[llvm] r260970 - Reapply r260489.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 16 07:16:00 PST 2016
Author: rafael
Date: Tue Feb 16 09:16:00 2016
New Revision: 260970
URL: http://llvm.org/viewvc/llvm-project?rev=260970&view=rev
Log:
Reapply r260489.
Original commit message:
[readobj] Dump DT_JMPREL relocations when outputting dynamic relocations.
The bits of r260488 it depends on have been committed.
Modified:
llvm/trunk/test/Object/relocation-executable.test
llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
Modified: llvm/trunk/test/Object/relocation-executable.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/relocation-executable.test?rev=260970&r1=260969&r2=260970&view=diff
==============================================================================
--- llvm/trunk/test/Object/relocation-executable.test (original)
+++ llvm/trunk/test/Object/relocation-executable.test Tue Feb 16 09:16:00 2016
@@ -34,6 +34,18 @@ RUN: %p/Inputs/hello-world.elf-x86-64
// 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 \
Modified: llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ELFDumper.cpp?rev=260970&r1=260969&r2=260970&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/ELFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/ELFDumper.cpp Tue Feb 16 09:16:00 2016
@@ -60,6 +60,8 @@ struct DynRegionInfo {
template <typename Type> iterator_range<const Type *> getAsRange() const {
const Type *Start = reinterpret_cast<const Type *>(Addr);
+ if (!Start)
+ return {Start, Start};
if (EntSize != sizeof(Type) || Size % EntSize)
reportError("Invalid entity size");
return {Start, Start + (Size / EntSize)};
@@ -152,6 +154,7 @@ private:
const ELFO *Obj;
DynRegionInfo DynRelRegion;
DynRegionInfo DynRelaRegion;
+ DynRegionInfo DynPLTRelRegion;
const Elf_Phdr *DynamicProgHeader = nullptr;
StringRef DynamicStringTable;
const Elf_Sym *DynSymStart = nullptr;
@@ -1105,6 +1108,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)
@@ -1243,6 +1261,17 @@ template <class ELFT> void ELFDumper<ELF
Elf_Rela Rela;
Rela.r_offset = Rel.r_offset;
Rela.r_info = Rel.r_info;
+ 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);
}
More information about the llvm-commits
mailing list