[PATCH] [PECOFF] Support COMDAT associative sections.

Rui Ueyama ruiu at google.com
Thu Jun 5 02:06:07 PDT 2014


Hi Bigcheese, shankarke, atanasyan,

This is a rework of r210240 to do it in the right way. Previously
it depended on dead-stripping pass to remove unneeded atoms, so
if the pass is not enabled it wouldn't work. This patch does not
depends on dead-stripping pass.

Background:
COFF supports a feature similar to ELF's section groups. This
patch implements it.

In ELF, section groups are identified by their names, and they are
treated somewhat differently from regular symbols. In COFF, the
feature is realized in a more straightforward way. A section can
have an annotation saying "if Nth section is linked, link this
section too." The annotation type is SELECT_ASSOCIATE.

Design:
A new method associate() is added to DefinedAtom. The new method
is supposed to return a list of atoms with SELECT_ASSOCIATE. The
Resolver adds live atom's associates() return values to the live
atom list. By default, assocaites() returns an empty list, so the
default behavior is the same as before.

Caveats:
The reason why I added a new member function associate() to
DefinedAtom, rather than adding a new reference type is mainly
performance. In order to collect all references of some type,
we have to scan all references of all atoms, which is more
costly than calling a member function on all atoms.

http://reviews.llvm.org/D4028

Files:
  include/lld/Core/DefinedAtom.h
  include/lld/Core/Resolver.h
  lib/Core/DefinedAtom.cpp
  lib/Core/Resolver.cpp
  lib/ReaderWriter/PECOFF/Atoms.h
  lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
  test/pecoff/Inputs/associative1.obj.yaml
  test/pecoff/Inputs/associative3.obj.yaml
  test/pecoff/associative.test
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4028.10127.patch
Type: text/x-patch
Size: 11206 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140605/73167a68/attachment.bin>


More information about the llvm-commits mailing list