summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2017-06-09 02:42:20 +0000
committerRui Ueyama <ruiu@google.com>2017-06-09 02:42:20 +0000
commita1ba859ad3d01fb15f8ac1aa1d51d11f1481aad1 (patch)
tree19ac8025511b975a4a6f2755b087f0c23c864c8e
parent783e4c2e3257baea011b578958feed1a0de42ff6 (diff)
downloadbcm5719-llvm-a1ba859ad3d01fb15f8ac1aa1d51d11f1481aad1.tar.gz
bcm5719-llvm-a1ba859ad3d01fb15f8ac1aa1d51d11f1481aad1.zip
Simplify. NFC.
llvm-svn: 305047
-rw-r--r--lld/ELF/InputFiles.cpp28
1 files changed, 15 insertions, 13 deletions
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index 98189825ccb..524246ed1d1 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -306,21 +306,23 @@ void elf::ObjectFile<ELFT>::initializeSections(
switch (Sec.sh_type) {
case SHT_GROUP: {
- // We discard comdat sections usually. When -r we should not do that. We
- // still do deduplication in this case to simplify implementation, because
- // otherwise merging group sections together would requre additional
- // regeneration of its contents.
- bool New = ComdatGroups
- .insert(CachedHashStringRef(
- getShtGroupSignature(ObjSections, Sec)))
- .second;
- if (New && Config->Relocatable)
- this->Sections[I] = createInputSection(Sec, SectionStringTable);
- else
- this->Sections[I] = &InputSection::Discarded;
- if (New)
+ // De-duplicate section groups by their signatures.
+ StringRef Signature = getShtGroupSignature(ObjSections, Sec);
+ bool IsNew = ComdatGroups.insert(CachedHashStringRef(Signature)).second;
+ this->Sections[I] = &InputSection::Discarded;
+
+ // If it is a new section group, we want to keep group members.
+ // Group leader sections, which contain indices of group members, are
+ // discarded because they are useless beyond this point. The only
+ // exception is the -r option because in order to produce re-linkable
+ // object files, we want to pass through basically everything.
+ if (IsNew) {
+ if (Config->Relocatable)
+ this->Sections[I] = createInputSection(Sec, SectionStringTable);
continue;
+ }
+ // Otherwise, discard group members.
for (uint32_t SecIndex : getShtGroupEntries(Sec)) {
if (SecIndex >= Size)
fatal(toString(this) +
OpenPOWER on IntegriCloud