[llvm] r242798 - Replace the last uses of ELF::getSymbolName in llvm-readobj.
Rafael Espindola
rafael.espindola at gmail.com
Tue Jul 21 09:26:21 PDT 2015
Author: rafael
Date: Tue Jul 21 11:26:21 2015
New Revision: 242798
URL: http://llvm.org/viewvc/llvm-project?rev=242798&view=rev
Log:
Replace the last uses of ELF::getSymbolName in llvm-readobj.
Modified:
llvm/trunk/include/llvm/Object/ELF.h
llvm/trunk/tools/llvm-readobj/ARMEHABIPrinter.h
llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
Modified: llvm/trunk/include/llvm/Object/ELF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELF.h?rev=242798&r1=242797&r2=242798&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELF.h (original)
+++ llvm/trunk/include/llvm/Object/ELF.h Tue Jul 21 11:26:21 2015
@@ -237,6 +237,9 @@ public:
const Elf_Shdr *getDotSymtabSec() const { return dot_symtab_sec; }
const Elf_Shdr *getDotDynSymSec() const { return DotDynSymSec; }
const Elf_Hash *getHashTable() const { return HashTable; }
+ StringRef getDynamicStringTable() const {
+ return StringRef((const char *)DynStrRegion.Addr, DynStrRegion.Size);
+ }
ErrorOr<StringRef> getStringTable(const Elf_Shdr *Section) const;
ErrorOr<StringRef> getStringTableForSymtab(const Elf_Shdr &Section) const;
Modified: llvm/trunk/tools/llvm-readobj/ARMEHABIPrinter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ARMEHABIPrinter.h?rev=242798&r1=242797&r2=242798&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/ARMEHABIPrinter.h (original)
+++ llvm/trunk/tools/llvm-readobj/ARMEHABIPrinter.h Tue Jul 21 11:26:21 2015
@@ -344,10 +344,15 @@ template <typename ET>
ErrorOr<StringRef>
PrinterContext<ET>::FunctionAtAddress(unsigned Section,
uint64_t Address) const {
+ const Elf_Shdr *Symtab = ELF->getDotSymtabSec();
+ ErrorOr<StringRef> StrTableOrErr = ELF->getStringTableForSymtab(*Symtab);
+ error(StrTableOrErr.getError());
+ StringRef StrTable = *StrTableOrErr;
+
for (const Elf_Sym &Sym : ELF->symbols())
if (Sym.st_shndx == Section && Sym.st_value == Address &&
Sym.getType() == ELF::STT_FUNC)
- return ELF->getSymbolName(&Sym, false);
+ return Sym.getName(StrTable);
return readobj_error::unknown_symbol;
}
Modified: llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ELFDumper.cpp?rev=242798&r1=242797&r2=242798&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/ELFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/ELFDumper.cpp Tue Jul 21 11:26:21 2015
@@ -695,13 +695,14 @@ template<class ELFT>
void ELFDumper<ELFT>::printDynamicRelocations() {
W.startLine() << "Dynamic Relocations {\n";
W.indent();
+ StringRef StringTable = Obj->getDynamicStringTable();
for (const typename ELFO::Elf_Rela &Rel : Obj->dyn_relas()) {
SmallString<32> RelocName;
Obj->getRelocationTypeName(Rel.getType(Obj->isMips64EL()), RelocName);
StringRef SymbolName;
uint32_t SymIndex = Rel.getSymbol(Obj->isMips64EL());
const typename ELFO::Elf_Sym *Sym = Obj->dynamic_symbol_begin() + SymIndex;
- SymbolName = errorOrDefault(Obj->getSymbolName(Sym, true));
+ SymbolName = errorOrDefault(Sym->getName(StringTable));
if (opts::ExpandRelocs) {
DictScope Group(W, "Relocation");
W.printHex("Offset", Rel.r_offset);
More information about the llvm-commits
mailing list