[PATCH] D60244: ELF: Move SymtabSHNDX and getSectionIndex() to ObjFile. NFCI.

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 3 20:03:55 PDT 2019


pcc created this revision.
pcc added a reviewer: ruiu.
Herald added subscribers: arphaman, MaskRay, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D60244

Files:
  lld/ELF/InputFiles.cpp
  lld/ELF/InputFiles.h


Index: lld/ELF/InputFiles.h
===================================================================
--- lld/ELF/InputFiles.h
+++ lld/ELF/InputFiles.h
@@ -161,15 +161,12 @@
 
   StringRef getStringTable() const { return StringTable; }
 
-  uint32_t getSectionIndex(const Elf_Sym &Sym) const;
-
   Elf_Sym_Range getGlobalELFSyms();
   Elf_Sym_Range getELFSyms() const { return ELFSyms; }
 
 protected:
   ArrayRef<Elf_Sym> ELFSyms;
   uint32_t FirstGlobal = 0;
-  ArrayRef<Elf_Word> SymtabSHNDX;
   StringRef StringTable;
   void initSymtab(ArrayRef<Elf_Shdr> Sections, const Elf_Shdr *Symtab);
 };
@@ -202,6 +199,8 @@
     return *this->Symbols[SymbolIndex];
   }
 
+  uint32_t getSectionIndex(const Elf_Sym &Sym) const;
+
   template <typename RelT> Symbol &getRelocTargetSym(const RelT &Rel) const {
     uint32_t SymIndex = Rel.getSymbol(Config->IsMips64EL);
     return getSymbol(SymIndex);
@@ -247,6 +246,8 @@
   bool shouldMerge(const Elf_Shdr &Sec);
   Symbol *createSymbol(const Elf_Sym *Sym);
 
+  ArrayRef<Elf_Word> SymtabSHNDX;
+
   // .shstrtab contents.
   StringRef SectionStringTable;
 
Index: lld/ELF/InputFiles.cpp
===================================================================
--- lld/ELF/InputFiles.cpp
+++ lld/ELF/InputFiles.cpp
@@ -258,11 +258,6 @@
   return makeArrayRef(ELFSyms.begin() + FirstGlobal, ELFSyms.end());
 }
 
-template <class ELFT>
-uint32_t ELFFileBase<ELFT>::getSectionIndex(const Elf_Sym &Sym) const {
-  return CHECK(getObj().getSectionIndex(&Sym, ELFSyms, SymtabSHNDX), this);
-}
-
 template <class ELFT>
 void ELFFileBase<ELFT>::initSymtab(ArrayRef<Elf_Shdr> Sections,
                                    const Elf_Shdr *Symtab) {
@@ -281,6 +276,12 @@
   this->ArchiveName = ArchiveName;
 }
 
+template <class ELFT>
+uint32_t ObjFile<ELFT>::getSectionIndex(const Elf_Sym &Sym) const {
+  return CHECK(this->getObj().getSectionIndex(&Sym, this->ELFSyms, SymtabSHNDX),
+               this);
+}
+
 template <class ELFT> ArrayRef<Symbol *> ObjFile<ELFT>::getLocalSymbols() {
   if (this->Symbols.empty())
     return {};
@@ -890,9 +891,6 @@
     case SHT_DYNAMIC:
       DynamicSec = &Sec;
       break;
-    case SHT_SYMTAB_SHNDX:
-      this->SymtabSHNDX = CHECK(Obj.getSHNDXTable(Sec, Sections), this);
-      break;
     case SHT_GNU_versym:
       this->VersymSec = &Sec;
       break;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60244.193645.patch
Type: text/x-patch
Size: 2330 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190404/2d0822fd/attachment.bin>


More information about the llvm-commits mailing list