[PECOFF] Support COMDAT associative sections.
authorRui Ueyama <ruiu@google.com>
Thu, 5 Jun 2014 07:37:20 +0000 (07:37 +0000)
committerRui Ueyama <ruiu@google.com>
Thu, 5 Jun 2014 07:37:20 +0000 (07:37 +0000)
commitf3cb9d1d57a763d46d4e7e46e660f06c9fb8ad55
treea6e1a1e9b068a2be81376f3319d557d871d01cb8
parentff114dae5afadfc95ab8f670402ba8f141d52de2
[PECOFF] Support COMDAT associative sections.

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."

Implementing such feature is easy. We can add a reference from a
target atom to an original atom, so that if the target is linked,
the original atom is also linked. If not linked, both will be
dead-stripped. So they are treated as a group.

I added a new reference type, kindAssociate. It does nothing except
preventing referenced atoms from being dead-stripped.

No change to the Resolver is needed.

Reviewers: Bigcheese, shankarke, atanasyan

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D3946

llvm-svn: 210240
lld/include/lld/Core/Reference.h
lld/lib/ReaderWriter/PECOFF/Atoms.h
lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
lld/lib/ReaderWriter/Reader.cpp
lld/test/pecoff/Inputs/associative1.obj.yaml [new file with mode: 0644]
lld/test/pecoff/Inputs/associative3.obj.yaml [new file with mode: 0644]
lld/test/pecoff/associative.test [new file with mode: 0644]