[PATCH] llvm-objdump should produce hex addresses for relocations
Ted Woodward
ted.woodward at codeaurora.org
Thu Mar 20 14:54:01 PDT 2014
Change format strings from const char * to StringRef.
Hi garious,
http://llvm-reviews.chandlerc.com/D3072
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D3072?vs=7893&id=8000#toc
Files:
test/MC/ARM/elf-jump24-fixup.s
test/MC/ARM/symbol-variants.s
test/tools/llvm-objdump/hex-relocation-addr.test
tools/llvm-objdump/llvm-objdump.cpp
Index: test/MC/ARM/elf-jump24-fixup.s
===================================================================
--- test/MC/ARM/elf-jump24-fixup.s
+++ test/MC/ARM/elf-jump24-fixup.s
@@ -6,4 +6,4 @@
foo:
b.w bar
-@ CHECK: {{[0-9]+}} R_ARM_THM_JUMP24 bar
+@ CHECK: {{[0-9a-f]+}} R_ARM_THM_JUMP24 bar
Index: test/MC/ARM/symbol-variants.s
===================================================================
--- test/MC/ARM/symbol-variants.s
+++ test/MC/ARM/symbol-variants.s
@@ -13,73 +13,73 @@
.word f02(NONE)
.word f03(none)
@CHECK: 8 R_ARM_NONE f02
- at CHECK: 12 R_ARM_NONE f03
+ at CHECK: c R_ARM_NONE f03
@ plt
bl f04(PLT)
bl f05(plt)
- at ARM: 16 R_ARM_PLT32 f04
- at ARM: 20 R_ARM_PLT32 f05
- at THUMB: 16 R_ARM_THM_CALL f04
- at THUMB: 20 R_ARM_THM_CALL f05
+ at ARM: 10 R_ARM_PLT32 f04
+ at ARM: 14 R_ARM_PLT32 f05
+ at THUMB: 10 R_ARM_THM_CALL f04
+ at THUMB: 14 R_ARM_THM_CALL f05
@ got
.word f06(GOT)
.word f07(got)
- at CHECK: 24 R_ARM_GOT_BREL f06
- at CHECK: 28 R_ARM_GOT_BREL f07
+ at CHECK: 18 R_ARM_GOT_BREL f06
+ at CHECK: 1c R_ARM_GOT_BREL f07
@ gotoff
.word f08(GOTOFF)
.word f09(gotoff)
- at CHECK: 32 R_ARM_GOTOFF32 f08
- at CHECK: 36 R_ARM_GOTOFF32 f09
+ at CHECK: 20 R_ARM_GOTOFF32 f08
+ at CHECK: 24 R_ARM_GOTOFF32 f09
@ tpoff
.word f10(TPOFF)
.word f11(tpoff)
- at CHECK: 40 R_ARM_TLS_LE32 f10
- at CHECK: 44 R_ARM_TLS_LE32 f11
+ at CHECK: 28 R_ARM_TLS_LE32 f10
+ at CHECK: 2c R_ARM_TLS_LE32 f11
@ tlsgd
.word f12(TLSGD)
.word f13(tlsgd)
- at CHECK: 48 R_ARM_TLS_GD32 f12
- at CHECK: 52 R_ARM_TLS_GD32 f13
+ at CHECK: 30 R_ARM_TLS_GD32 f12
+ at CHECK: 34 R_ARM_TLS_GD32 f13
@ target1
.word f14(TARGET1)
.word f15(target1)
- at CHECK: 56 R_ARM_TARGET1 f14
- at CHECK: 60 R_ARM_TARGET1 f15
+ at CHECK: 38 R_ARM_TARGET1 f14
+ at CHECK: 3c R_ARM_TARGET1 f15
@ target2
.word f16(TARGET2)
.word f17(target2)
- at CHECK: 64 R_ARM_TARGET2 f16
- at CHECK: 68 R_ARM_TARGET2 f17
+ at CHECK: 40 R_ARM_TARGET2 f16
+ at CHECK: 44 R_ARM_TARGET2 f17
@ prel31
.word f18(PREL31)
.word f19(prel31)
- at CHECK: 72 R_ARM_PREL31 f18
- at CHECK: 76 R_ARM_PREL31 f19
+ at CHECK: 48 R_ARM_PREL31 f18
+ at CHECK: 4c R_ARM_PREL31 f19
@ tlsldo
.word f20(TLSLDO)
.word f21(tlsldo)
- at CHECK: 80 R_ARM_TLS_LDO32 f20
- at CHECK: 84 R_ARM_TLS_LDO32 f21
+ at CHECK: 50 R_ARM_TLS_LDO32 f20
+ at CHECK: 54 R_ARM_TLS_LDO32 f21
@ tlscall
.word f22(TLSCALL)
.word f23(tlscall)
-@ CHECK: 88 R_ARM_TLS_CALL f22
-@ CHECK: 92 R_ARM_TLS_CALL f23
+@ CHECK: 58 R_ARM_TLS_CALL f22
+@ CHECK: 5c R_ARM_TLS_CALL f23
@ tlsdesc
.word f24(TLSDESC)
.word f25(tlsdesc)
-@ CHECK: 96 R_ARM_TLS_GOTDESC f24
-@ CHECK: 100 R_ARM_TLS_GOTDESC f25
+@ CHECK: 60 R_ARM_TLS_GOTDESC f24
+@ CHECK: 64 R_ARM_TLS_GOTDESC f25
Index: test/tools/llvm-objdump/hex-relocation-addr.test
===================================================================
--- /dev/null
+++ test/tools/llvm-objdump/hex-relocation-addr.test
@@ -0,0 +1,17 @@
+// This test checks that relocation addresses are printed in hex
+// RUN: llvm-objdump -r %p/Inputs/win64-unwind.exe.coff-x86_64.obj | FileCheck %s
+
+CHECK: RELOCATION RECORDS FOR [.pdata]:
+CHECK-NEXT: 0 IMAGE_REL_AMD64_ADDR32NB func
+CHECK-NEXT: 4 IMAGE_REL_AMD64_ADDR32NB func
+CHECK-NEXT: 8 IMAGE_REL_AMD64_ADDR32NB .xdata
+CHECK-NEXT: c IMAGE_REL_AMD64_ADDR32NB func
+CHECK-NEXT: 10 IMAGE_REL_AMD64_ADDR32NB func
+CHECK-NEXT: 14 IMAGE_REL_AMD64_ADDR32NB .xdata
+CHECK-NEXT: 18 IMAGE_REL_AMD64_ADDR32NB smallFunc
+CHECK-NEXT: 1c IMAGE_REL_AMD64_ADDR32NB smallFunc
+CHECK-NEXT: 20 IMAGE_REL_AMD64_ADDR32NB .xdata
+CHECK-NEXT: 24 IMAGE_REL_AMD64_ADDR32NB allocFunc
+CHECK-NEXT: 28 IMAGE_REL_AMD64_ADDR32NB allocFunc
+CHECK-NEXT: 2c IMAGE_REL_AMD64_ADDR32NB .xdata
+
Index: tools/llvm-objdump/llvm-objdump.cpp
===================================================================
--- tools/llvm-objdump/llvm-objdump.cpp
+++ tools/llvm-objdump/llvm-objdump.cpp
@@ -382,6 +382,9 @@
}
}
+ StringRef Fmt = Obj->getBytesInAddress() > 4 ? "\t\t%016" PRIx64 ": " :
+ "\t\t\t%08" PRIx64 ": ";
+
// Create a mapping, RelocSecs = SectionRelocMap[S], where sections
// in RelocSecs contain the relocations for section S.
error_code EC;
@@ -536,7 +539,7 @@
if (error(rel_cur->getTypeName(name))) goto skip_print_rel;
if (error(rel_cur->getValueString(val))) goto skip_print_rel;
- outs() << format("\t\t\t%8" PRIx64 ": ", SectionAddr + addr) << name
+ outs() << format(Fmt.data(), SectionAddr + addr) << name
<< "\t" << val << "\n";
skip_print_rel:
@@ -548,6 +551,8 @@
}
static void PrintRelocations(const ObjectFile *Obj) {
+ StringRef Fmt = Obj->getBytesInAddress() > 4 ? "%016" PRIx64 :
+ "%08" PRIx64;
for (const SectionRef &Section : Obj->sections()) {
if (Section.relocation_begin() == Section.relocation_end())
continue;
@@ -570,7 +575,8 @@
continue;
if (error(Reloc.getValueString(valuestr)))
continue;
- outs() << address << " " << relocname << " " << valuestr << "\n";
+ outs() << format(Fmt.data(), address) << " " << relocname << " "
+ << valuestr << "\n";
}
outs() << "\n";
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3072.4.patch
Type: text/x-patch
Size: 5169 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140320/9a9ed770/attachment.bin>
More information about the llvm-commits
mailing list