From: Rafael Espindola Date: Tue, 21 Jul 2015 18:04:29 +0000 (+0000) Subject: Remove getStaticSymbolName. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=9ed0d629ce9ee7a1a8d7231347ad3050d1f98732;p=oota-llvm.git Remove getStaticSymbolName. Every user now keeps track of the correct string table to use. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242818 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Object/ELF.h b/include/llvm/Object/ELF.h index 4ba5bc10ffe..6ebb92f7ee8 100644 --- a/include/llvm/Object/ELF.h +++ b/include/llvm/Object/ELF.h @@ -388,7 +388,6 @@ public: ErrorOr getSection(uint32_t Index) const; const Elf_Sym *getSymbol(uint32_t index) const; - ErrorOr getStaticSymbolName(const Elf_Sym *Symb) const; ErrorOr getDynamicSymbolName(const Elf_Sym *Symb) const; ErrorOr getSectionName(const Elf_Shdr *Section) const; @@ -897,12 +896,6 @@ const char *ELFFile::getDynamicString(uintX_t Offset) const { return (const char *)DynStrRegion.Addr + Offset; } -template -ErrorOr -ELFFile::getStaticSymbolName(const Elf_Sym *Symb) const { - return Symb->getName(DotStrtab); -} - template ErrorOr ELFFile::getDynamicSymbolName(const Elf_Sym *Symb) const { diff --git a/tools/obj2yaml/elf2yaml.cpp b/tools/obj2yaml/elf2yaml.cpp index 05efdb6c759..def3981eae1 100644 --- a/tools/obj2yaml/elf2yaml.cpp +++ b/tools/obj2yaml/elf2yaml.cpp @@ -27,7 +27,8 @@ class ELFDumper { const object::ELFFile &Obj; - std::error_code dumpSymbol(const Elf_Sym *Sym, ELFYAML::Symbol &S); + std::error_code dumpSymbol(const Elf_Sym *Sym, StringRef StrTable, + ELFYAML::Symbol &S); std::error_code dumpCommonSection(const Elf_Shdr *Shdr, ELFYAML::Section &S); std::error_code dumpCommonRelocationSection(const Elf_Shdr *Shdr, ELFYAML::RelocationSection &S); @@ -121,6 +122,12 @@ ErrorOr ELFDumper::dump() { } // Dump symbols + const Elf_Shdr *Symtab = Obj.getDotSymtabSec(); + ErrorOr StrTableOrErr = Obj.getStringTableForSymtab(*Symtab); + if (std::error_code EC = StrTableOrErr.getError()) + return EC; + StringRef StrTable = *StrTableOrErr; + bool IsFirstSym = true; for (const Elf_Sym &Sym : Obj.symbols()) { if (IsFirstSym) { @@ -129,7 +136,7 @@ ErrorOr ELFDumper::dump() { } ELFYAML::Symbol S; - if (std::error_code EC = ELFDumper::dumpSymbol(&Sym, S)) + if (std::error_code EC = ELFDumper::dumpSymbol(&Sym, StrTable, S)) return EC; switch (Sym.getBinding()) @@ -153,13 +160,14 @@ ErrorOr ELFDumper::dump() { template std::error_code ELFDumper::dumpSymbol(const Elf_Sym *Sym, + StringRef StrTable, ELFYAML::Symbol &S) { S.Type = Sym->getType(); S.Value = Sym->st_value; S.Size = Sym->st_size; S.Other = Sym->st_other; - ErrorOr NameOrErr = Obj.getStaticSymbolName(Sym); + ErrorOr NameOrErr = Sym->getName(StrTable); if (std::error_code EC = NameOrErr.getError()) return EC; S.Name = NameOrErr.get();