[PATCH] D96636: [lld][ELF] Support for zero flag section groups
Petr Hosek via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 12 14:31:41 PST 2021
phosek created this revision.
phosek added reviewers: MaskRay, jhenderson, mcgrathr, ruiu.
Herald added subscribers: arichardson, emaste.
phosek requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D96636
Files:
lld/ELF/InputFiles.cpp
lld/test/ELF/gc-sections-group-debug.s
Index: lld/test/ELF/gc-sections-group-debug.s
===================================================================
--- lld/test/ELF/gc-sections-group-debug.s
+++ lld/test/ELF/gc-sections-group-debug.s
@@ -8,5 +8,5 @@
# CHECK: Name: .debug_types
-.section .debug_types,"G", at progbits,abcd,comdat
+.section .debug_types,"G", at progbits,abcd
.quad .debug_types
Index: lld/ELF/InputFiles.cpp
===================================================================
--- lld/ELF/InputFiles.cpp
+++ lld/ELF/InputFiles.cpp
@@ -609,24 +609,17 @@
StringRef signature = getShtGroupSignature(objSections, sec);
this->sections[i] = &InputSection::discarded;
-
ArrayRef<Elf_Word> entries =
CHECK(obj.template getSectionContentsAsArray<Elf_Word>(sec), this);
if (entries.empty())
fatal(toString(this) + ": empty SHT_GROUP");
- // The first word of a SHT_GROUP section contains flags. Currently,
- // the standard defines only "GRP_COMDAT" flag for the COMDAT group.
- // An group with the empty flag doesn't define anything; such sections
- // are just skipped.
- if (entries[0] == 0)
- continue;
-
- if (entries[0] != GRP_COMDAT)
+ Elf_Word flag = entries[0];
+ if (flag && flag != GRP_COMDAT)
fatal(toString(this) + ": unsupported SHT_GROUP format");
bool isNew =
- ignoreComdats ||
+ (flag & GRP_COMDAT) == 0 || ignoreComdats ||
symtab->comdatGroups.try_emplace(CachedHashStringRef(signature), this)
.second;
if (isNew) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96636.323482.patch
Type: text/x-patch
Size: 1575 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210212/5cb0e809/attachment.bin>
More information about the llvm-commits
mailing list