This is an archive of the discontinued LLVM Phabricator instance.

[lld][ELF] Support for zero flag section groups
ClosedPublic

Authored by phosek on Feb 12 2021, 2:31 PM.

Details

Summary

This change introduces support for zero flag ELF section groups to lld.
lld already supports COMDAT sections, which in ELF are a special type of
ELF section groups. These are generally useful to enable linker GC where
you want a group of sections to always travel together, that is to be
either retained or discarded as a whole, but without the COMDAT
semantics. Other ELF linkers already support zero flag ELF section
groups and this change helps us reach feature parity.

Diff Detail

Event Timeline

phosek created this revision.Feb 12 2021, 2:31 PM
phosek requested review of this revision.Feb 12 2021, 2:31 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 12 2021, 2:31 PM
MaskRay added inline comments.Feb 13 2021, 3:01 PM
lld/test/ELF/gc-sections-group-debug.s
11 ↗(On Diff #323482)

This tests a real world use case, .debug_types which has the GRP_COMDAT flag.

You can add another section to gc-sections-group.s

phosek updated this revision to Diff 323578.Feb 13 2021, 3:41 PM
phosek marked an inline comment as done.
phosek updated this revision to Diff 323579.Feb 13 2021, 3:43 PM
phosek updated this revision to Diff 323580.Feb 13 2021, 4:02 PM
MaskRay accepted this revision.Feb 13 2021, 4:57 PM

LGTM.

This revision is now accepted and ready to land.Feb 13 2021, 4:57 PM
jhenderson accepted this revision.Feb 15 2021, 2:08 AM

Looks good, with a couple of small comments.

lld/ELF/InputFiles.cpp
621

I wonder whether isNew is a bit misnamed nowadays. Perhaps it should be renamed to keepGroup or something like that. Waht do you think?

lld/test/ELF/gc-sections-group.s
65
phosek updated this revision to Diff 324054.Feb 16 2021, 11:01 AM
phosek marked 2 inline comments as done.
phosek added inline comments.
lld/ELF/InputFiles.cpp
621

That makes sense, I've renamed this to keepGroup.

This revision was landed with ongoing or failed builds.Feb 16 2021, 2:34 PM
This revision was automatically updated to reflect the committed changes.
This comment was removed by mehdi_amini.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 26 2023, 4:42 PM