llvm-project
374 строки · 10.2 Кб
1// REQUIRES: aarch64
2// RUN: split-file %s %t.dir && cd %t.dir
3
4#--- test-simple.s
5// Build a simple function with an entry thunk.
6
7.section .text,"xr",discard,func
8.globl func
9.p2align 2
10func:
11mov w0, #1
12ret
13
14.section .wowthk$aa,"xr",discard,thunk
15.globl thunk
16.p2align 2
17thunk:
18mov w0, #10
19ret
20
21.section .hybmp$x, "yi"
22.symidx func
23.symidx thunk
24.word 1 // entry thunk
25
26.data
27.rva func
28
29// RUN: llvm-mc -filetype=obj -triple=arm64ec-windows %S/Inputs/loadconfig-arm64ec.s -o loadcfg.obj
30// RUN: llvm-mc -filetype=obj -triple=arm64ec-windows test-simple.s -o test-simple.obj
31// RUN: lld-link -machine:arm64ec -dll -noentry -out:out-simple.dll loadcfg.obj test-simple.obj
32// RUN: llvm-objdump -d out-simple.dll | FileCheck --check-prefix=DISASM %s
33
34// DISASM: Disassembly of section .text:
35// DISASM-EMPTY:
36// DISASM-NEXT: 0000000180001000 <.text>:
37// DISASM-NEXT: 180001000: 00000009 udf #0x9
38// DISASM-NEXT: 180001004: 52800020 mov w0, #0x1 // =1
39// DISASM-NEXT: 180001008: d65f03c0 ret
40// DISASM-NEXT: 18000100c: 52800140 mov w0, #0xa // =10
41// DISASM-NEXT: 180001010: d65f03c0 ret
42
43// RUN: llvm-readobj --sections out-simple.dll | FileCheck --check-prefix=HYBMP %s
44// HYBMP-NOT: .hybmp
45
46// RUN: lld-link -machine:arm64x -dll -noentry -out:out-simplex.dll loadcfg.obj test-simple.obj
47// RUN: llvm-objdump -d out-simplex.dll | FileCheck --check-prefix=DISASM %s
48
49#--- test-split-func.s
50// Build a simple function with an entry thunk, but pass it in multiple files.
51
52.section .text,"xr",discard,func
53.globl func
54.p2align 2
55func:
56mov w0, #1
57ret
58
59#--- test-split-thunk.s
60.section .wowthk$aa,"xr",discard,thunk
61.globl thunk
62.p2align 2
63thunk:
64mov w0, #10
65ret
66
67#--- test-split-hybmp.s
68.section .hybmp$x, "yi"
69.symidx func
70.symidx thunk
71.word 1 // entry thunk
72
73#--- test-split-data.s
74.data
75.rva func
76
77// RUN: llvm-mc -filetype=obj -triple=arm64ec-windows test-split-func.s -o test-split-func.obj
78// RUN: llvm-mc -filetype=obj -triple=arm64ec-windows test-split-thunk.s -o test-split-thunk.obj
79// RUN: llvm-mc -filetype=obj -triple=arm64ec-windows test-split-hybmp.s -o test-split-hybmp.obj
80// RUN: llvm-mc -filetype=obj -triple=arm64ec-windows test-split-data.s -o test-split-data.obj
81// RUN: lld-link -machine:arm64ec -dll -noentry -out:out-split.dll loadcfg.obj \
82// RUN: test-split-func.obj test-split-thunk.obj test-split-data.obj test-split-hybmp.obj
83// RUN: llvm-objdump -d out-split.dll | FileCheck --check-prefix=DISASM %s
84
85#--- test-align.s
86// Build multiple functions with thunks and various alignments and check that entry thunk offsets
87// are correctly placed.
88
89.section .text,"xr",discard,func
90.globl func
91.p2align 2
92func:
93mov w0, #1
94nop
95ret
96
97.section .text,"xr",discard,func2
98.globl func2
99.p2align 2
100func2:
101mov w0, #2
102ret
103
104.section .text,"xr",discard,func3
105.globl func3
106.p2align 3
107func3:
108mov w0, #3
109nop
110ret
111
112.section .text,"xr",discard,func4
113.globl func4
114.p2align 3
115func4:
116mov w0, #4
117ret
118
119.section .text,"xr",discard,func5
120.globl func5
121.p2align 3
122func5:
123mov w0, #5
124ret
125
126.section .text,"xr",discard,func6
127.globl func6
128.p2align 4
129func6:
130mov w0, #6
131ret
132
133.section .wowthk$aa,"xr",discard,thunk
134.globl thunk
135.p2align 2
136thunk:
137mov w0, #10
138ret
139
140.section .wowthk$aa,"xr",discard,thunk2
141.globl thunk2
142.p2align 2
143thunk2:
144mov w0, #20
145ret
146
147.section .hybmp$x, "yi"
148.symidx func
149.symidx thunk
150.word 1 // entry thunk
151.symidx func2
152.symidx thunk2
153.word 1 // entry thunk
154.symidx func3
155.symidx thunk
156.word 1 // entry thunk
157.symidx func4
158.symidx thunk
159.word 1 // entry thunk
160.symidx func5
161.symidx thunk
162.word 1 // entry thunk
163.symidx func6
164.symidx thunk
165.word 1 // entry thunk
166
167.data
168.rva func
169.rva func2
170.rva func3
171.rva func4
172.rva func5
173.rva func6
174
175// RUN: llvm-mc -filetype=obj -triple=arm64ec-windows test-align.s -o test-align.obj
176// RUN: lld-link -machine:arm64ec -dll -noentry -out:out-align.dll loadcfg.obj test-align.obj
177// RUN: llvm-objdump -d out-align.dll | FileCheck --check-prefix=ALIGN %s
178
179// ALIGN: Disassembly of section .text:
180// ALIGN-EMPTY:
181// ALIGN-NEXT: 0000000180001000 <.text>:
182// ALIGN-NEXT: 180001000: 00000055 udf #0x55
183// ALIGN-NEXT: 180001004: 52800020 mov w0, #0x1 // =1
184// ALIGN-NEXT: 180001008: d503201f nop
185// ALIGN-NEXT: 18000100c: d65f03c0 ret
186// ALIGN-NEXT: 180001010: 0000004d udf #0x4d
187// ALIGN-NEXT: 180001014: 52800040 mov w0, #0x2 // =2
188// ALIGN-NEXT: 180001018: d65f03c0 ret
189// ALIGN-NEXT: 18000101c: 00000039 udf #0x39
190// ALIGN-NEXT: 180001020: 52800060 mov w0, #0x3 // =3
191// ALIGN-NEXT: 180001024: d503201f nop
192// ALIGN-NEXT: 180001028: d65f03c0 ret
193// ALIGN-NEXT: 18000102c: 00000029 udf #0x29
194// ALIGN-NEXT: 180001030: 52800080 mov w0, #0x4 // =4
195// ALIGN-NEXT: 180001034: d65f03c0 ret
196// ALIGN-NEXT: 180001038: 00000000 udf #0x0
197// ALIGN-NEXT: 18000103c: 00000019 udf #0x19
198// ALIGN-NEXT: 180001040: 528000a0 mov w0, #0x5 // =5
199// ALIGN-NEXT: 180001044: d65f03c0 ret
200// ALIGN-NEXT: 180001048: 00000000 udf #0x0
201// ALIGN-NEXT: 18000104c: 00000009 udf #0x9
202// ALIGN-NEXT: 180001050: 528000c0 mov w0, #0x6 // =6
203// ALIGN-NEXT: 180001054: d65f03c0 ret
204// ALIGN-NEXT: 180001058: 52800140 mov w0, #0xa // =10
205// ALIGN-NEXT: 18000105c: d65f03c0 ret
206// ALIGN-NEXT: 180001060: 52800280 mov w0, #0x14 // =20
207// ALIGN-NEXT: 180001064: d65f03c0 ret
208
209#--- test-icf-thunk.s
210// Build two functions with identical entry thunks and check that thunks are merged by ICF.
211
212.section .text,"xr",discard,func
213.globl func
214.p2align 2
215func:
216mov w0, #1
217ret
218
219.section .text,"xr",discard,func2
220.globl func2
221.p2align 2
222func2:
223mov w0, #2
224ret
225
226.section .wowthk$aa,"xr",discard,thunk
227.globl thunk
228.p2align 2
229thunk:
230mov w0, #10
231ret
232
233.section .wowthk$aa,"xr",discard,thunk2
234.globl thunk2
235.p2align 2
236thunk2:
237mov w0, #10
238ret
239
240.section .hybmp$x, "yi"
241.symidx func
242.symidx thunk
243.word 1 // entry thunk
244.symidx func2
245.symidx thunk2
246.word 1 // entry thunk
247
248.data
249.rva func
250.rva func2
251
252// RUN: llvm-mc -filetype=obj -triple=arm64ec-windows test-icf-thunk.s -o test-icf-thunk.obj
253// RUN: lld-link -machine:arm64ec -dll -noentry -out:out-icf-thunk.dll loadcfg.obj test-icf-thunk.obj
254// RUN: llvm-objdump -d out-icf-thunk.dll | FileCheck --check-prefix=ICF-THUNK %s
255
256// ICF-THUNK: Disassembly of section .text:
257// ICF-THUNK-EMPTY:
258// ICF-THUNK-NEXT: 0000000180001000 <.text>:
259// ICF-THUNK-NEXT: 180001000: 00000015 udf #0x15
260// ICF-THUNK-NEXT: 180001004: 52800020 mov w0, #0x1 // =1
261// ICF-THUNK-NEXT: 180001008: d65f03c0 ret
262// ICF-THUNK-NEXT: 18000100c: 00000009 udf #0x9
263// ICF-THUNK-NEXT: 180001010: 52800040 mov w0, #0x2 // =2
264// ICF-THUNK-NEXT: 180001014: d65f03c0 ret
265// ICF-THUNK-NEXT: 180001018: 52800140 mov w0, #0xa // =10
266// ICF-THUNK-NEXT: 18000101c: d65f03c0 ret
267
268#--- test-icf-diff-thunk.s
269// Build two identical functions with different entry thunks and check that they are not merged by ICF.
270
271.section .text,"xr",discard,func
272.globl func
273.p2align 2
274func:
275mov w0, #1
276ret
277
278.section .text,"xr",discard,func2
279.globl func2
280.p2align 2
281func2:
282mov w0, #1
283ret
284
285.section .wowthk$aa,"xr",discard,thunk
286.globl thunk
287.p2align 2
288thunk:
289mov w0, #10
290ret
291
292.section .wowthk$aa,"xr",discard,thunk2
293.globl thunk2
294.p2align 2
295thunk2:
296mov w0, #20
297ret
298
299.section .hybmp$x, "yi"
300.symidx func
301.symidx thunk
302.word 1 // entry thunk
303.symidx func2
304.symidx thunk2
305.word 1 // entry thunk
306
307.data
308.rva func
309.rva func2
310
311// RUN: llvm-mc -filetype=obj -triple=arm64ec-windows test-icf-diff-thunk.s -o test-icf-diff-thunk.obj
312// RUN: lld-link -machine:arm64ec -dll -noentry -out:out-icf-diff-thunk.dll loadcfg.obj test-icf-diff-thunk.obj
313// RUN: llvm-objdump -d out-icf-diff-thunk.dll | FileCheck --check-prefix=ICF-DIFF-THUNK %s
314
315// ICF-DIFF-THUNK: Disassembly of section .text:
316// ICF-DIFF-THUNK-EMPTY:
317// ICF-DIFF-THUNK-NEXT: 0000000180001000 <.text>:
318// ICF-DIFF-THUNK-NEXT: 180001000: 00000015 udf #0x15
319// ICF-DIFF-THUNK-NEXT: 180001004: 52800020 mov w0, #0x1 // =1
320// ICF-DIFF-THUNK-NEXT: 180001008: d65f03c0 ret
321// ICF-DIFF-THUNK-NEXT: 18000100c: 00000011 udf #0x11
322// ICF-DIFF-THUNK-NEXT: 180001010: 52800020 mov w0, #0x1 // =1
323// ICF-DIFF-THUNK-NEXT: 180001014: d65f03c0 ret
324// ICF-DIFF-THUNK-NEXT: 180001018: 52800140 mov w0, #0xa // =10
325// ICF-DIFF-THUNK-NEXT: 18000101c: d65f03c0 ret
326// ICF-DIFF-THUNK-NEXT: 180001020: 52800280 mov w0, #0x14 // =20
327// ICF-DIFF-THUNK-NEXT: 180001024: d65f03c0 ret
328
329#--- test-icf-both.s
330// Build two identical functions with identical entry thunks and check that they are merged by ICF.
331
332.section .text,"xr",discard,func
333.globl func
334.p2align 2
335func:
336mov w0, #1
337ret
338
339.section .text,"xr",discard,func2
340.globl func2
341.p2align 2
342func2:
343mov w0, #1
344ret
345
346.section .wowthk$aa,"xr",discard,thunk
347.globl thunk
348.p2align 2
349thunk:
350mov w0, #10
351ret
352
353.section .wowthk$aa,"xr",discard,thunk2
354.globl thunk2
355.p2align 2
356thunk2:
357mov w0, #10
358ret
359
360.section .hybmp$x, "yi"
361.symidx func
362.symidx thunk
363.word 1 // entry thunk
364.symidx func2
365.symidx thunk2
366.word 1 // entry thunk
367
368.data
369.rva func
370.rva func2
371
372// RUN: llvm-mc -filetype=obj -triple=arm64ec-windows test-icf-both.s -o test-icf-both.obj
373// RUN: lld-link -machine:arm64ec -dll -noentry -out:out-icf-both.dll loadcfg.obj test-icf-both.obj
374// RUN: llvm-objdump -d out-icf-both.dll | FileCheck --check-prefix=DISASM %s
375
376