[llvm] r244333 - Don't use a DenseMap to handle SHT_SYMTAB_SHNDX.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 7 09:51:44 PDT 2015


Author: rafael
Date: Fri Aug  7 11:51:44 2015
New Revision: 244333

URL: http://llvm.org/viewvc/llvm-project?rev=244333&view=rev
Log:
Don't use a DenseMap to handle SHT_SYMTAB_SHNDX.

It is already a convenient table.

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=244333&r1=244332&r2=244333&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELF.h (original)
+++ llvm/trunk/include/llvm/Object/ELF.h Fri Aug  7 11:51:44 2015
@@ -15,7 +15,6 @@
 #define LLVM_OBJECT_ELF_H
 
 #include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringSwitch.h"
@@ -102,7 +101,6 @@ private:
   const Elf_Shdr *DotDynSymSec = nullptr;   // Dynamic symbol table section.
 
   const Elf_Shdr *SymbolTableSectionHeaderIndex = nullptr;
-  DenseMap<const Elf_Sym *, ELF::Elf64_Word> ExtendedSymbolTable;
 
 public:
   template<typename T>
@@ -263,9 +261,14 @@ typedef ELFFile<ELFType<support::big, tr
 
 template <class ELFT>
 ELF::Elf64_Word
-ELFFile<ELFT>::getExtendedSymbolTableIndex(const Elf_Sym *symb) const {
-  assert(symb->st_shndx == ELF::SHN_XINDEX);
-  return ExtendedSymbolTable.lookup(symb);
+ELFFile<ELFT>::getExtendedSymbolTableIndex(const Elf_Sym *Sym) const {
+  assert(Sym->st_shndx == ELF::SHN_XINDEX);
+  unsigned Index = Sym - symbol_begin();
+
+  // FIXME: error checking
+  const Elf_Word *ShndxTable = reinterpret_cast<const Elf_Word *>(
+      base() + SymbolTableSectionHeaderIndex->sh_offset);
+  return ShndxTable[Index];
 }
 
 template <class ELFT>
@@ -273,7 +276,7 @@ ErrorOr<const typename ELFFile<ELFT>::El
 ELFFile<ELFT>::getSection(const Elf_Sym *symb) const {
   uint32_t Index = symb->st_shndx;
   if (Index == ELF::SHN_XINDEX)
-    return getSection(ExtendedSymbolTable.lookup(symb));
+    return getSection(getExtendedSymbolTableIndex(symb));
   if (Index == ELF::SHN_UNDEF || Index >= ELF::SHN_LORESERVE)
     return nullptr;
   return getSection(symb->st_shndx);
@@ -444,17 +447,6 @@ ELFFile<ELFT>::ELFFile(StringRef Object,
     DotShstrtab = *SymtabOrErr;
   }
 
-  // Build symbol name side-mapping if there is one.
-  if (SymbolTableSectionHeaderIndex) {
-    const Elf_Word *ShndxTable = reinterpret_cast<const Elf_Word*>(base() +
-                                      SymbolTableSectionHeaderIndex->sh_offset);
-    for (const Elf_Sym &S : symbols()) {
-      if (*ShndxTable != ELF::SHN_UNDEF)
-        ExtendedSymbolTable[&S] = *ShndxTable;
-      ++ShndxTable;
-    }
-  }
-
   EC = std::error_code();
 }
 




More information about the llvm-commits mailing list