mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 12:43:36 +01:00
[readobj] Dump DT_JMPREL relocations when outputting dynamic relocations.
llvm-svn: 260489
This commit is contained in:
parent
4b64c43150
commit
e7d9c3a84d
@ -34,6 +34,18 @@ RUN: %p/Inputs/hello-world.elf-x86-64 | FileCheck %s --check-prefix=DYN
|
||||
// DYN-NEXT: Symbol: __gmon_start__
|
||||
// DYN-NEXT: Addend: 0x0
|
||||
// DYN-NEXT: }
|
||||
// DYN-NEXT: Relocation {
|
||||
// DYN-NEXT: Offset: 0x4018F8
|
||||
// DYN-NEXT: Type: R_X86_64_JUMP_SLOT (7)
|
||||
// DYN-NEXT: Symbol: __libc_start_main
|
||||
// DYN-NEXT: Addend: 0x0
|
||||
// DYN-NEXT: }
|
||||
// DYN-NEXT: Relocation {
|
||||
// DYN-NEXT: Offset: 0x401900
|
||||
// DYN-NEXT: Type: R_X86_64_JUMP_SLOT (7)
|
||||
// DYN-NEXT: Symbol: puts
|
||||
// DYN-NEXT: Addend: 0x0
|
||||
// DYN-NEXT: }
|
||||
// DYN-NEXT: }
|
||||
|
||||
RUN: llvm-readobj -dyn-relocations -expand-relocs \
|
||||
|
@ -1,6 +1,6 @@
|
||||
RUN: llvm-readobj -dyn-symbols -dynamic-table \
|
||||
RUN: llvm-readobj -dyn-symbols -dynamic-table -dyn-relocations \
|
||||
RUN: %S/Inputs/dynamic-table-exe-no-shdrs.x86 | FileCheck %s
|
||||
RUN: llvm-readobj -dyn-symbols -dynamic-table \
|
||||
RUN: llvm-readobj -dyn-symbols -dynamic-table -relocations \
|
||||
RUN: %S/Inputs/dynamic-table-exe-no-phdrs.x86 | FileCheck %s
|
||||
|
||||
CHECK: File:
|
||||
@ -8,7 +8,32 @@ CHECK-NEXT: Format: ELF32-i386
|
||||
CHECK-NEXT: Arch: i386
|
||||
CHECK-NEXT: AddressSize: 32bit
|
||||
CHECK-NEXT: LoadName:
|
||||
CHECK-NEXT: DynamicSymbols [
|
||||
CHECK: 0x85F R_386_RELATIVE - 0x0
|
||||
CHECK-NEXT: 0x874 R_386_RELATIVE - 0x0
|
||||
CHECK-NEXT: 0x19FC R_386_RELATIVE - 0x0
|
||||
CHECK-NEXT: 0x1A00 R_386_RELATIVE - 0x0
|
||||
CHECK-NEXT: 0x1B2C R_386_RELATIVE - 0x0
|
||||
CHECK-NEXT: 0x1B60 R_386_RELATIVE - 0x0
|
||||
CHECK-NEXT: 0x0 R_386_NONE - 0x0
|
||||
CHECK-NEXT: 0x864 R_386_PC32 puts 0x0
|
||||
CHECK-NEXT: 0x880 R_386_PC32 _ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode 0x0
|
||||
CHECK-NEXT: 0x88C R_386_PC32 _ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev 0x0
|
||||
CHECK-NEXT: 0x89B R_386_PC32 _Unwind_Resume 0x0
|
||||
CHECK-NEXT: 0x9BB R_386_32 __gxx_personality_v0 0x0
|
||||
CHECK-NEXT: 0x1B18 R_386_GLOB_DAT __gmon_start__ 0x0
|
||||
CHECK-NEXT: 0x1B1C R_386_GLOB_DAT _Jv_RegisterClasses 0x0
|
||||
CHECK-NEXT: 0x1B20 R_386_GLOB_DAT _ITM_deregisterTMCloneTable 0x0
|
||||
CHECK-NEXT: 0x1B24 R_386_GLOB_DAT _ITM_registerTMCloneTable 0x0
|
||||
CHECK-NEXT: 0x1B28 R_386_GLOB_DAT __cxa_finalize 0x0
|
||||
CHECK: 0x1B3C R_386_JUMP_SLOT __gmon_start__ 0x0
|
||||
CHECK-NEXT: 0x1B40 R_386_JUMP_SLOT __libc_start_main 0x0
|
||||
CHECK-NEXT: 0x1B44 R_386_JUMP_SLOT _ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev 0x0
|
||||
CHECK-NEXT: 0x1B48 R_386_JUMP_SLOT _ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode 0x0
|
||||
CHECK-NEXT: 0x1B4C R_386_JUMP_SLOT puts 0x0
|
||||
CHECK-NEXT: 0x1B50 R_386_JUMP_SLOT __gxx_personality_v0 0x0
|
||||
CHECK-NEXT: 0x1B54 R_386_JUMP_SLOT _Unwind_Resume 0x0
|
||||
CHECK-NEXT: 0x1B58 R_386_JUMP_SLOT __cxa_finalize 0x0
|
||||
CHECK: DynamicSymbols [
|
||||
CHECK-NEXT: Symbol {
|
||||
CHECK-NEXT: Name: @
|
||||
CHECK-NEXT: Value: 0x0
|
||||
|
@ -165,6 +165,7 @@ private:
|
||||
// Dynamic relocation info.
|
||||
DynRegionInfo DynRelRegion;
|
||||
DynRegionInfo DynRelaRegion;
|
||||
DynRegionInfo DynPLTRelRegion;
|
||||
|
||||
DynRegionInfo DynSymRegion;
|
||||
StringRef DynamicStringTable;
|
||||
@ -1126,6 +1127,21 @@ void ELFDumper<ELFT>::parseDynamicTable(
|
||||
case ELF::DT_RELENT:
|
||||
DynRelRegion.EntSize = Dyn.getVal();
|
||||
break;
|
||||
case ELF::DT_PLTREL:
|
||||
if (Dyn.getVal() == DT_REL)
|
||||
DynPLTRelRegion.EntSize = sizeof(Elf_Rel);
|
||||
else if (Dyn.getVal() == DT_RELA)
|
||||
DynPLTRelRegion.EntSize = sizeof(Elf_Rela);
|
||||
else
|
||||
reportError(Twine("unknown DT_PLTREL value of ") +
|
||||
Twine((uint64_t)Dyn.getVal()));
|
||||
break;
|
||||
case ELF::DT_JMPREL:
|
||||
DynPLTRelRegion.Addr = toMappedAddr(Dyn.getPtr());
|
||||
break;
|
||||
case ELF::DT_PLTRELSZ:
|
||||
DynPLTRelRegion.Size = Dyn.getVal();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (StringTableBegin)
|
||||
@ -1155,6 +1171,7 @@ void ELFDumper<ELFT>::parseDynamicTable(
|
||||
CheckDRI(DynamicTable);
|
||||
CheckDRI(DynRelRegion);
|
||||
CheckDRI(DynRelaRegion);
|
||||
CheckDRI(DynPLTRelRegion);
|
||||
|
||||
if (DynamicStringTable.data() >= Start && DynamicStringTable.data() < End)
|
||||
End = DynamicStringTable.data();
|
||||
@ -1310,6 +1327,17 @@ template <class ELFT> void ELFDumper<ELFT>::printDynamicRelocations() {
|
||||
Rela.r_addend = 0;
|
||||
printDynamicRelocation(Rela);
|
||||
}
|
||||
if (DynPLTRelRegion.EntSize == sizeof(Elf_Rela))
|
||||
for (const Elf_Rela &Rela : DynPLTRelRegion.getAsRange<Elf_Rela>())
|
||||
printDynamicRelocation(Rela);
|
||||
else
|
||||
for (const Elf_Rel &Rel : DynPLTRelRegion.getAsRange<Elf_Rel>()) {
|
||||
Elf_Rela Rela;
|
||||
Rela.r_offset = Rel.r_offset;
|
||||
Rela.r_info = Rel.r_info;
|
||||
Rela.r_addend = 0;
|
||||
printDynamicRelocation(Rela);
|
||||
}
|
||||
W.unindent();
|
||||
W.startLine() << "}\n";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user