[memprof] Remove an unused using directive (#117004)
[llvm-project.git] / lld / test / ELF / x86-64-gotpc-relax-too-far.s
blob0318d73ec2db2626c07f2a9727755c193ba04c63
1 # REQUIRES: x86
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
15 # DISASM: <_foo>:
16 # DISASM-NEXT: movl 0x1ffffa(%rip), %eax
17 # DISASM-NEXT: addq 0x1ffffb(%rip), %rax
18 # DISASM-NEXT: addq $0x7fffffff, %rax
19 # DISASM: <_start>:
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
25 # DISASM4: <_foo>:
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
35 #--- a.s
36 .section .text.foo,"ax"
37 .globl _foo
38 .type _foo, @function
39 _foo:
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
44 .section .text,"ax"
45 .globl _start
46 .type _start, @function
47 _start:
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
54 .space 1
55 foo_1:
56 .space 1
58 .section data,"aw",@progbits
59 .space 13
61 #--- lds1
62 SECTIONS {
63 .text.foo 0x100000 : { *(.text.foo) }
64 .text 0x200000 : { *(.text) }
65 .got 0x300000 : { *(.got) }
66 foo 0x7fffffff : { *(foo) }
67 data 0x80200000 : { *(data) }
69 #--- lds2
70 SECTIONS {
71 .text.foo 0x100000 : { *(.text.foo) }
72 .text 0x1ff000 : { . = . + 0x1000 ; *(.text) }
73 .got 0x300000 : { *(.got) }
74 foo 0x7fffffff : { *(foo) }
75 data 0x80200000 : { *(data) }
77 #--- lds3
78 SECTIONS {
79 .text.foo 0x100000 : { *(.text.foo) }
80 .text 0x200000 : { *(.text) }
81 .got 0x300000 : { *(.got) }
82 data 0x400000 : { *(data) }
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) }