This is an archive of the discontinued LLVM Phabricator instance.

[PECOFF] Support COMDAT associative sections.
ClosedPublic

Authored by ruiu on May 28 2014, 10:42 PM.

Details

Summary

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.

Diff Detail

Repository
rL LLVM

Event Timeline

ruiu updated this revision to Diff 9905.May 28 2014, 10:42 PM
ruiu retitled this revision from to [PECOFF] Support COMDAT associative sections..
ruiu updated this object.
ruiu edited the test plan for this revision. (Show Details)
ruiu added reviewers: Bigcheese, shankarke, atanasyan.
ruiu added a subscriber: Unknown Object (MLST).
atanasyan edited edge metadata.May 29 2014, 5:03 AM

LGTM with minor question / note.

lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
174 ↗(On Diff #9905)

Is it really necessary to use the std::set here i.e. is it possible that a COFF file contains more than one "record" states that sections say "A" and "B" are associated?

rnk added a subscriber: rnk.May 29 2014, 9:56 AM

Is it OK to rely on dead stripping to remove associative comdat sections when the associated data is discarded? I thought it was possible for the user to disable dead stripping, in which case the result will be incorrect, and data will be initialized multiple times.

ruiu closed this revision.Jun 5 2014, 12:45 AM
ruiu updated this revision to Diff 10121.

Closed by commit rL210240 (authored by @ruiu).