As an optimization, llvm-ar skips writing the symbol table when it already exists. This is a workaround for build systems that needlessly run ar/ranlib to create a symbol table, even if it already exists.
However, some tools manipulate the archive, and then use ar/ranlib to fix up the symbol table. (Nvidia's nvprune does this). This patch adds a heuristic to determine if the symbol table is invalid, and if so, will rewrite it. This still achieves the goal of the common case, avoiding needless writes when the symbol table is valid, although at the cost of a few more reads (iterating over all members of the symbol table instead of just checking that it exists).
It seems that this function detect certain type of breakage. What kind of breakage does this logic can catch? Is that that common and no other types of breakage uncmmon?