[llvm] r285898 - Split getSHNDXTable in two.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 3 05:23:41 PDT 2016


Author: rafael
Date: Thu Nov  3 07:23:41 2016
New Revision: 285898

URL: http://llvm.org/viewvc/llvm-project?rev=285898&view=rev
Log:
Split getSHNDXTable in two.

Some clients already have the section table available.

Modified:
    llvm/trunk/include/llvm/Object/ELF.h

Modified: llvm/trunk/include/llvm/Object/ELF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELF.h?rev=285898&r1=285897&r2=285898&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELF.h (original)
+++ llvm/trunk/include/llvm/Object/ELF.h Thu Nov  3 07:23:41 2016
@@ -81,6 +81,8 @@ public:
   ErrorOr<StringRef> getStringTableForSymtab(const Elf_Shdr &Section) const;
 
   ErrorOr<ArrayRef<Elf_Word>> getSHNDXTable(const Elf_Shdr &Section) const;
+  ErrorOr<ArrayRef<Elf_Word>> getSHNDXTable(const Elf_Shdr &Section,
+                                            Elf_Shdr_Range Sections) const;
 
   void VerifyStrTab(const Elf_Shdr *sh) const;
 
@@ -423,12 +425,23 @@ ELFFile<ELFT>::getStringTable(const Elf_
 template <class ELFT>
 ErrorOr<ArrayRef<typename ELFT::Word>>
 ELFFile<ELFT>::getSHNDXTable(const Elf_Shdr &Section) const {
+  auto SectionsOrErr = sections();
+  if (std::error_code EC = SectionsOrErr.getError())
+    return EC;
+  return getSHNDXTable(Section, *SectionsOrErr);
+}
+
+template <class ELFT>
+ErrorOr<ArrayRef<typename ELFT::Word>>
+ELFFile<ELFT>::getSHNDXTable(const Elf_Shdr &Section,
+                             Elf_Shdr_Range Sections) const {
   assert(Section.sh_type == ELF::SHT_SYMTAB_SHNDX);
   auto VOrErr = getSectionContentsAsArray<Elf_Word>(&Section);
   if (std::error_code EC = VOrErr.getError())
     return EC;
   ArrayRef<Elf_Word> V = *VOrErr;
-  ErrorOr<const Elf_Shdr *> SymTableOrErr = getSection(Section.sh_link);
+  ErrorOr<const Elf_Shdr *> SymTableOrErr =
+      object::getSection<ELFT>(Sections, Section.sh_link);
   if (std::error_code EC = SymTableOrErr.getError())
     return EC;
   const Elf_Shdr &SymTable = **SymTableOrErr;




More information about the llvm-commits mailing list