[lld] r285755 - Don't fetch the section string table multiple times. NFC.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 1 14:48:01 PDT 2016


Author: rafael
Date: Tue Nov  1 16:48:00 2016
New Revision: 285755

URL: http://llvm.org/viewvc/llvm-project?rev=285755&view=rev
Log:
Don't fetch the section string table multiple times. NFC.

Modified:
    lld/trunk/ELF/InputFiles.cpp
    lld/trunk/ELF/InputFiles.h

Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=285755&r1=285754&r2=285755&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Tue Nov  1 16:48:00 2016
@@ -292,6 +292,7 @@ void elf::ObjectFile<ELFT>::initializeSe
   Sections.resize(Size);
   unsigned I = -1;
   const ELFFile<ELFT> &Obj = this->ELFObj;
+  StringRef SectionStringTable = check(Obj.getSectionStringTable());
   for (const Elf_Shdr &Sec : Obj.sections()) {
     ++I;
     if (Sections[I] == &InputSection<ELFT>::Discarded)
@@ -328,7 +329,7 @@ void elf::ObjectFile<ELFT>::initializeSe
     case SHT_NULL:
       break;
     default:
-      Sections[I] = createInputSection(Sec);
+      Sections[I] = createInputSection(Sec, SectionStringTable);
     }
   }
 }
@@ -373,8 +374,9 @@ elf::ObjectFile<ELFT>::getRelocTarget(co
 
 template <class ELFT>
 InputSectionBase<ELFT> *
-elf::ObjectFile<ELFT>::createInputSection(const Elf_Shdr &Sec) {
-  StringRef Name = check(this->ELFObj.getSectionName(&Sec));
+elf::ObjectFile<ELFT>::createInputSection(const Elf_Shdr &Sec,
+                                          StringRef SectionStringTable) {
+  StringRef Name = check(this->ELFObj.getSectionName(&Sec, SectionStringTable));
 
   switch (Sec.sh_type) {
   case SHT_ARM_ATTRIBUTES:

Modified: lld/trunk/ELF/InputFiles.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.h?rev=285755&r1=285754&r2=285755&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.h (original)
+++ lld/trunk/ELF/InputFiles.h Tue Nov  1 16:48:00 2016
@@ -199,7 +199,8 @@ private:
   void initializeSymbols();
   void initializeReverseDependencies();
   InputSectionBase<ELFT> *getRelocTarget(const Elf_Shdr &Sec);
-  InputSectionBase<ELFT> *createInputSection(const Elf_Shdr &Sec);
+  InputSectionBase<ELFT> *createInputSection(const Elf_Shdr &Sec,
+                                             StringRef SectionStringTable);
 
   bool shouldMerge(const Elf_Shdr &Sec);
   SymbolBody *createSymbolBody(const Elf_Sym *Sym);




More information about the llvm-commits mailing list