Skip to content

Commit 87de9a0

Browse files
committed
[X86InstPrinter] Change printPCRelImm to print the target address in hexadecimal form
``` // llvm-objdump -d output (before) 400000: e8 0b 00 00 00 callq 11 400005: e8 0b 00 00 00 callq 11 // llvm-objdump -d output (after) 400000: e8 0b 00 00 00 callq 0x400010 400005: e8 0b 00 00 00 callq 0x400015 // GNU objdump -d. The lack of 0x is not ideal because the result cannot be re-assembled 400000: e8 0b 00 00 00 callq 400010 400005: e8 0b 00 00 00 callq 400015 ``` In llvm-objdump, we pass the address of the next MCInst. Ideally we should just thread the address of the current address, unfortunately we cannot call X86MCCodeEmitter::encodeInstruction (X86MCCodeEmitter requires MCInstrInfo and MCContext) to get the length of the MCInst. MCInstPrinter::printInst has other callers (e.g llvm-mc -filetype=asm, llvm-mca) which set Address to 0. They leave MCInstPrinter::PrintBranchImmAsAddress as false and this change is a no-op for them. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D76580
1 parent 62dea6e commit 87de9a0

File tree

61 files changed

+262
-242
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+262
-242
lines changed

lld/test/COFF/delayimports32.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ BASEREL-NEXT: }
7272
BASEREL-NEXT: ]
7373

7474
DISASM: 1029: b8 20 30 40 00 movl $4206624, %eax
75-
DISASM-NEXT: 102e: e9 0a 00 00 00 jmp 10 <.text+0x3d>
75+
DISASM-NEXT: 102e: e9 0a 00 00 00 jmp 0x40103d <.text+0x3d>
7676
DISASM-NEXT: 1033: b8 24 30 40 00 movl $4206628, %eax
77-
DISASM-NEXT: 1038: e9 00 00 00 00 jmp 0 <.text+0x3d>
77+
DISASM-NEXT: 1038: e9 00 00 00 00 jmp 0x40103d <.text+0x3d>
7878
DISASM-NEXT: 103d: 51 pushl %ecx
7979
DISASM-NEXT: 103e: 52 pushl %edx
8080
DISASM-NEXT: 103f: 50 pushl %eax
8181
DISASM-NEXT: 1040: 68 00 20 40 00 pushl $4202496
82-
DISASM-NEXT: 1045: e8 b6 ff ff ff calll -74 <.text>
82+
DISASM-NEXT: 1045: e8 b6 ff ff ff calll 0x401000 <.text>
8383
DISASM-NEXT: 104a: 5a popl %edx
8484
DISASM-NEXT: 104b: 59 popl %ecx
8585
DISASM-NEXT: 104c: ff e0 jmpl *%eax

lld/test/COFF/imports.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ TEXT-NEXT: movq $0, %rcx
1919
TEXT-NEXT: leaq 8180(%rip), %rdx
2020
TEXT-NEXT: leaq 8167(%rip), %r8
2121
TEXT-NEXT: movl $0, %r9d
22-
TEXT-NEXT: callq 60
22+
TEXT-NEXT: callq 0x140001060
2323
TEXT-NEXT: movl $0, %ecx
24-
TEXT-NEXT: callq 18
25-
TEXT-NEXT: callq 29
24+
TEXT-NEXT: callq 0x140001040
25+
TEXT-NEXT: callq 0x140001050
2626
TEXT: jmpq *4098(%rip)
2727
TEXT: jmpq *4090(%rip)
2828
TEXT: jmpq *4082(%rip)

lld/test/COFF/lto-comdat.ll

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@
5252
; TEXT-01-EMPTY:
5353
; TEXT-01-NEXT: <.text>:
5454
; TEXT-01-NEXT: subq $40, %rsp
55-
; TEXT-01-NEXT: callq 23
56-
; TEXT-01-NEXT: callq 18
57-
; TEXT-01-NEXT: callq 13
55+
; TEXT-01-NEXT: callq 0x140001020
56+
; TEXT-01-NEXT: callq 0x140001020
57+
; TEXT-01-NEXT: callq 0x140001020
5858
; TEXT-01-NEXT: xorl %eax, %eax
5959
; TEXT-01-NEXT: addq $40, %rsp
6060
; TEXT-01: retq
@@ -70,20 +70,20 @@
7070
; TEXT-10-EMPTY:
7171
; TEXT-10-NEXT: <.text>:
7272
; TEXT-10-NEXT: subq $40, %rsp
73-
; TEXT-10-NEXT: callq 55
73+
; TEXT-10-NEXT: callq 0x140001040
7474
; TEXT-10-NEXT: nop
7575
; TEXT-10-NEXT: addq $40, %rsp
7676
; TEXT-10-NEXT: retq
7777
; TEXT-10-NEXT: int3
7878
; TEXT-10-NEXT: subq $40, %rsp
79-
; TEXT-10-NEXT: callq 39
79+
; TEXT-10-NEXT: callq 0x140001040
8080
; TEXT-10-NEXT: nop
8181
; TEXT-10-NEXT: addq $40, %rsp
8282
; TEXT-10-NEXT: retq
8383
; TEXT-10-NEXT: int3
8484
; TEXT-10-NEXT: subq $40, %rsp
85-
; TEXT-10-NEXT: callq -41
86-
; TEXT-10-NEXT: callq -30
85+
; TEXT-10-NEXT: callq 0x140001000
86+
; TEXT-10-NEXT: callq 0x140001010
8787
; TEXT-10-NEXT: xorl %eax, %eax
8888
; TEXT-10-NEXT: addq $40, %rsp
8989
; TEXT-10-NEXT: retq

lld/test/COFF/lto.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
; TEXT-01-EMPTY:
6060
; TEXT-01-NEXT: <.text>:
6161
; TEXT-01-NEXT: subq $40, %rsp
62-
; TEXT-01-NEXT: callq 23
62+
; TEXT-01-NEXT: callq 0x140001020
6363
; TEXT-01-NEXT: xorl %eax, %eax
6464
; TEXT-01-NEXT: addq $40, %rsp
6565
; TEXT-01-NEXT: retq
@@ -118,7 +118,7 @@
118118
; TEXT-10-NEXT: int3
119119
; TEXT-10-NEXT: int3
120120
; TEXT-10-NEXT: subq $40, %rsp
121-
; TEXT-10-NEXT: callq -41
121+
; TEXT-10-NEXT: callq 0x140001000
122122
; TEXT-10-NEXT: xorl %eax, %eax
123123
; TEXT-10-NEXT: addq $40, %rsp
124124
; TEXT-10-NEXT: retq

lld/test/ELF/comdat.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ foo:
3131
// CHECK-EMPTY:
3232
// CHECK-NEXT: <bar>:
3333
// 0x1234 - 0x1235 - 5 = -6
34-
// CHECK-NEXT: 1235: {{.*}} callq -6
34+
// CHECK-NEXT: 1235: {{.*}} callq 0x1234
3535

3636
.section .text3,"axG",@progbits,zed,comdat,unique,0
3737

lld/test/ELF/gnu-ifunc-i386.s

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@
113113
// DISASM: <bar_resolver>:
114114
// DISASM-NEXT: 4010e5: retl
115115
// DISASM: <_start>:
116-
// DISASM-NEXT: 4010e6: calll 21 <foo>
117-
// DISASM-NEXT: calll 32 <bar>
116+
// DISASM-NEXT: 4010e6: calll 0x401100 <foo>
117+
// DISASM-NEXT: calll 0x401110 <bar>
118118
// DISASM-NEXT: movl $4194516, %edx
119119
// DISASM-NEXT: movl $4194532, %edx
120120
// DISASM-EMPTY:
@@ -123,11 +123,11 @@
123123
// DISASM-NEXT: <foo>:
124124
// DISASM-NEXT: 401100: jmpl *4202784
125125
// DISASM-NEXT: pushl $0
126-
// DISASM-NEXT: jmp -4198672
126+
// DISASM-NEXT: jmp 0x0
127127
// DISASM: <bar>:
128128
// DISASM-NEXT: 401110: jmpl *4202788
129129
// DISASM-NEXT: pushl $8
130-
// DISASM-NEXT: jmp -4198688
130+
// DISASM-NEXT: jmp 0x0
131131

132132
.text
133133
.type foo STT_GNU_IFUNC

lld/test/ELF/gnu-ifunc-noplt-i386.s

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
// DISASM-NEXT: retl
2828
// DISASM-EMPTY:
2929
// DISASM-NEXT: 004011ee <_start>:
30-
// DISASM-NEXT: calll -0x4 <_start+0x1>
31-
// DISASM-NEXT: calll -0x4 <_start+0x6>
32-
// DISASM-NEXT: calll 0x23 <bar2@plt>
33-
// DISASM-NEXT: calll 0x2e <zed2@plt>
30+
// DISASM-NEXT: calll 0x4011ef <_start+0x1>
31+
// DISASM-NEXT: calll 0x4011f4 <_start+0x6>
32+
// DISASM-NEXT: calll 0x401220 <bar2@plt>
33+
// DISASM-NEXT: calll 0x401230 <zed2@plt>
3434
// DISASM-EMPTY:
3535
// DISASM-NEXT: Disassembly of section .plt:
3636
// DISASM-EMPTY:
@@ -45,12 +45,12 @@
4545
// DISASM-NEXT: 00401220 <bar2@plt>:
4646
// DISASM-NEXT: jmpl *0x4032d4
4747
// DISASM-NEXT: pushl $0x0
48-
// DISASM-NEXT: jmp -0x20 <.plt>
48+
// DISASM-NEXT: jmp 0x401210 <.plt>
4949
// DISASM-EMPTY:
5050
// DISASM-NEXT: 00401230 <zed2@plt>:
5151
// DISASM-NEXT: jmpl *0x4032d8
5252
// DISASM-NEXT: pushl $0x8
53-
// DISASM-NEXT: jmp -0x30 <.plt>
53+
// DISASM-NEXT: jmp 0x401210 <.plt>
5454

5555
.text
5656
.type foo STT_GNU_IFUNC

lld/test/ELF/gnu-ifunc-noplt.s

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030
// DISASM-NEXT: 201321: retq
3131
// DISASM-EMPTY:
3232
// DISASM-NEXT: 0000000000201322 <_start>:
33-
// DISASM-NEXT: 201322: callq 0 <_start+0x5>
34-
// DISASM-NEXT: 201327: callq 0 <_start+0xa>
35-
// DISASM-NEXT: 20132c: callq 31 <bar2@plt>
36-
// DISASM-NEXT: 201331: callq 42 <zed2@plt>
33+
// DISASM-NEXT: 201322: callq 0x201327 <_start+0x5>
34+
// DISASM-NEXT: 201327: callq 0x20132c <_start+0xa>
35+
// DISASM-NEXT: 20132c: callq 0x201350 <bar2@plt>
36+
// DISASM-NEXT: 201331: callq 0x201360 <zed2@plt>
3737
// DISASM-EMPTY:
3838
// DISASM-NEXT: Disassembly of section .plt:
3939
// DISASM-EMPTY:
@@ -45,12 +45,12 @@
4545
// DISASM-NEXT: 0000000000201350 <bar2@plt>:
4646
// DISASM-NEXT: 201350: jmpq *8514(%rip)
4747
// DISASM-NEXT: 201356: pushq $0
48-
// DISASM-NEXT: 20135b: jmp -32 <.plt>
48+
// DISASM-NEXT: 20135b: jmp 0x201340 <.plt>
4949
// DISASM-EMPTY:
5050
// DISASM-NEXT: 0000000000201360 <zed2@plt>:
5151
// DISASM-NEXT: 201360: jmpq *8506(%rip)
5252
// DISASM-NEXT: 201366: pushq $1
53-
// DISASM-NEXT: 20136b: jmp -48 <.plt>
53+
// DISASM-NEXT: 20136b: jmp 0x201340 <.plt>
5454

5555
.text
5656
.type foo STT_GNU_IFUNC

lld/test/ELF/gnu-ifunc-plt-i386.s

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@
3737
// DISASM: <bar>:
3838
// DISASM-NEXT: 4011b5: retl
3939
// DISASM: <_start>:
40-
// DISASM-NEXT: 4011b6: calll 69 <zed2+0x401200>
41-
// DISASM-NEXT: calll 80 <zed2+0x401210>
42-
// DISASM-NEXT: calll 27 <bar2@plt>
43-
// DISASM-NEXT: calll 38 <zed2@plt>
40+
// DISASM-NEXT: 4011b6: calll 0x401200 <zed2+0x401200>
41+
// DISASM-NEXT: calll 0x401210 <zed2+0x401210>
42+
// DISASM-NEXT: calll 0x4011e0 <bar2@plt>
43+
// DISASM-NEXT: calll 0x4011f0 <zed2@plt>
4444
// DISASM-EMPTY:
4545
// DISASM-NEXT: Disassembly of section .plt:
4646
// DISASM-EMPTY:
@@ -55,22 +55,22 @@
5555
// DISASM-NEXT: <bar2@plt>:
5656
// DISASM-NEXT: 4011e0: jmpl *4207268
5757
// DISASM-NEXT: pushl $0
58-
// DISASM-NEXT: jmp -32 <.plt>
58+
// DISASM-NEXT: jmp 0x4011d0 <.plt>
5959
// DISASM-EMPTY:
6060
// DISASM-NEXT: <zed2@plt>:
6161
// DISASM-NEXT: 4011f0: jmpl *4207272
6262
// DISASM-NEXT: pushl $8
63-
// DISASM-NEXT: jmp -48 <.plt>
63+
// DISASM-NEXT: jmp 0x4011d0 <.plt>
6464
// DISASM-EMPTY:
6565
// DISASM-NEXT: Disassembly of section .iplt:
6666
// DISASM-EMPTY:
6767
// DISASM-NEXT: <.iplt>:
6868
// DISASM-NEXT: jmpl *4207276
6969
// DISASM-NEXT: pushl $0
70-
// DISASM-NEXT: jmp -64 <.plt>
70+
// DISASM-NEXT: jmp 0x4011d0 <.plt>
7171
// DISASM-NEXT: jmpl *4207280
7272
// DISASM-NEXT: pushl $8
73-
// DISASM-NEXT: jmp -80 <.plt>
73+
// DISASM-NEXT: jmp 0x4011d0 <.plt>
7474

7575
.text
7676
.type foo STT_GNU_IFUNC

lld/test/ELF/gnu-ifunc-plt.s

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
// DISASM: <bar>:
4242
// DISASM-NEXT: 2012d9: retq
4343
// DISASM: <_start>:
44-
// DISASM-NEXT: 2012da: callq 65
45-
// DISASM-NEXT: 2012df: callq 76
44+
// DISASM-NEXT: 2012da: callq 0x201320
45+
// DISASM-NEXT: 2012df: callq 0x201330
4646
// DISASM-NEXT: callq {{.*}} <bar2@plt>
4747
// DISASM-NEXT: callq {{.*}} <zed2@plt>
4848
// DISASM-EMPTY:
@@ -56,22 +56,22 @@
5656
// DISASM-NEXT: <bar2@plt>:
5757
// DISASM-NEXT: 201300: jmpq *8514(%rip)
5858
// DISASM-NEXT: 201306: pushq $0
59-
// DISASM-NEXT: 20130b: jmp -32 <.plt>
59+
// DISASM-NEXT: 20130b: jmp 0x2012f0 <.plt>
6060
// DISASM-EMPTY:
6161
// DISASM-NEXT: <zed2@plt>:
6262
// DISASM-NEXT: 201310: jmpq *8506(%rip)
6363
// DISASM-NEXT: 201316: pushq $1
64-
// DISASM-NEXT: 20131b: jmp -48 <.plt>
64+
// DISASM-NEXT: 20131b: jmp 0x2012f0 <.plt>
6565
// DISASM-EMPTY:
6666
// DISASM-NEXT: Disassembly of section .iplt:
6767
// DISASM-EMPTY:
6868
// DISASM-NEXT: <.iplt>:
6969
// DISASM-NEXT: 201320: jmpq *8498(%rip)
7070
// DISASM-NEXT: 201326: pushq $0
71-
// DISASM-NEXT: 20132b: jmp -64 <.plt>
71+
// DISASM-NEXT: 20132b: jmp 0x2012f0 <.plt>
7272
// DISASM-NEXT: 201330: jmpq *8490(%rip)
7373
// DISASM-NEXT: 201336: pushq $1
74-
// DISASM-NEXT: 20133b: jmp -80 <.plt>
74+
// DISASM-NEXT: 20133b: jmp 0x2012f0 <.plt>
7575

7676
.text
7777
.type foo STT_GNU_IFUNC

lld/test/ELF/gnu-ifunc-shared.s

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
// DISASM: <fct2>:
1717
// DISASM-NEXT: 1309: retq
1818
// DISASM: <f1>:
19-
// DISASM-NEXT: 130a: callq 65
20-
// DISASM-NEXT: 130f: callq 28
21-
// DISASM-NEXT: 1314: callq 39
19+
// DISASM-NEXT: 130a: callq 0x1350
20+
// DISASM-NEXT: 130f: callq 0x1330
21+
// DISASM-NEXT: 1314: callq 0x1340
2222
// DISASM-NEXT: 1319: retq
2323
// DISASM: <f2>:
2424
// DISASM-NEXT: 131a: retq
@@ -33,18 +33,18 @@
3333
// DISASM-NEXT: <fct2@plt>:
3434
// DISASM-NEXT: 1330: jmpq *8482(%rip)
3535
// DISASM-NEXT: 1336: pushq $0
36-
// DISASM-NEXT: 133b: jmp -32 <.plt>
36+
// DISASM-NEXT: 133b: jmp 0x1320 <.plt>
3737
// DISASM-EMPTY:
3838
// DISASM-NEXT: <f2@plt>:
3939
// DISASM-NEXT: 1340: jmpq *8474(%rip)
4040
// DISASM-NEXT: 1346: pushq $1
41-
// DISASM-NEXT: 134b: jmp -48 <.plt>
41+
// DISASM-NEXT: 134b: jmp 0x1320 <.plt>
4242
// DISASM: Disassembly of section .iplt:
4343
// DISASM-EMPTY:
4444
// DISASM: <.iplt>:
4545
// DISASM-NEXT: 1350: jmpq *8466(%rip)
4646
// DISASM-NEXT: 1356: pushq $0
47-
// DISASM-NEXT: 135b: jmp -64 <.plt>
47+
// DISASM-NEXT: 135b: jmp 0x1320 <.plt>
4848

4949
// CHECK: Relocations [
5050
// CHECK-NEXT: Section (5) .rela.dyn {

lld/test/ELF/gnu-ifunc.s

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@
9696
// DISASM: <bar>:
9797
// DISASM-NEXT: 201189: {{.*}} retq
9898
// DISASM: <_start>:
99-
// DISASM-NEXT: 20118a: {{.*}} callq 33
100-
// DISASM-NEXT: 20118f: {{.*}} callq 44
99+
// DISASM-NEXT: 20118a: {{.*}} callq 0x2011b0
100+
// DISASM-NEXT: 20118f: {{.*}} callq 0x2011c0
101101
// DISASM-NEXT: 201194: {{.*}} movl $2097496, %edx
102102
// DISASM-NEXT: 201199: {{.*}} movl $2097544, %edx
103103
// DISASM-NEXT: 20119e: {{.*}} movl $2097545, %edx
@@ -107,10 +107,10 @@
107107
// DISASM-NEXT: <.iplt>:
108108
// DISASM-NEXT: 2011b0: {{.*}} jmpq *4122(%rip)
109109
// DISASM-NEXT: 2011b6: {{.*}} pushq $0
110-
// DISASM-NEXT: 2011bb: {{.*}} jmp -2101696
110+
// DISASM-NEXT: 2011bb: {{.*}} jmp 0x0
111111
// DISASM-NEXT: 2011c0: {{.*}} jmpq *4114(%rip)
112112
// DISASM-NEXT: 2011c6: {{.*}} pushq $1
113-
// DISASM-NEXT: 2011cb: {{.*}} jmp -2101712
113+
// DISASM-NEXT: 2011cb: {{.*}} jmp 0x0
114114

115115
.text
116116
.type foo STT_GNU_IFUNC

lld/test/ELF/i386-feature-cet.s

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141

4242
# DISASM: Disassembly of section .text:
4343
# DISASM: 00401200 <func1>:
44-
# DISASM-NEXT: 401200: calll 0x2b <func2+0x401230>
45-
# DISASM-NEXT: 401205: calll 0x36 <ifunc>
44+
# DISASM-NEXT: 401200: calll 0x401230 <func2+0x401230>
45+
# DISASM-NEXT: 401205: calll 0x401240 <ifunc>
4646
# DISASM-NEXT: retl
4747

4848
# DISASM: Disassembly of section .plt:
@@ -55,7 +55,7 @@
5555
# DISASM-NEXT: nop
5656
# DISASM-NEXT: endbr32
5757
# DISASM-NEXT: pushl $0x0
58-
# DISASM-NEXT: jmp -0x1e <.plt>
58+
# DISASM-NEXT: jmp 0x401210 <.plt>
5959
# DISASM-NEXT: nop
6060

6161
# DISASM: Disassembly of section .plt.sec:

0 commit comments

Comments
 (0)