2
2
# RUN: split-file %s %t
3
3
# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/a.s -o %t/a.o
4
4
# RUN: ld.lld -T %t/lds1 %t/a.o -o %t/bin
5
- # RUN: llvm-objdump --no-print-imm-hex - d %t/bin | FileCheck --check-prefix=DISASM %s
5
+ # RUN: llvm-objdump -d %t/bin | FileCheck --check-prefix=DISASM %s
6
6
# RUN: llvm-readelf -S %t/bin | FileCheck --check-prefixes=GOT %s
7
7
# RUN: ld.lld -T %t/lds2 %t/a.o -o %t/bin2
8
- # RUN: llvm-objdump --no-print-imm-hex - d %t/bin2 | FileCheck --check-prefix=DISASM %s
8
+ # RUN: llvm-objdump -d %t/bin2 | FileCheck --check-prefix=DISASM %s
9
9
# RUN: llvm-readelf -S %t/bin2 | FileCheck --check-prefixes=GOT %s
10
10
# RUN: ld.lld -T %t/lds3 %t/a.o -o %t/bin3
11
11
# RUN: llvm-readelf -S %t/bin3 | FileCheck --check-prefixes=UNNECESSARY-GOT %s
12
+ # RUN: ld.lld -T %t/lds4 %t/a.o -o %t/bin4
13
+ # RUN: llvm-objdump -d %t/bin4 | FileCheck --check-prefix=DISASM4 %s
12
14
13
15
# DISASM: <_foo>:
14
- # DISASM-NEXT: movl 2097146(%rip), %eax
16
+ # DISASM-NEXT: movl 0x1ffffa(%rip), %eax
17
+ # DISASM-NEXT: addq 0x1ffffb(%rip), %rax
18
+ # DISASM-NEXT: addq $0x7fffffff, %rax
15
19
# DISASM: <_start>:
16
- # DISASM-NEXT: movl 1048578(%rip), %eax
17
- # DISASM-NEXT: movq 1048571(%rip), %rax
18
- # DISASM-NEXT: leaq 2147483641(%rip), %rax
19
- # DISASM-NEXT: leal 2147483635(%rip), %eax
20
+ # DISASM-NEXT: movl 0x10000a(%rip), %eax
21
+ # DISASM-NEXT: movq 0x100003(%rip), %rax
22
+ # DISASM-NEXT: leaq 0x7ffffff9(%rip), %rax
23
+ # DISASM-NEXT: leal 0x7ffffff3(%rip), %eax
24
+
25
+ # DISASM4: <_foo>:
26
+ # DISASM4-NEXT: leal 0x7fffeffa(%rip), %eax
27
+ # DISASM4-NEXT: addq 0x1ff3(%rip), %rax
28
+ # DISASM4-NEXT: addq $0x7fffffff, %rax
20
29
21
30
# In our implementation, .got is retained even if all GOT-generating relocations are optimized.
22
31
# Make sure .got still exists with the right size.
23
32
# UNNECESSARY-GOT: .got PROGBITS 0000000000300000 101020 000000 00 WA 0 0 8
24
- # GOT: .got PROGBITS 0000000000300000 102000 000010 00 WA 0 0 8
33
+ # GOT: .got PROGBITS 0000000000300000 102000 000018 00 WA 0 0 8
25
34
26
35
#--- a.s
27
36
.section .text .foo,"ax"
28
37
.globl _foo
29
38
.type _foo, @function
30
39
_foo:
31
40
movl __start_data@GOTPCREL(%rip ), %eax # out of range
41
+ addq foo_1@GOTPCREL(%rip ), %rax # out of range
42
+ addq foo@GOTPCREL(%rip ), %rax # in range
32
43
33
44
.section .text ,"ax"
34
45
.globl _start
@@ -39,6 +50,11 @@ _start:
39
50
movq __stop_data@GOTPCREL(%rip ), %rax # in range
40
51
movl __stop_data@GOTPCREL(%rip ), %eax # in range
41
52
53
+ .section foo,"aw" ,@progbits
54
+ .space 1
55
+ foo_1:
56
+ .space 1
57
+
42
58
.section data,"aw" ,@progbits
43
59
.space 13
44
60
@@ -47,13 +63,15 @@ SECTIONS {
47
63
.text .foo 0x100000 : { *(.text .foo) }
48
64
.text 0x200000 : { *(.text ) }
49
65
.got 0x300000 : { *(.got) }
66
+ foo 0x7fffffff : { *(foo) }
50
67
data 0x80200000 : { *(data) }
51
68
}
52
69
#--- lds2
53
70
SECTIONS {
54
71
.text .foo 0x100000 : { *(.text .foo) }
55
72
.text 0x1ff000 : { . = . + 0x1000 ; *(.text ) }
56
73
.got 0x300000 : { *(.got) }
74
+ foo 0x7fffffff : { *(foo) }
57
75
data 0x80200000 : { *(data) }
58
76
}
59
77
#--- lds3
@@ -63,3 +81,13 @@ SECTIONS {
63
81
.got 0x300000 : { *(.got) }
64
82
data 0x400000 : { *(data) }
65
83
}
84
+
85
+ #--- lds4
86
+ ## Max VA difference < 0x80000000
87
+ SECTIONS {
88
+ .text .foo 0x02000 : { *(.text .foo) }
89
+ .text 0x3000 : { *(.text ) }
90
+ .got 0x4000 : { *(.got) }
91
+ foo 0x7fffffff : { *(foo) }
92
+ data 0x80001000 : { *(data) }
93
+ }
0 commit comments