mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 12:50:30 +00:00
Support printing relocations in files with no section table.
llvm-svn: 242998
This commit is contained in:
parent
61c30ffea6
commit
6ee9519072
BIN
test/Object/Inputs/rel-no-sec-table.elf-x86-64
Executable file
BIN
test/Object/Inputs/rel-no-sec-table.elf-x86-64
Executable file
Binary file not shown.
@ -35,3 +35,15 @@ RUN: %p/Inputs/hello-world.elf-x86-64 | FileCheck %s --check-prefix=DYN
|
||||
// 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: }
|
||||
|
@ -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<ELFT> *Obj, StreamWriter &Writer)
|
||||
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>::printDynamicRelocations() {
|
||||
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>::printDynamicSymbols() {
|
||||
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<ELFT>::parseGOT() {
|
||||
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user