This is an archive of the discontinued LLVM Phabricator instance.

COFF: Do not assign linker-weak symbols to selectany comdat sections.
ClosedPublic

Authored by pcc on Jun 29 2015, 8:31 PM.

Details

Summary

It is mandatory to specify a comdat in order to receive comdat semantics
for a symbol. We were previously getting this wrong in -function-sections
mode; linker-weak symbols were being emitted in a selectany comdat. This
change causes such symbols to use a noduplicates comdat instead, fixing
the inconsistency.

Also correct an inaccuracy in the docs.

Diff Detail

Event Timeline

pcc updated this revision to Diff 28745.Jun 29 2015, 8:31 PM
pcc retitled this revision from to COFF: Do not assign linker-weak symbols to selectany comdat sections..
pcc updated this object.
pcc edited the test plan for this revision. (Show Details)
pcc added a reviewer: majnemer.
pcc added a subscriber: Unknown Object (MLST).
majnemer edited edge metadata.Jun 29 2015, 11:35 PM
majnemer added a subscriber: rafael.

@rafael, what do you think?

2015-06-30 2:36 GMT-04:00 David Majnemer <david.majnemer@gmail.com>:

@rafael, what do you think?

If I remember correctly, the only reason for using comdats at all with
-function-sections was so that link.exe could gc the sections.

Does that still work with IMAGE_COMDAT_SELECT_NODUPLICATES? If so this
LGTM, otherwise we should probably stop using comdats for
-ffunction-sections.

Cheers,
Rafael

pcc added a comment.Jun 30 2015, 12:05 PM

I have verified (with the /map flag) that link.exe will GC unused noduplicates comdat sections.

This revision was automatically updated to reflect the committed changes.