2 # RUN: split-file %s %t
3 # RUN: llvm-mc -filetype=obj -triple=x86_64 %t/a.s -o %t/a.o
4 # RUN: ld.lld -T %t/lds1 %t/a.o -o %t/bin
5 # RUN: llvm-objdump -d %t/bin | FileCheck --check-prefix=DISASM %s
6 # RUN: llvm-readelf -S %t/bin | FileCheck --check-prefixes=GOT %s
7 # RUN: ld.lld -T %t/lds2 %t/a.o -o %t/bin2
8 # RUN: llvm-objdump -d %t/bin2 | FileCheck --check-prefix=DISASM %s
9 # RUN: llvm-readelf -S %t/bin2 | FileCheck --check-prefixes=GOT %s
10 # RUN: ld.lld -T %t/lds3 %t/a.o -o %t/bin3
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
16 # DISASM-NEXT: movl 0x1ffffa(%rip), %eax
17 # DISASM-NEXT: addq 0x1ffffb(%rip), %rax
18 # DISASM-NEXT: addq $0x7fffffff, %rax
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
26 # DISASM4-NEXT: leal 0x7fffeffa(%rip), %eax
27 # DISASM4-NEXT: addq 0x1ff3(%rip), %rax
28 # DISASM4-NEXT: addq $0x7fffffff, %rax
30 # In our implementation, .got is retained even if all GOT-generating relocations are optimized.
31 # Make sure .got still exists with the right size.
32 # UNNECESSARY-GOT: .got PROGBITS 0000000000300000 101020 000000 00 WA 0 0 8
33 # GOT: .got PROGBITS 0000000000300000 102000 000018 00 WA 0 0 8
36 .section .text.foo,"ax"
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
46 .type _start, @function
48 movl __stop_data@GOTPCREL
(%rip
), %eax
# out of range
49 movq __stop_data@GOTPCREL
(%rip
), %rax
# out of range
50 movq __stop_data@GOTPCREL
(%rip
), %rax
# in range
51 movl __stop_data@GOTPCREL
(%rip
), %eax
# in range
53 .section foo,"aw",@progbits
58 .section data,"aw",@progbits
63 .text.foo 0x100000 : { *(.text.foo) }
64 .text 0x200000 : { *(.text) }
65 .got 0x300000 : { *(.got) }
66 foo
0x7fffffff : { *(foo
) }
67 data
0x80200000 : { *(data
) }
71 .text.foo 0x100000 : { *(.text.foo) }
72 .text 0x1ff000 : { . = . + 0x1000 ; *(.text) }
73 .got 0x300000 : { *(.got) }
74 foo
0x7fffffff : { *(foo
) }
75 data
0x80200000 : { *(data
) }
79 .text.foo 0x100000 : { *(.text.foo) }
80 .text 0x200000 : { *(.text) }
81 .got 0x300000 : { *(.got) }
82 data
0x400000 : { *(data
) }
86 ## Max VA difference < 0x80000000
88 .text.foo 0x02000 : { *(.text.foo) }
89 .text 0x3000 : { *(.text) }
90 .got 0x4000 : { *(.got) }
91 foo
0x7fffffff : { *(foo
) }
92 data
0x80001000 : { *(data
) }