From 09ad805fcfd1383d555389e5961479defb68620b Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 7 Aug 2015 16:51:44 +0000 Subject: [PATCH] Don't use a DenseMap to handle SHT_SYMTAB_SHNDX. It is already a convenient table. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@244333 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/ELF.h | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/include/llvm/Object/ELF.h b/include/llvm/Object/ELF.h index e91c6e63caa..3ec28f05dec 100644 --- a/include/llvm/Object/ELF.h +++ b/include/llvm/Object/ELF.h @@ -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 ExtendedSymbolTable; public: template @@ -263,9 +261,14 @@ typedef ELFFile> ELF64BEFile; template ELF::Elf64_Word -ELFFile::getExtendedSymbolTableIndex(const Elf_Sym *symb) const { - assert(symb->st_shndx == ELF::SHN_XINDEX); - return ExtendedSymbolTable.lookup(symb); +ELFFile::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( + base() + SymbolTableSectionHeaderIndex->sh_offset); + return ShndxTable[Index]; } template @@ -273,7 +276,7 @@ ErrorOr::Elf_Shdr *> ELFFile::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::ELFFile(StringRef Object, std::error_code &EC) DotShstrtab = *SymtabOrErr; } - // Build symbol name side-mapping if there is one. - if (SymbolTableSectionHeaderIndex) { - const Elf_Word *ShndxTable = reinterpret_cast(base() + - SymbolTableSectionHeaderIndex->sh_offset); - for (const Elf_Sym &S : symbols()) { - if (*ShndxTable != ELF::SHN_UNDEF) - ExtendedSymbolTable[&S] = *ShndxTable; - ++ShndxTable; - } - } - EC = std::error_code(); } -- 2.34.1