Skip to content

Commit abe0dd1

Browse files
authored
[llvm-objdump] Print ... even if a data mapping symbol is active
Swap `!DisassembleZeroes` and `if (DumpARMELFData)` conditions so that in the false DisassembleZeroes case (default), `...` will be printed for long consecutive zeroes, even when a data mapping symbol is active. This is especially useful for certain lld tests that insert a huge padding within a code section. Without `...` the output will be huge. Pull Request: #109553
1 parent 3c348bf commit abe0dd1

File tree

5 files changed

+133
-19
lines changed

5 files changed

+133
-19
lines changed

lld/test/ELF/aarch64-undefined-weak.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// REQUIRES: aarch64
22
// RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux %s -o %t.o
33
// RUN: ld.lld --image-base=0x10000000 %t.o -o %t
4-
// RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s
4+
// RUN: llvm-objdump -d -z --no-show-raw-insn %t | FileCheck %s
55

66
// Check that the ARM 64-bit ABI rules for undefined weak symbols are applied.
77
// Branch instructions are resolved to the next instruction. Undefined

llvm/test/MC/ARM/ltorg-range.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@ RUN: llvm-mc -triple armv7-unknown-linux-gnueabi -filetype obj -o - %s \
2-
@ RUN: | llvm-objdump -d - | FileCheck %s
2+
@ RUN: | llvm-objdump -d -z - | FileCheck %s
33

44
ldr r0, =0x01020304
55
@ CHECK: ldr
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
## Test zero dumping when a data mapping symbol is active.
2+
# RUN: llvm-mc -filetype=obj -triple=aarch64 %s -o %t
3+
# RUN: llvm-objdump -t -d %t | FileCheck %s
4+
5+
# CHECK: SYMBOL TABLE:
6+
# CHECK-NEXT: 0000000000000000 l .text 0000000000000000 $d
7+
# CHECK-NEXT: 000000000000000c l .text 0000000000000000 $x
8+
# CHECK-NEXT: 0000000000000010 l .text 0000000000000000 $d
9+
10+
# CHECK: 0000000000000000 <_start>:
11+
# CHECK-NEXT: ...
12+
# CHECK-NEXT: 8: 01 00 00 00 .word 0x00000001
13+
# CHECK-NEXT: c: d503201f nop
14+
# CHECK-NEXT: ...
15+
# CHECK-NEXT: 18: d503201f nop
16+
# CHECK-NEXT: ...
17+
# CHECK-NEXT: 2c: d503201f nop
18+
# CHECK-NEXT: ...
19+
# CHECK-NEXT: 48: d503201f nop
20+
21+
# RUN: llvm-objdump -d -z %t | FileCheck %s --check-prefix=ZERO
22+
23+
# ZERO: 0000000000000000 <_start>:
24+
# ZERO-NEXT: 0: 00 00 00 00 .word 0x00000000
25+
# ZERO-NEXT: 4: 00 00 00 00 .word 0x00000000
26+
# ZERO-NEXT: 8: 01 00 00 00 .word 0x00000001
27+
# ZERO-NEXT: c: d503201f nop
28+
# ZERO-NEXT: 10: 00 00 00 00 .word 0x00000000
29+
# ZERO-NEXT: 14: 00 00 00 00 .word 0x00000000
30+
# ZERO-NEXT: 18: d503201f nop
31+
32+
## Check we do not skip zeroes blocks if have relocations pointed to these places.
33+
# RUN: llvm-objdump -d -r %t | FileCheck %s --check-prefix=RELOC
34+
35+
# RELOC: 0000000000000000 <_start>:
36+
# RELOC-NEXT: ...
37+
# RELOC-NEXT: 8: 01 00 00 00 .word 0x00000001
38+
# RELOC-NEXT: c: d503201f nop
39+
# RELOC-NEXT: ...
40+
# RELOC-NEXT: 18: d503201f nop
41+
# RELOC-NEXT: 1c: 00 00 00 00 .word 0x00000000
42+
# RELOC-NEXT: 000000000000001c: R_AARCH64_ABS64 x1
43+
# RELOC-NEXT: ...
44+
# RELOC-NEXT: 2c: d503201f nop
45+
# RELOC-NEXT: ...
46+
# RELOC-NEXT: 38: 00 00 00 00 .word 0x00000000
47+
# RELOC-NEXT: 0000000000000038: R_AARCH64_ABS64 x2
48+
# RELOC-NEXT: ...
49+
# RELOC-NEXT: 48: d503201f nop
50+
51+
.globl _start
52+
_start:
53+
.space 8
54+
.long 1
55+
nop
56+
.space 8
57+
nop
58+
59+
.quad x1
60+
.space 8
61+
nop
62+
63+
.space 8
64+
.quad x2
65+
.space 8
66+
nop
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
## Test zero dumping when a data mapping symbol is active.
2+
# RUN: llvm-mc -filetype=obj -triple=armv7 %s -o %t
3+
# RUN: llvm-objdump -t -d %t | FileCheck %s
4+
5+
# CHECK: SYMBOL TABLE:
6+
# CHECK-NEXT: 00000000 l .text 00000000 $d
7+
# CHECK-NEXT: 0000000c l .text 00000000 $a
8+
# CHECK-NEXT: 00000010 l .text 00000000 $d
9+
10+
# CHECK: 00000000 <_start>:
11+
# CHECK-NEXT: ...
12+
# CHECK-NEXT: 8: 01 00 00 00 .word 0x00000001
13+
# CHECK-NEXT: c: e320f000 <unknown>
14+
# CHECK-NEXT: ...
15+
# CHECK-NEXT: 18: e320f000 <unknown>
16+
# CHECK-NEXT: ...
17+
# CHECK-NEXT: 28: e320f000 <unknown>
18+
# CHECK-NEXT: ...
19+
# CHECK-NEXT: 40: e320f000 <unknown>
20+
21+
# RUN: llvm-objdump -d -z --triple=armv7 %t | FileCheck %s --check-prefix=ZERO
22+
23+
# ZERO: 00000000 <_start>:
24+
# ZERO-NEXT: 0: 00 00 00 00 .word 0x00000000
25+
# ZERO-NEXT: 4: 00 00 00 00 .word 0x00000000
26+
# ZERO-NEXT: 8: 01 00 00 00 .word 0x00000001
27+
# ZERO-NEXT: c: e320f000 nop
28+
# ZERO-NEXT: 10: 00 00 00 00 .word 0x00000000
29+
# ZERO-NEXT: 14: 00 00 00 00 .word 0x00000000
30+
# ZERO-NEXT: 18: e320f000 nop
31+
32+
.globl _start
33+
_start:
34+
.space 8
35+
.long 1
36+
nop
37+
.space 8
38+
nop
39+
40+
.long x1
41+
.space 8
42+
nop
43+
44+
.space 8
45+
.long x2
46+
.space 8
47+
nop

llvm/tools/llvm-objdump/llvm-objdump.cpp

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2244,27 +2244,28 @@ disassembleObject(ObjectFile &Obj, const ObjectFile &DbgObj,
22442244
return false;
22452245
};
22462246

2247+
// When -z or --disassemble-zeroes are given we always dissasemble
2248+
// them. Otherwise we might want to skip zero bytes we see.
2249+
if (!DisassembleZeroes) {
2250+
uint64_t MaxOffset = End - Index;
2251+
// For --reloc: print zero blocks patched by relocations, so that
2252+
// relocations can be shown in the dump.
2253+
if (InlineRelocs && RelCur != RelEnd)
2254+
MaxOffset = std::min(RelCur->getOffset() - RelAdjustment - Index,
2255+
MaxOffset);
2256+
2257+
if (size_t N =
2258+
countSkippableZeroBytes(Bytes.slice(Index, MaxOffset))) {
2259+
FOS << "\t\t..." << '\n';
2260+
Index += N;
2261+
continue;
2262+
}
2263+
}
2264+
22472265
if (DumpARMELFData) {
22482266
Size = dumpARMELFData(SectionAddr, Index, End, Obj, Bytes,
22492267
MappingSymbols, *DT->SubtargetInfo, FOS);
22502268
} else {
2251-
// When -z or --disassemble-zeroes are given we always dissasemble
2252-
// them. Otherwise we might want to skip zero bytes we see.
2253-
if (!DisassembleZeroes) {
2254-
uint64_t MaxOffset = End - Index;
2255-
// For --reloc: print zero blocks patched by relocations, so that
2256-
// relocations can be shown in the dump.
2257-
if (InlineRelocs && RelCur != RelEnd)
2258-
MaxOffset = std::min(RelCur->getOffset() - RelAdjustment - Index,
2259-
MaxOffset);
2260-
2261-
if (size_t N =
2262-
countSkippableZeroBytes(Bytes.slice(Index, MaxOffset))) {
2263-
FOS << "\t\t..." << '\n';
2264-
Index += N;
2265-
continue;
2266-
}
2267-
}
22682269

22692270
if (DumpTracebackTableForXCOFFFunction &&
22702271
doesXCOFFTracebackTableBegin(Bytes.slice(Index, 4))) {

0 commit comments

Comments
 (0)