diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-06-10 13:44:49 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-06-10 13:44:49 +0000 |
commit | 2079716dfb3fb7e4e24b8b2e85eb6780b981a0af (patch) | |
tree | 3b0c58e50948b450b50b20ae5a38c005128edfb5 /ELF/InputFiles.cpp | |
parent | b9a1baec33e911ca24f51abf882d454e62047ea6 (diff) | |
download | src-2079716dfb3fb7e4e24b8b2e85eb6780b981a0af.tar.gz src-2079716dfb3fb7e4e24b8b2e85eb6780b981a0af.zip |
Vendor import of lld trunk r305145:vendor/lld/lld-trunk-r305145
Notes
Notes:
svn path=/vendor/lld/dist/; revision=319788
svn path=/vendor/lld/lld-trunk-r305145/; revision=319789; tag=vendor/lld/lld-trunk-r305145
Diffstat (limited to 'ELF/InputFiles.cpp')
-rw-r--r-- | ELF/InputFiles.cpp | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/ELF/InputFiles.cpp b/ELF/InputFiles.cpp index 98189825ccbf..524246ed1d17 100644 --- a/ELF/InputFiles.cpp +++ b/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) + |