llvm.org GIT mirror llvm / 400438c
[llvm-objdump] Use %08 instead of %016 to print leading addresses for 32-bit binaries Reviewed By: grimar Differential Revision: https://reviews.llvm.org/D63398 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@363539 91177308-0d34-0410-b5e6-96231b3b80d8 Fangrui Song a month ago
5 changed file(s) with 30 addition(s) and 26 deletion(s). Raw diff Collapse all Expand all
55 # section afterwards. We had negative label difference assertions when .cv_loc
66 # bound tightly to the next instruction.
77
8 # ASM: 0000000000000000 _callit:
8 # ASM: 00000000 _callit:
99 # begin inline {
1010 # ASM-NEXT: 0: e8 00 00 00 00 calll 0 <_callit+0x5>
1111 # ASM-NEXT: 5: 85 c0 testl %eax, %eax
1616 # }
1717
1818
19 # ASM: 0000000000000000 _callit:
19 # ASM: 00000000 _callit:
2020 # begin inline {
2121 # ASM-NEXT: 0: e8 00 00 00 00 calll 0 <_callit+0x5>
2222 # ASM-NEXT: 5: 85 c0 testl %eax, %eax
66 # RUN: llvm-mc -triple=powerpc-unknown-linux -filetype=obj %s -o %t.o
77 # RUN: llvm-objdump -d %t.o | FileCheck %s
88
9 # CHECK: 0000000000000000 callee_back:
9 # CHECK: {{0*}}00000000 callee_back:
1010 # CHECK: 18: {{.*}} bl .-24
1111 # CHECK: 20: {{.*}} bl .+16
12 # CHECK: 0000000000000030 callee_forward:
12 # CHECK: {{0*}}00000030 callee_forward:
1313
1414 .text
1515 .global caller
None // RUN: llvm-mc %s -filetype=obj -triple=x86_64-pc-linux -o %t.o
0 # RUN: llvm-mc %s -filetype=obj -triple=i386 -o %t.32.o
1 # RUN: llvm-mc %s -filetype=obj -triple=x86_64 -o %t.64.o
12
2 // Check we print the address of `foo` and `bar`.
3 // RUN: llvm-objdump -d %t.o | FileCheck %s
4 // CHECK: 0000000000000000 foo:
5 // CHECK-NEXT: 0: {{.*}} nop
6 // CHECK-NEXT: 1: {{.*}} nop
7 // CHECK: 0000000000000002 bar:
8 // CHECK-NEXT: 2: {{.*}} nop
3 ## Check we print the address of `foo` and `bar`.
4 # RUN: llvm-objdump -d %t.32.o | FileCheck --check-prefixes=ADDR32,ADDR %s
5 # RUN: llvm-objdump -d %t.64.o | FileCheck --check-prefixes=ADDR64,ADDR %s
6 # ADDR32: 00000000 foo:
7 # ADDR64: 0000000000000000 foo:
8 # ADDR-NEXT: 0: {{.*}} nop
9 # ADDR-NEXT: 1: {{.*}} nop
10 # ADDR32: 00000002 bar:
11 # ADDR64: 0000000000000002 bar:
12 # ADDR-NEXT: 2: {{.*}} nop
913
10 // Check we do not print the addresses with -no-leading-addr.
11 // RUN: llvm-objdump -d --no-leading-addr %t.o | FileCheck %s --check-prefix=NOADDR
12 // NOADDR: {{^}}foo:
13 // NOADDR-NEXT: {{.*}} nop
14 // NOADDR-NEXT: {{.*}} nop
15 // NOADDR: {{^}}bar:
16 // NOADDR-NEXT: {{.*}} nop
14 ## Check we do not print the addresses with --no-leading-addr.
15 # RUN: llvm-objdump -d --no-leading-addr %t.32.o | FileCheck %s --check-prefix=NOADDR
16 # RUN: llvm-objdump -d --no-leading-addr %t.64.o | FileCheck %s --check-prefix=NOADDR
17 # NOADDR: {{^}}foo:
18 # NOADDR-NEXT: {{.*}} nop
19 # NOADDR-NEXT: {{.*}} nop
20 # NOADDR: {{^}}bar:
21 # NOADDR-NEXT: {{.*}} nop
1722
1823 .text
1924 .globl foo
611611 }
612612
613613 static void printRelocation(const RelocationRef &Rel, uint64_t Address,
614 uint8_t AddrSize) {
615 StringRef Fmt =
616 AddrSize > 4 ? "\t\t%016" PRIx64 ": " : "\t\t\t%08" PRIx64 ": ";
614 bool Is64Bits) {
615 StringRef Fmt = Is64Bits ? "\t\t%016" PRIx64 ": " : "\t\t\t%08" PRIx64 ": ";
617616 SmallString<16> Name;
618617 SmallString<32> Val;
619618 Rel.getTypeName(Name);
703702 auto PrintReloc = [&]() -> void {
704703 while ((RelCur != RelEnd) && (RelCur->getOffset() <= Address.Address)) {
705704 if (RelCur->getOffset() == Address.Address) {
706 printRelocation(*RelCur, Address.Address, 4);
705 printRelocation(*RelCur, Address.Address, false);
707706 return;
708707 }
709708 ++RelCur;
10311030 std::map> RelocMap;
10321031 if (InlineRelocs)
10331032 RelocMap = getRelocsMap(*Obj);
1033 bool Is64Bits = Obj->getBytesInAddress() > 4;
10341034
10351035 // Create a mapping from virtual address to symbol name. This is used to
10361036 // pretty print the symbols while disassembling.
12281228
12291229 outs() << '\n';
12301230 if (!NoLeadingAddr)
1231 outs() << format("%016" PRIx64 " ",
1231 outs() << format(Is64Bits ? "%016" PRIx64 " " : "%08" PRIx64 " ",
12321232 SectionAddr + Start + VMAAdjustment);
12331233
12341234 StringRef SymbolName = std::get<1>(Symbols[SI]);
14001400 Offset += AdjustVMA;
14011401 }
14021402
1403 printRelocation(*RelCur, SectionAddr + Offset,
1404 Obj->getBytesInAddress());
1403 printRelocation(*RelCur, SectionAddr + Offset, Is64Bits);
14051404 ++RelCur;
14061405 }
14071406 }