[PATCH] [core] add support to resolve section groups.

Shankar Kalpathi Easwaran shankarke at gmail.com
Tue Mar 25 11:31:27 PDT 2014


  Reference : IA-64 gABI Issue 72: COMDAT

  C++ has many situations where the compiler may need to emit code or data, but may not be able to identify a unique compilation unit where it should be emitted. The approach chosen by the C++ ABI group to deal with this problem, is to allow the compiler to emit the required information in multiple compilation units, in a form which allows the linker to remove all but one copy. This is essentially the feature called COMDAT in several existing implementations.

  The COMDAT sections in ELF are modeled by using '.group' sections in the input files. Each '.group' section is associated with a signature. The '.group' section has a list of members that are part of the the '.group' which the linker selects to appear in the input file(Whichever .group section appeared first in the link). References to any of the '.group' members can also appear from outside the '.group'.

  In lld the the '.group' sections with COMDAT are identified by a contentType = typeGroupComdat
  The '.group' members are identified by using kindGroupChild references.
  The group child members have a reference to the group section by using kindGroupParent references.

  The point to be noted here is the 'group child' members would need to be emitted in the output file iff the group was selected by the resolver.

  This is modeled in lld by removing the 'group child' members from the definedAtom List.

  Any reference to the group-child from outside the group is referred using a 'undefined' atom.

  The testcases along with this change exercise all the options listed, and provides a way to resolve section groups in the core linker so that the functionality can be exercised from other readers as well.


More information about the llvm-commits mailing list