377 lines · plain
1// REQUIRES: aarch642// RUN: split-file %s %t.dir && cd %t.dir3 4#--- test-simple.s5// Build a simple function with an entry thunk.6 7 .section .text,"xr",discard,func8 .globl func9 .p2align 210func:11 mov w0, #112 ret13 14 .section .wowthk$aa,"xr",discard,thunk15 .globl thunk16 .p2align 217thunk:18 mov w0, #1019 ret20 21 .section .hybmp$x, "yi"22 .symidx func23 .symidx thunk24 .word 1 // entry thunk25 26 .data27 .rva func28 29// RUN: llvm-mc -filetype=obj -triple=arm64ec-windows %S/Inputs/loadconfig-arm64ec.s -o loadcfg.obj30// RUN: llvm-mc -filetype=obj -triple=aarch64-windows %S/Inputs/loadconfig-arm64.s -o native-loadcfg.obj31// RUN: llvm-mc -filetype=obj -triple=arm64ec-windows test-simple.s -o test-simple.obj32// RUN: lld-link -machine:arm64ec -dll -noentry -out:out-simple.dll loadcfg.obj test-simple.obj33// RUN: llvm-objdump -d out-simple.dll | FileCheck --check-prefix=DISASM %s34 35// DISASM: Disassembly of section .text:36// DISASM-EMPTY:37// DISASM-NEXT: 0000000180001000 <.text>:38// DISASM-NEXT: 180001000: 00000009 udf #0x939// DISASM-NEXT: 180001004: 52800020 mov w0, #0x1 // =140// DISASM-NEXT: 180001008: d65f03c0 ret41// DISASM-NEXT: 18000100c: 52800140 mov w0, #0xa // =1042// DISASM-NEXT: 180001010: d65f03c0 ret43 44// RUN: llvm-readobj --sections out-simple.dll | FileCheck --check-prefix=HYBMP %s45// HYBMP-NOT: .hybmp46 47// RUN: lld-link -machine:arm64x -dll -noentry -out:out-simplex.dll native-loadcfg.obj loadcfg.obj test-simple.obj48// RUN: llvm-objdump -d out-simplex.dll | FileCheck --check-prefix=DISASM %s49 50#--- test-split-func.s51// Build a simple function with an entry thunk, but pass it in multiple files.52 53 .section .text,"xr",discard,func54 .globl func55 .p2align 256func:57 mov w0, #158 ret59 60#--- test-split-thunk.s61 .section .wowthk$aa,"xr",discard,thunk62 .globl thunk63 .p2align 264thunk:65 mov w0, #1066 ret67 68#--- test-split-hybmp.s69 .section .hybmp$x, "yi"70 .symidx func71 .symidx thunk72 .word 1 // entry thunk73 74#--- test-split-data.s75 .data76 .rva func77 78// RUN: llvm-mc -filetype=obj -triple=arm64ec-windows test-split-func.s -o test-split-func.obj79// RUN: llvm-mc -filetype=obj -triple=arm64ec-windows test-split-thunk.s -o test-split-thunk.obj80// RUN: llvm-mc -filetype=obj -triple=arm64ec-windows test-split-hybmp.s -o test-split-hybmp.obj81// RUN: llvm-mc -filetype=obj -triple=arm64ec-windows test-split-data.s -o test-split-data.obj82// RUN: lld-link -machine:arm64ec -dll -noentry -out:out-split.dll loadcfg.obj \83// RUN: test-split-func.obj test-split-thunk.obj test-split-data.obj test-split-hybmp.obj84// RUN: llvm-objdump -d out-split.dll | FileCheck --check-prefix=DISASM %s85 86#--- test-align.s87// Build multiple functions with thunks and various alignments and check that entry thunk offsets88// are correctly placed.89 90 .section .text,"xr",discard,func91 .globl func92 .p2align 293func:94 mov w0, #195 nop96 ret97 98 .section .text,"xr",discard,func299 .globl func2100 .p2align 2101func2:102 mov w0, #2103 ret104 105 .section .text,"xr",discard,func3106 .globl func3107 .p2align 3108func3:109 mov w0, #3110 nop111 ret112 113 .section .text,"xr",discard,func4114 .globl func4115 .p2align 3116func4:117 mov w0, #4118 ret119 120 .section .text,"xr",discard,func5121 .globl func5122 .p2align 3123func5:124 mov w0, #5125 ret126 127 .section .text,"xr",discard,func6128 .globl func6129 .p2align 4130func6:131 mov w0, #6132 ret133 134 .section .wowthk$aa,"xr",discard,thunk135 .globl thunk136 .p2align 2137thunk:138 mov w0, #10139 ret140 141 .section .wowthk$aa,"xr",discard,thunk2142 .globl thunk2143 .p2align 2144thunk2:145 mov w0, #20146 ret147 148 .section .hybmp$x, "yi"149 .symidx func150 .symidx thunk151 .word 1 // entry thunk152 .symidx func2153 .symidx thunk2154 .word 1 // entry thunk155 .symidx func3156 .symidx thunk157 .word 1 // entry thunk158 .symidx func4159 .symidx thunk160 .word 1 // entry thunk161 .symidx func5162 .symidx thunk163 .word 1 // entry thunk164 .symidx func6165 .symidx thunk166 .word 1 // entry thunk167 168 .data169 .rva func170 .rva func2171 .rva func3172 .rva func4173 .rva func5174 .rva func6175 176// RUN: llvm-mc -filetype=obj -triple=arm64ec-windows test-align.s -o test-align.obj177// RUN: lld-link -machine:arm64ec -dll -noentry -out:out-align.dll loadcfg.obj test-align.obj178// RUN: llvm-objdump -d out-align.dll | FileCheck --check-prefix=ALIGN %s179 180// ALIGN: Disassembly of section .text:181// ALIGN-EMPTY:182// ALIGN-NEXT: 0000000180001000 <.text>:183// ALIGN-NEXT: 180001000: 00000055 udf #0x55184// ALIGN-NEXT: 180001004: 52800020 mov w0, #0x1 // =1185// ALIGN-NEXT: 180001008: d503201f nop186// ALIGN-NEXT: 18000100c: d65f03c0 ret187// ALIGN-NEXT: 180001010: 0000004d udf #0x4d188// ALIGN-NEXT: 180001014: 52800040 mov w0, #0x2 // =2189// ALIGN-NEXT: 180001018: d65f03c0 ret190// ALIGN-NEXT: 18000101c: 00000039 udf #0x39191// ALIGN-NEXT: 180001020: 52800060 mov w0, #0x3 // =3192// ALIGN-NEXT: 180001024: d503201f nop193// ALIGN-NEXT: 180001028: d65f03c0 ret194// ALIGN-NEXT: 18000102c: 00000029 udf #0x29195// ALIGN-NEXT: 180001030: 52800080 mov w0, #0x4 // =4196// ALIGN-NEXT: 180001034: d65f03c0 ret197// ALIGN-NEXT: 180001038: 00000000 udf #0x0198// ALIGN-NEXT: 18000103c: 00000019 udf #0x19199// ALIGN-NEXT: 180001040: 528000a0 mov w0, #0x5 // =5200// ALIGN-NEXT: 180001044: d65f03c0 ret201// ALIGN-NEXT: 180001048: 00000000 udf #0x0202// ALIGN-NEXT: 18000104c: 00000009 udf #0x9203// ALIGN-NEXT: 180001050: 528000c0 mov w0, #0x6 // =6204// ALIGN-NEXT: 180001054: d65f03c0 ret205// ALIGN-NEXT: 180001058: 52800140 mov w0, #0xa // =10206// ALIGN-NEXT: 18000105c: d65f03c0 ret207// ALIGN-NEXT: 180001060: 52800280 mov w0, #0x14 // =20208// ALIGN-NEXT: 180001064: d65f03c0 ret209 210#--- test-icf-thunk.s211// Build two functions with identical entry thunks and check that thunks are merged by ICF.212 213 .section .text,"xr",discard,func214 .globl func215 .p2align 2216func:217 mov w0, #1218 ret219 220 .section .text,"xr",discard,func2221 .globl func2222 .p2align 2223func2:224 mov w0, #2225 ret226 227 .section .wowthk$aa,"xr",discard,thunk228 .globl thunk229 .p2align 2230thunk:231 mov w0, #10232 ret233 234 .section .wowthk$aa,"xr",discard,thunk2235 .globl thunk2236 .p2align 2237thunk2:238 mov w0, #10239 ret240 241 .section .hybmp$x, "yi"242 .symidx func243 .symidx thunk244 .word 1 // entry thunk245 .symidx func2246 .symidx thunk2247 .word 1 // entry thunk248 249 .data250 .rva func251 .rva func2252 253// RUN: llvm-mc -filetype=obj -triple=arm64ec-windows test-icf-thunk.s -o test-icf-thunk.obj254// RUN: lld-link -machine:arm64ec -dll -noentry -out:out-icf-thunk.dll loadcfg.obj test-icf-thunk.obj255// RUN: llvm-objdump -d out-icf-thunk.dll | FileCheck --check-prefix=ICF-THUNK %s256 257// ICF-THUNK: Disassembly of section .text:258// ICF-THUNK-EMPTY:259// ICF-THUNK-NEXT: 0000000180001000 <.text>:260// ICF-THUNK-NEXT: 180001000: 00000015 udf #0x15261// ICF-THUNK-NEXT: 180001004: 52800020 mov w0, #0x1 // =1262// ICF-THUNK-NEXT: 180001008: d65f03c0 ret263// ICF-THUNK-NEXT: 18000100c: 00000009 udf #0x9264// ICF-THUNK-NEXT: 180001010: 52800040 mov w0, #0x2 // =2265// ICF-THUNK-NEXT: 180001014: d65f03c0 ret266// ICF-THUNK-NEXT: 180001018: 52800140 mov w0, #0xa // =10267// ICF-THUNK-NEXT: 18000101c: d65f03c0 ret268 269#--- test-icf-diff-thunk.s270// Build two identical functions with different entry thunks and check that they are not merged by ICF.271 272 .section .text,"xr",discard,func273 .globl func274 .p2align 2275func:276 mov w0, #1277 ret278 279 .section .text,"xr",discard,func2280 .globl func2281 .p2align 2282func2:283 mov w0, #1284 ret285 286 .section .wowthk$aa,"xr",discard,thunk287 .globl thunk288 .p2align 2289thunk:290 mov w0, #10291 ret292 293 .section .wowthk$aa,"xr",discard,thunk2294 .globl thunk2295 .p2align 2296thunk2:297 mov w0, #20298 ret299 300 .section .hybmp$x, "yi"301 .symidx func302 .symidx thunk303 .word 1 // entry thunk304 .symidx func2305 .symidx thunk2306 .word 1 // entry thunk307 308 .data309 .rva func310 .rva func2311 312// RUN: llvm-mc -filetype=obj -triple=arm64ec-windows test-icf-diff-thunk.s -o test-icf-diff-thunk.obj313// RUN: lld-link -machine:arm64ec -dll -noentry -out:out-icf-diff-thunk.dll loadcfg.obj test-icf-diff-thunk.obj314// RUN: llvm-objdump -d out-icf-diff-thunk.dll | FileCheck --check-prefix=ICF-DIFF-THUNK %s315 316// ICF-DIFF-THUNK: Disassembly of section .text:317// ICF-DIFF-THUNK-EMPTY:318// ICF-DIFF-THUNK-NEXT: 0000000180001000 <.text>:319// ICF-DIFF-THUNK-NEXT: 180001000: 00000015 udf #0x15320// ICF-DIFF-THUNK-NEXT: 180001004: 52800020 mov w0, #0x1 // =1321// ICF-DIFF-THUNK-NEXT: 180001008: d65f03c0 ret322// ICF-DIFF-THUNK-NEXT: 18000100c: 00000011 udf #0x11323// ICF-DIFF-THUNK-NEXT: 180001010: 52800020 mov w0, #0x1 // =1324// ICF-DIFF-THUNK-NEXT: 180001014: d65f03c0 ret325// ICF-DIFF-THUNK-NEXT: 180001018: 52800140 mov w0, #0xa // =10326// ICF-DIFF-THUNK-NEXT: 18000101c: d65f03c0 ret327// ICF-DIFF-THUNK-NEXT: 180001020: 52800280 mov w0, #0x14 // =20328// ICF-DIFF-THUNK-NEXT: 180001024: d65f03c0 ret329 330#--- test-icf-both.s331// Build two identical functions with identical entry thunks and check that they are merged by ICF.332 333 .section .text,"xr",discard,func334 .globl func335 .p2align 2336func:337 mov w0, #1338 ret339 340 .section .text,"xr",discard,func2341 .globl func2342 .p2align 2343func2:344 mov w0, #1345 ret346 347 .section .wowthk$aa,"xr",discard,thunk348 .globl thunk349 .p2align 2350thunk:351 mov w0, #10352 ret353 354 .section .wowthk$aa,"xr",discard,thunk2355 .globl thunk2356 .p2align 2357thunk2:358 mov w0, #10359 ret360 361 .section .hybmp$x, "yi"362 .symidx func363 .symidx thunk364 .word 1 // entry thunk365 .symidx func2366 .symidx thunk2367 .word 1 // entry thunk368 369 .data370 .rva func371 .rva func2372 373// RUN: llvm-mc -filetype=obj -triple=arm64ec-windows test-icf-both.s -o test-icf-both.obj374// RUN: lld-link -machine:arm64ec -dll -noentry -out:out-icf-both.dll loadcfg.obj test-icf-both.obj375// RUN: llvm-objdump -d out-icf-both.dll | FileCheck --check-prefix=DISASM %s376 377