[llvm] r242818 - Remove getStaticSymbolName.
Rafael Espindola
rafael.espindola at gmail.com
Tue Jul 21 11:04:29 PDT 2015
Author: rafael
Date: Tue Jul 21 13:04:29 2015
New Revision: 242818
URL: http://llvm.org/viewvc/llvm-project?rev=242818&view=rev
Log:
Remove getStaticSymbolName.
Every user now keeps track of the correct string table to use.
Modified:
llvm/trunk/include/llvm/Object/ELF.h
llvm/trunk/tools/obj2yaml/elf2yaml.cpp
Modified: llvm/trunk/include/llvm/Object/ELF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELF.h?rev=242818&r1=242817&r2=242818&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELF.h (original)
+++ llvm/trunk/include/llvm/Object/ELF.h Tue Jul 21 13:04:29 2015
@@ -388,7 +388,6 @@ public:
ErrorOr<const Elf_Shdr *> getSection(uint32_t Index) const;
const Elf_Sym *getSymbol(uint32_t index) const;
- ErrorOr<StringRef> getStaticSymbolName(const Elf_Sym *Symb) const;
ErrorOr<StringRef> getDynamicSymbolName(const Elf_Sym *Symb) const;
ErrorOr<StringRef> getSectionName(const Elf_Shdr *Section) const;
@@ -898,12 +897,6 @@ const char *ELFFile<ELFT>::getDynamicStr
}
template <class ELFT>
-ErrorOr<StringRef>
-ELFFile<ELFT>::getStaticSymbolName(const Elf_Sym *Symb) const {
- return Symb->getName(DotStrtab);
-}
-
-template <class ELFT>
ErrorOr<StringRef>
ELFFile<ELFT>::getDynamicSymbolName(const Elf_Sym *Symb) const {
return StringRef(getDynamicString(Symb->st_name));
Modified: llvm/trunk/tools/obj2yaml/elf2yaml.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/obj2yaml/elf2yaml.cpp?rev=242818&r1=242817&r2=242818&view=diff
==============================================================================
--- llvm/trunk/tools/obj2yaml/elf2yaml.cpp (original)
+++ llvm/trunk/tools/obj2yaml/elf2yaml.cpp Tue Jul 21 13:04:29 2015
@@ -27,7 +27,8 @@ class ELFDumper {
const object::ELFFile<ELFT> &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<ELFYAML::Object *> ELFDumper<ELF
}
// Dump symbols
+ const Elf_Shdr *Symtab = Obj.getDotSymtabSec();
+ ErrorOr<StringRef> 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<ELFYAML::Object *> ELFDumper<ELF
}
ELFYAML::Symbol S;
- if (std::error_code EC = ELFDumper<ELFT>::dumpSymbol(&Sym, S))
+ if (std::error_code EC = ELFDumper<ELFT>::dumpSymbol(&Sym, StrTable, S))
return EC;
switch (Sym.getBinding())
@@ -153,13 +160,14 @@ ErrorOr<ELFYAML::Object *> ELFDumper<ELF
template <class ELFT>
std::error_code ELFDumper<ELFT>::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<StringRef> NameOrErr = Obj.getStaticSymbolName(Sym);
+ ErrorOr<StringRef> NameOrErr = Sym->getName(StrTable);
if (std::error_code EC = NameOrErr.getError())
return EC;
S.Name = NameOrErr.get();
More information about the llvm-commits
mailing list