[ELF] Make section member orders consistent
[llvm-project.git] / lld / test / ELF / aarch64-plt.s
blob7d83a40dfc2783ce680c5188eb31fc664aae95f1
1 // REQUIRES: aarch64
2 // RUN: llvm-mc -filetype=obj -triple=aarch64-pc-freebsd %s -o %t.o
3 // RUN: llvm-mc -filetype=obj -triple=aarch64-pc-freebsd %p/Inputs/plt-aarch64.s -o %t2.o
4 // RUN: ld.lld -shared %t2.o -soname=t2.so -o %t2.so
5 // RUN: ld.lld -shared %t.o %t2.so -o %t.so
6 // RUN: ld.lld %t.o %t2.so -o %t.exe
7 // RUN: llvm-readobj -S -r %t.so | FileCheck --check-prefix=CHECKDSO %s
8 // RUN: llvm-objdump -s --section=.got.plt %t.so | FileCheck --check-prefix=DUMPDSO %s
9 // RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex %t.so | FileCheck --check-prefix=DISASMDSO %s
10 // RUN: llvm-readobj -S -r %t.exe | FileCheck --check-prefix=CHECKEXE %s
11 // RUN: llvm-objdump -s --section=.got.plt %t.exe | FileCheck --check-prefix=DUMPEXE %s
12 // RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex %t.exe | FileCheck --check-prefix=DISASMEXE %s
14 // CHECKDSO: Name: .plt
15 // CHECKDSO-NEXT: Type: SHT_PROGBITS
16 // CHECKDSO-NEXT: Flags [
17 // CHECKDSO-NEXT: SHF_ALLOC
18 // CHECKDSO-NEXT: SHF_EXECINSTR
19 // CHECKDSO-NEXT: ]
20 // CHECKDSO-NEXT: Address: 0x10340
21 // CHECKDSO-NEXT: Offset:
22 // CHECKDSO-NEXT: Size: 80
23 // CHECKDSO-NEXT: Link:
24 // CHECKDSO-NEXT: Info:
25 // CHECKDSO-NEXT: AddressAlignment: 16
27 // CHECKDSO: Name: .got.plt
28 // CHECKDSO-NEXT: Type: SHT_PROGBITS
29 // CHECKDSO-NEXT: Flags [
30 // CHECKDSO-NEXT: SHF_ALLOC
31 // CHECKDSO-NEXT: SHF_WRITE
32 // CHECKDSO-NEXT: ]
33 // CHECKDSO-NEXT: Address: 0x30450
34 // CHECKDSO-NEXT: Offset:
35 // CHECKDSO-NEXT: Size: 48
36 // CHECKDSO-NEXT: Link:
37 // CHECKDSO-NEXT: Info:
38 // CHECKDSO-NEXT: AddressAlignment: 8
40 // CHECKDSO: Relocations [
41 // CHECKDSO-NEXT: Section ({{.*}}) .rela.plt {
43 // &(.got.plt[3]) = 0x30450 + 3 * 8 = 0x30468
44 // CHECKDSO-NEXT: 0x30468 R_AARCH64_JUMP_SLOT foo
46 // &(.got.plt[4]) = 0x30450 + 4 * 8 = 0x30470
47 // CHECKDSO-NEXT: 0x30470 R_AARCH64_JUMP_SLOT bar
49 // &(.got.plt[5]) = 0x30000 + 5 * 8 = 0x30470
50 // CHECKDSO-NEXT: 0x30478 R_AARCH64_JUMP_SLOT weak
51 // CHECKDSO-NEXT: }
52 // CHECKDSO-NEXT: ]
54 // DUMPDSO: Contents of section .got.plt:
55 // .got.plt[0..2] = 0 (reserved)
56 // .got.plt[3..5] = .plt = 0x10010
57 // DUMPDSO-NEXT: 30450 00000000 00000000 00000000 00000000
58 // DUMPDSO-NEXT: 30460 00000000 00000000 40030100 00000000
59 // DUMPDSO-NEXT: 30470 40030100 00000000 40030100 00000000
61 // DISASMDSO: <_start>:
62 // DISASMDSO-NEXT: 10330: b 0x10360 <foo@plt>
63 // DISASMDSO-NEXT: 10334: b 0x10370 <bar@plt>
64 // DISASMDSO-NEXT: 10338: b 0x10380 <weak@plt>
66 // DISASMDSO: <foo>:
67 // DISASMDSO-NEXT: 1033c: nop
69 // DISASMDSO: Disassembly of section .plt:
70 // DISASMDSO-EMPTY:
71 // DISASMDSO-NEXT: <.plt>:
72 // DISASMDSO-NEXT: 10340: stp x16, x30, [sp, #-0x10]!
73 // &(.got.plt[2]) = 0x30450 + 2 * 8 = 0x30460
74 // DISASMDSO-NEXT: 10344: adrp x16, 0x30000
75 // DISASMDSO-NEXT: 10348: ldr x17, [x16, #0x460]
76 // DISASMDSO-NEXT: 1034c: add x16, x16, #0x460
77 // DISASMDSO-NEXT: 10350: br x17
78 // DISASMDSO-NEXT: 10354: nop
79 // DISASMDSO-NEXT: 10358: nop
80 // DISASMDSO-NEXT: 1035c: nop
82 // foo@plt 0x30468
83 // &.got.plt[foo] = 0x30468
84 // DISASMDSO-EMPTY:
85 // DISASMDSO-NEXT: <foo@plt>:
86 // DISASMDSO-NEXT: 10360: adrp x16, 0x30000
87 // DISASMDSO-NEXT: 10364: ldr x17, [x16, #0x468]
88 // DISASMDSO-NEXT: 10368: add x16, x16, #0x468
89 // DISASMDSO-NEXT: 1036c: br x17
91 // bar@plt
92 // &.got.plt[foo] = 0x30470
93 // DISASMDSO-EMPTY:
94 // DISASMDSO-NEXT: <bar@plt>:
95 // DISASMDSO-NEXT: 10370: adrp x16, 0x30000
96 // DISASMDSO-NEXT: 10374: ldr x17, [x16, #0x470]
97 // DISASMDSO-NEXT: 10378: add x16, x16, #0x470
98 // DISASMDSO-NEXT: 1037c: br x17
100 // weak@plt
101 // 0x30468 = 0x10000 + 131072 + 1128
102 // DISASMDSO-EMPTY:
103 // DISASMDSO-NEXT: <weak@plt>:
104 // DISASMDSO-NEXT: 10380: adrp x16, 0x30000
105 // DISASMDSO-NEXT: 10384: ldr x17, [x16, #0x478]
106 // DISASMDSO-NEXT: 10388: add x16, x16, #0x478
107 // DISASMDSO-NEXT: 1038c: br x17
109 // CHECKEXE: Name: .plt
110 // CHECKEXE-NEXT: Type: SHT_PROGBITS
111 // CHECKEXE-NEXT: Flags [
112 // CHECKEXE-NEXT: SHF_ALLOC
113 // CHECKEXE-NEXT: SHF_EXECINSTR
114 // CHECKEXE-NEXT: ]
115 // CHECKEXE-NEXT: Address: 0x2102E0
116 // CHECKEXE-NEXT: Offset:
117 // CHECKEXE-NEXT: Size: 64
118 // CHECKEXE-NEXT: Link:
119 // CHECKEXE-NEXT: Info:
120 // CHECKEXE-NEXT: AddressAlignment: 16
122 // CHECKEXE: Name: .got.plt
123 // CHECKEXE-NEXT: Type: SHT_PROGBITS
124 // CHECKEXE-NEXT: Flags [
125 // CHECKEXE-NEXT: SHF_ALLOC
126 // CHECKEXE-NEXT: SHF_WRITE
127 // CHECKEXE-NEXT: ]
128 // CHECKEXE-NEXT: Address: 0x2303F0
129 // CHECKEXE-NEXT: Offset:
130 // CHECKEXE-NEXT: Size: 40
131 // CHECKEXE-NEXT: Link:
132 // CHECKEXE-NEXT: Info:
133 // CHECKEXE-NEXT: AddressAlignment: 8
135 // CHECKEXE: Relocations [
136 // CHECKEXE-NEXT: Section ({{.*}}) .rela.plt {
138 // &(.got.plt[3]) = 0x2303f0 + 3 * 8 = 0x230408
139 // CHECKEXE-NEXT: 0x230408 R_AARCH64_JUMP_SLOT bar 0x0
141 // &(.got.plt[4]) = 0x2303f0 + 4 * 8 = 0x230410
142 // CHECKEXE-NEXT: 0x230410 R_AARCH64_JUMP_SLOT weak 0x0
143 // CHECKEXE-NEXT: }
144 // CHECKEXE-NEXT: ]
146 // DUMPEXE: Contents of section .got.plt:
147 // .got.plt[0..2] = 0 (reserved)
148 // .got.plt[3..4] = .plt = 0x40010
149 // DUMPEXE-NEXT: 2303f0 00000000 00000000 00000000 00000000
150 // DUMPEXE-NEXT: 230400 00000000 00000000 e0022100 00000000
151 // DUMPEXE-NEXT: 230410 e0022100 00000000
153 // DISASMEXE: <_start>:
154 // DISASMEXE-NEXT: 2102c8: b 0x2102d4 <foo>
155 // DISASMEXE-NEXT: 2102cc: b 0x210300 <bar@plt>
156 // DISASMEXE-NEXT: 2102d0: b 0x210310 <weak@plt>
158 // DISASMEXE: <foo>:
159 // DISASMEXE-NEXT: 2102d4: nop
161 // DISASMEXE: Disassembly of section .plt:
162 // DISASMEXE-EMPTY:
163 // DISASMEXE-NEXT: <.plt>:
164 // DISASMEXE-NEXT: 2102e0: stp x16, x30, [sp, #-0x10]!
165 // &(.got.plt[2]) = 0x2303f0 + 2 * 8 = 0x230400
166 // DISASMEXE-NEXT: 2102e4: adrp x16, 0x230000
167 // DISASMEXE-NEXT: 2102e8: ldr x17, [x16, #0x400]
168 // DISASMEXE-NEXT: 2102ec: add x16, x16, #0x400
169 // DISASMEXE-NEXT: 2102f0: br x17
170 // DISASMEXE-NEXT: 2102f4: nop
171 // DISASMEXE-NEXT: 2102f8: nop
172 // DISASMEXE-NEXT: 2102fc: nop
174 // bar@plt
175 // DISASMEXE-EMPTY:
176 // DISASMEXE-NEXT: <bar@plt>:
177 // DISASMEXE-NEXT: 210300: adrp x16, 0x230000
178 // DISASMEXE-NEXT: 210304: ldr x17, [x16, #0x408]
179 // DISASMEXE-NEXT: 210308: add x16, x16, #0x408
180 // DISASMEXE-NEXT: 21030c: br x17
182 // weak@plt
183 // DISASMEXE-EMPTY:
184 // DISASMEXE-NEXT: <weak@plt>:
185 // DISASMEXE-NEXT: 210310: adrp x16, 0x230000
186 // DISASMEXE-NEXT: 210314: ldr x17, [x16, #0x410]
187 // DISASMEXE-NEXT: 210318: add x16, x16, #0x410
188 // DISASMEXE-NEXT: 21031c: br x17
190 .global _start,foo,bar
191 .weak weak
192 _start:
193 b foo
194 b bar
195 b weak
197 .section .text2,"ax",@progbits
198 foo: