[PATCH] [lld][core] sectionGroup support.

kledzik at apple.com kledzik at apple.com
Thu Feb 6 11:04:56 PST 2014


  My understanding of ELF groups (I think it is call group COMDAT) is that there is a set of symbols that are "grouped" together, and one of them is the "signature" for the group.  The linker's rule is that either everything in a group is kept or everything in the group is tossed.  The signature symbol is important because it determines if the group is kept or not.  For instance:

  File A:
    int foo() { return 0; }

  File B;
    __attribute__((weak)) int foo() { static int r = get(); return r; }

  And for file A, the compiler generates a group that contains just "foo" which is also the signature for the group.  For file B, the compiler generates a group that contains "foo" and "r" and the signature is "foo".

  When linking these together, if the linker chooses the "foo" from A (and it should because non-weak trumps weak), then the linker needs to toss the "foo" from B *and* the "r' from B because it was part of the group that was tossed.


  If this model is correct, I don't see the need for a group atom (typeSignature).  All we need is two Reference Kinds: kindGroupMember and kindGroupSignature.  The atom for the signature symbol has kindGroupMember references to each other atom in the group and each other atom have one kindGroupSignature reference to the signature atom.

  When coalescing, the Resolver looks at each atom it is about to remove (coalesced away) and if it has kindGroupMember references, then each of those atoms are coalesced away too.

http://llvm-reviews.chandlerc.com/D2710



More information about the llvm-commits mailing list