This is small change, on the principle, "let's keep the commits small and take little baby steps in each commit".
APPLIES AFTER:
- D40845 (LLD Comdat support)
This beefs up Sam's change with a few lines of code taken from ELF-LLD, which has the notion of "discarded" input sections. We now have "discarded" InputSegments/InputFunctions.
As proof of concept, I've implemented discarding duplicate weak symbols. If two files both define the same function weakly, then the second copy shouldn't be written out, since all calls to it will go via relocations, and no relocations can touch the function if it's not reachable via any Symbols. Hence if every translation unit provides a function like "std::string::whatever" it will only be written out once.
The behaviour is covered by existing tests, which exercise the weak symbols code, and assert on the output.
This size of a global symbol isn't represented this way. In fact we don't represent the size at all currently.