diff options
-rw-r--r-- | lld/ELF/InputFiles.cpp | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index 25fff944c2e..ee9eff72bf9 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -205,8 +205,6 @@ void elf::ObjectFile<ELFT>::parse(DenseSet<CachedHashStringRef> &ComdatGroups) { // Read section and symbol tables. initializeSections(ComdatGroups); initializeSymbols(); - if (Config->GcSections && Config->EMachine == EM_ARM) - initializeReverseDependencies(); } // Sections with SHT_GROUP and comdat bits define comdat section groups. @@ -331,24 +329,16 @@ void elf::ObjectFile<ELFT>::initializeSections( default: Sections[I] = createInputSection(Sec, SectionStringTable); } - } -} -// .ARM.exidx sections have a reverse dependency on the InputSection they -// have a SHF_LINK_ORDER dependency, this is identified by the sh_link. -template <class ELFT> -void elf::ObjectFile<ELFT>::initializeReverseDependencies() { - unsigned I = -1; - for (const Elf_Shdr &Sec : this->ELFObj.sections()) { - ++I; - if ((Sections[I] == &InputSection<ELFT>::Discarded) || - !(Sec.sh_flags & SHF_LINK_ORDER)) - continue; - if (Sec.sh_link >= Sections.size()) - fatal(getFilename(this) + ": invalid sh_link index: " + - Twine(Sec.sh_link)); - auto *IS = cast<InputSection<ELFT>>(Sections[Sec.sh_link]); - IS->DependentSection = Sections[I]; + // .ARM.exidx sections have a reverse dependency on the InputSection they + // have a SHF_LINK_ORDER dependency, this is identified by the sh_link. + if (Sec.sh_flags & SHF_LINK_ORDER) { + if (Sec.sh_link >= Sections.size()) + fatal(getFilename(this) + ": invalid sh_link index: " + + Twine(Sec.sh_link)); + auto *IS = cast<InputSection<ELFT>>(Sections[Sec.sh_link]); + IS->DependentSection = Sections[I]; + } } } |