[memprof] Remove an unused using directive (#117004)
[llvm-project.git] / lld / test / ELF / x86-64-gotpc-relax.s
blobbc5830ba7b6295efa2ed055244e215fd33c0fe33
1 # REQUIRES: x86
2 ## Test R_X86_64_GOTPCRELX and R_X86_64_REX_GOTPCRELX/R_X86_64_CODE_4_GOTPCRELX GOT optimization.
4 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
5 # RUN: ld.lld %t.o -o %t1 --no-apply-dynamic-relocs
6 # RUN: llvm-readelf -S -r -x .got.plt %t1 | FileCheck --check-prefixes=CHECK,NOAPPLY %s
7 # RUN: ld.lld %t.o -o %t1 --apply-dynamic-relocs
8 # RUN: llvm-readelf -S -r -x .got.plt %t1 | FileCheck --check-prefixes=CHECK,APPLY %s
9 # RUN: ld.lld %t.o -o %t1
10 # RUN: llvm-objdump --no-print-imm-hex -d %t1 | FileCheck --check-prefix=DISASM %s
12 ## --no-relax disables GOT optimization.
13 # RUN: ld.lld --no-relax %t.o -o %t2
14 # RUN: llvm-objdump --no-print-imm-hex -d %t2 | FileCheck --check-prefix=NORELAX %s
16 ## In our implementation, .got is retained even if all GOT-generating relocations are optimized.
17 # CHECK: Name Type Address Off Size ES Flg Lk Inf Al
18 # CHECK: .iplt PROGBITS 00000000002012e0 0002e0 000010 00 AX 0 0 16
19 # CHECK-NEXT: .got PROGBITS 00000000002022f0 0002f0 000000 00 WA 0 0 8
21 ## There is one R_X86_64_IRELATIVE relocations.
22 # RELOC-LABEL: Relocation section '.rela.dyn' at offset {{.*}} contains 1 entry:
23 # CHECK: Offset Info Type Symbol's Value Symbol's Name + Addend
24 # CHECK: 00000000002032f0 0000000000000025 R_X86_64_IRELATIVE 2011e2
25 # CHECK-LABEL: Hex dump of section '.got.plt':
26 # NOAPPLY-NEXT: 0x002032f0 00000000 00000000
27 # APPLY-NEXT: 0x002032f0 e2112000 00000000
29 # 0x201173 + 7 - 10 = 0x201170
30 # 0x20117a + 7 - 17 = 0x201170
31 # 0x201181 + 7 - 23 = 0x201171
32 # 0x201188 + 7 - 30 = 0x201171
33 # DISASM: Disassembly of section .text:
34 # DISASM-EMPTY:
35 # DISASM-NEXT: <foo>:
36 # DISASM-NEXT: 2011e0: 90 nop
37 # DISASM: <hid>:
38 # DISASM-NEXT: 2011e1: 90 nop
39 # DISASM: <ifunc>:
40 # DISASM-NEXT: 2011e2: c3 retq
41 # DISASM: <_start>:
42 # DISASM-NEXT: leaq -10(%rip), %rax
43 # DISASM-NEXT: leaq -17(%rip), %rax
44 # DISASM-NEXT: leaq -23(%rip), %rax
45 # DISASM-NEXT: leaq -30(%rip), %rax
46 # DISASM-NEXT: movq 8426(%rip), %rax
47 # DISASM-NEXT: movq 8419(%rip), %rax
48 # DISASM-NEXT: leaq -52(%rip), %rax
49 # DISASM-NEXT: leaq -59(%rip), %rax
50 # DISASM-NEXT: leaq -65(%rip), %rax
51 # DISASM-NEXT: leaq -72(%rip), %rax
52 # DISASM-NEXT: movq 8384(%rip), %rax
53 # DISASM-NEXT: movq 8377(%rip), %rax
54 # DISASM-NEXT: callq 0x2011e0 <foo>
55 # DISASM-NEXT: callq 0x2011e0 <foo>
56 # DISASM-NEXT: callq 0x2011e1 <hid>
57 # DISASM-NEXT: callq 0x2011e1 <hid>
58 # DISASM-NEXT: callq *8347(%rip)
59 # DISASM-NEXT: callq *8341(%rip)
60 # DISASM-NEXT: jmp 0x2011e0 <foo>
61 # DISASM-NEXT: nop
62 # DISASM-NEXT: jmp 0x2011e0 <foo>
63 # DISASM-NEXT: nop
64 # DISASM-NEXT: jmp 0x2011e1 <hid>
65 # DISASM-NEXT: nop
66 # DISASM-NEXT: jmp 0x2011e1 <hid>
67 # DISASM-NEXT: nop
68 # DISASM-NEXT: jmpq *8311(%rip)
69 # DISASM-NEXT: jmpq *8305(%rip)
70 # DISASM-NEXT: leaq -167(%rip), %r16
71 # DISASM-NEXT: leaq -175(%rip), %r16
72 # DISASM-NEXT: leaq -182(%rip), %r16
73 # DISASM-NEXT: leaq -190(%rip), %r16
74 # DISASM-NEXT: movq 8265(%rip), %r16
75 # DISASM-NEXT: movq 8257(%rip), %r16
76 # DISASM-NEXT: leaq -215(%rip), %r16
77 # DISASM-NEXT: leaq -223(%rip), %r16
78 # DISASM-NEXT: leaq -230(%rip), %r16
79 # DISASM-NEXT: leaq -238(%rip), %r16
80 # DISASM-NEXT: movq 8217(%rip), %r16
81 # DISASM-NEXT: movq 8209(%rip), %r16
83 # NORELAX-LABEL: <_start>:
84 # NORELAX-COUNT-12: movq
85 # NORELAX-COUNT-6: callq *
86 # NORELAX-COUNT-6: jmpq *
87 # NORELAX-COUNT-12: movq
89 .text
90 .globl foo
91 .type foo, @function
92 foo:
93 nop
95 .globl hid
96 .hidden hid
97 .type hid, @function
98 hid:
99 nop
101 .text
102 .type ifunc STT_GNU_IFUNC
103 .globl ifunc
104 .type ifunc, @function
105 ifunc:
108 .globl _start
109 .type _start, @function
110 _start:
111 movq foo@GOTPCREL(%rip), %rax
112 movq foo@GOTPCREL(%rip), %rax
113 movq hid@GOTPCREL(%rip), %rax
114 movq hid@GOTPCREL(%rip), %rax
115 movq ifunc@GOTPCREL(%rip), %rax
116 movq ifunc@GOTPCREL(%rip), %rax
117 movq foo@GOTPCREL(%rip), %rax
118 movq foo@GOTPCREL(%rip), %rax
119 movq hid@GOTPCREL(%rip), %rax
120 movq hid@GOTPCREL(%rip), %rax
121 movq ifunc@GOTPCREL(%rip), %rax
122 movq ifunc@GOTPCREL(%rip), %rax
124 call *foo@GOTPCREL(%rip)
125 call *foo@GOTPCREL(%rip)
126 call *hid@GOTPCREL(%rip)
127 call *hid@GOTPCREL(%rip)
128 call *ifunc@GOTPCREL(%rip)
129 call *ifunc@GOTPCREL(%rip)
130 jmp *foo@GOTPCREL(%rip)
131 jmp *foo@GOTPCREL(%rip)
132 jmp *hid@GOTPCREL(%rip)
133 jmp *hid@GOTPCREL(%rip)
134 jmp *ifunc@GOTPCREL(%rip)
135 jmp *ifunc@GOTPCREL(%rip)
137 movq foo@GOTPCREL(%rip), %r16
138 movq foo@GOTPCREL(%rip), %r16
139 movq hid@GOTPCREL(%rip), %r16
140 movq hid@GOTPCREL(%rip), %r16
141 movq ifunc@GOTPCREL(%rip), %r16
142 movq ifunc@GOTPCREL(%rip), %r16
143 movq foo@GOTPCREL(%rip), %r16
144 movq foo@GOTPCREL(%rip), %r16
145 movq hid@GOTPCREL(%rip), %r16
146 movq hid@GOTPCREL(%rip), %r16
147 movq ifunc@GOTPCREL(%rip), %r16
148 movq ifunc@GOTPCREL(%rip), %r16