[llvm] r242998 - Support printing relocations in files with no section table.
Rafael Espindola
rafael.espindola at gmail.com
Thu Jul 23 02:11:05 PDT 2015
Author: rafael
Date: Thu Jul 23 04:11:05 2015
New Revision: 242998
URL: http://llvm.org/viewvc/llvm-project?rev=242998&view=rev
Log:
Support printing relocations in files with no section table.
Added:
llvm/trunk/test/Object/Inputs/rel-no-sec-table.elf-x86-64 (with props)
Modified:
llvm/trunk/test/Object/relocation-executable.test
llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
Added: llvm/trunk/test/Object/Inputs/rel-no-sec-table.elf-x86-64
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/Inputs/rel-no-sec-table.elf-x86-64?rev=242998&view=auto
==============================================================================
Binary files llvm/trunk/test/Object/Inputs/rel-no-sec-table.elf-x86-64 (added) and llvm/trunk/test/Object/Inputs/rel-no-sec-table.elf-x86-64 Thu Jul 23 04:11:05 2015 differ
Propchange: llvm/trunk/test/Object/Inputs/rel-no-sec-table.elf-x86-64
------------------------------------------------------------------------------
svn:executable = *
Modified: llvm/trunk/test/Object/relocation-executable.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/relocation-executable.test?rev=242998&r1=242997&r2=242998&view=diff
==============================================================================
--- llvm/trunk/test/Object/relocation-executable.test (original)
+++ llvm/trunk/test/Object/relocation-executable.test Thu Jul 23 04:11:05 2015
@@ -35,3 +35,15 @@ RUN: %p/Inputs/hello-world.elf-x86-64
// DYN-NEXT: Addend: 0x0
// DYN-NEXT: }
// DYN-NEXT: }
+
+RUN: llvm-readobj -dyn-relocations -expand-relocs \
+RUN: %p/Inputs/rel-no-sec-table.elf-x86-64 | FileCheck %s --check-prefix=DYN2
+
+// DYN2: Dynamic Relocations {
+// DYN2-NEXT: Relocation {
+// DYN2-NEXT: Offset: 0x12F0
+// DYN2-NEXT: Type: R_X86_64_GLOB_DAT (6)
+// DYN2-NEXT: Symbol: g
+// DYN2-NEXT: Addend: 0x0
+// DYN2-NEXT: }
+// DYN2-NEXT: }
Modified: llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ELFDumper.cpp?rev=242998&r1=242997&r2=242998&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/ELFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/ELFDumper.cpp Thu Jul 23 04:11:05 2015
@@ -110,6 +110,7 @@ private:
DynRegionInfo DynRelaRegion;
DynRegionInfo DynamicRegion;
StringRef DynamicStringTable;
+ const Elf_Sym *DynSymStart = nullptr;
StringRef SOName;
const Elf_Hash *HashTable = nullptr;
};
@@ -660,6 +661,10 @@ ELFDumper<ELFT>::ELFDumper(const ELFFile
case ELF::DT_STRSZ:
StringTableSize = Dyn.getVal();
break;
+ case ELF::DT_SYMTAB:
+ DynSymStart =
+ reinterpret_cast<const Elf_Sym *>(toMappedAddr(Dyn.getPtr()));
+ break;
}
}
if (StringTableBegin)
@@ -837,7 +842,7 @@ void ELFDumper<ELFT>::printDynamicReloca
Obj->getRelocationTypeName(Rel.getType(Obj->isMips64EL()), RelocName);
StringRef SymbolName;
uint32_t SymIndex = Rel.getSymbol(Obj->isMips64EL());
- const Elf_Sym *Sym = Obj->dynamic_symbol_begin() + SymIndex;
+ const Elf_Sym *Sym = DynSymStart + SymIndex;
SymbolName = errorOrDefault(Sym->getName(DynamicStringTable));
if (opts::ExpandRelocs) {
DictScope Group(W, "Relocation");
@@ -931,7 +936,7 @@ void ELFDumper<ELFT>::printDynamicSymbol
ErrorOr<StringRef> StrTableOrErr = Obj->getStringTableForSymtab(*Symtab);
error(StrTableOrErr.getError());
StringRef StrTable = *StrTableOrErr;
- for (const Elf_Sym &Sym : Obj->dynamic_symbols())
+ for (const Elf_Sym &Sym : Obj->symbols(Symtab))
printSymbol(&Sym, StrTable, true);
}
@@ -1431,8 +1436,8 @@ template <class ELFT> void MipsGOTParser
const Elf_Shdr *DynSymSec = Obj->getDotDynSymSec();
ErrorOr<StringRef> StrTable = Obj->getStringTableForSymtab(*DynSymSec);
error(StrTable.getError());
- const Elf_Sym *DynSymBegin = Obj->dynamic_symbol_begin();
- const Elf_Sym *DynSymEnd = Obj->dynamic_symbol_end();
+ const Elf_Sym *DynSymBegin = Obj->symbol_begin(DynSymSec);
+ const Elf_Sym *DynSymEnd = Obj->symbol_end(DynSymSec);
std::size_t DynSymTotal = std::size_t(std::distance(DynSymBegin, DynSymEnd));
if (*DtGotSym > DynSymTotal) {
More information about the llvm-commits
mailing list