From 719dc7c4369f3e9eb38802d0d3f18dc365fc56cf Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 29 Jun 2015 12:38:31 +0000 Subject: Remove Elf_Sym_Iter. It was a fairly broken concept for an ELF only class. An ELF file can have two symbol tables, but they have exactly the same format. There is no concept of a dynamic or a static symbol. Storing this on the iterator also makes us do more work per symbol than necessary. To fetch a name we would: * Find if we had a static or a dynamic symbol. * Look at the corresponding symbol table and find the string table section. * Look at the string table section to fetch its contents. * Compute the name as a substring of the string table. All but the last step can be done per symbol table instead of per symbol. This is a step in that direction. llvm-svn: 240939 --- llvm/tools/llvm-objdump/llvm-objdump.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'llvm/tools/llvm-objdump/llvm-objdump.cpp') diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp index 77c425d..610d548 100644 --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -321,6 +321,10 @@ static std::error_code getRelocationValueString(const ELFObjectFile *Obj, const ELFFile &EF = *Obj->getELFFile(); const Elf_Shdr *sec = EF.getSection(Rel.d.a); + const Elf_Shdr *SymTab = EF.getSection(sec->sh_link); + assert(SymTab->sh_type == ELF::SHT_SYMTAB || + SymTab->sh_type == ELF::SHT_DYNSYM); + const Elf_Shdr *StrTab = EF.getSection(SymTab->sh_link); uint8_t type; StringRef res; int64_t addend = 0; @@ -351,8 +355,7 @@ static std::error_code getRelocationValueString(const ELFObjectFile *Obj, return EC; Target = *SecName; } else { - ErrorOr SymName = - EF.getSymbolName(EF.getSection(sec->sh_link), symb); + ErrorOr SymName = EF.getSymbolName(StrTab, symb); if (!SymName) return SymName.getError(); Target = *SymName; -- cgit v1.1