[lld] r285805 - Simplify SHF_LINK_ORDER handling. NFC.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 2 06:36:31 PDT 2016


Author: rafael
Date: Wed Nov  2 08:36:31 2016
New Revision: 285805

URL: http://llvm.org/viewvc/llvm-project?rev=285805&view=rev
Log:
Simplify SHF_LINK_ORDER handling. NFC.

While ARM is the only currently user we support this is a general
feature.

This avoids a second walk over the sections.

Modified:
    lld/trunk/ELF/InputFiles.cpp

Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=285805&r1=285804&r2=285805&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Wed Nov  2 08:36:31 2016
@@ -205,8 +205,6 @@ void elf::ObjectFile<ELFT>::parse(DenseS
   // 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>::initializeSe
     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];
+    }
   }
 }
 




More information about the llvm-commits mailing list