1REQUIRES: aarch64, x86 2RUN: split-file %s %t.dir && cd %t.dir 3 4RUN: llvm-mc -filetype=obj -triple=arm64ec-windows test.s -o test.obj 5RUN: llvm-mc -filetype=obj -triple=arm64ec-windows helper-mangled.s -o helper-mangled.obj 6RUN: llvm-mc -filetype=obj -triple=arm64ec-windows helper-demangled.s -o helper-demangled.obj 7RUN: llvm-mc -filetype=obj -triple=arm64ec-windows %S/Inputs/loadconfig-arm64ec.s -o loadconfig-arm64ec.obj 8RUN: llvm-lib -machine:arm64ec -def:test.def -out:test-arm64ec.lib 9RUN: llvm-lib -machine:arm64ec -def:test2.def -out:test2-arm64ec.lib 10 11RUN: lld-link -machine:arm64ec -dll -noentry -out:out.dll loadconfig-arm64ec.obj test.obj \ 12RUN: helper-mangled.obj test-arm64ec.lib test2-arm64ec.lib -delayload:test.dll -map 13 14RUN: llvm-readobj --hex-dump=.test out.dll | FileCheck --check-prefix=TESTSEC %s 15TESTSEC: 0x18000a000 00600000 88700000 00200000 10100000 16TESTSEC-NEXT: 0x18000a010 08600000 90700000 10200000 30100000 17TESTSEC-NEXT: 0x18000a020 1c100000 3c100000 00300000 18 19RUN: llvm-objdump -d out.dll | FileCheck --check-prefix=DISASM %s 20DISASM: 0000000180001000 <.text>: 21DISASM-NEXT: 80001000: 52800000 mov w0, #0x0 // =0 22DISASM-NEXT: 180001004: d65f03c0 ret 23DISASM-NEXT: 180001008: 52800020 mov w0, #0x1 // =1 24DISASM-NEXT: 18000100c: d65f03c0 ret 25DISASM-NEXT: 180001010: b0000030 adrp x16, 0x180006000 26DISASM-NEXT: 180001014: f9400210 ldr x16, [x16] 27DISASM-NEXT: 180001018: d61f0200 br x16 28DISASM-NEXT: 18000101c: d000002b adrp x11, 0x180007000 29DISASM-NEXT: 180001020: f940456b ldr x11, [x11, #0x88] 30DISASM-NEXT: 180001024: 9000000a adrp x10, 0x180001000 <.text> 31DISASM-NEXT: 180001028: 9101414a add x10, x10, #0x50 32DISASM-NEXT: 18000102c: 17fffff5 b 0x180001000 <.text> 33DISASM-NEXT: 180001030: b0000030 adrp x16, 0x180006000 34DISASM-NEXT: 180001034: f9400610 ldr x16, [x16, #0x8] 35DISASM-NEXT: 180001038: d61f0200 br x16 36DISASM-NEXT: 18000103c: d000002b adrp x11, 0x180007000 37DISASM-NEXT: 180001040: f940496b ldr x11, [x11, #0x90] 38DISASM-NEXT: 180001044: 9000000a adrp x10, 0x180001000 <.text> 39DISASM-NEXT: 180001048: 9101614a add x10, x10, #0x58 40DISASM-NEXT: 18000104c: 17ffffed b 0x180001000 <.text> 41DISASM-NEXT: 180001050: 52800040 mov w0, #0x2 // =2 42DISASM-NEXT: 180001054: d65f03c0 ret 43DISASM-NEXT: 180001058: 52800060 mov w0, #0x3 // =3 44DISASM-NEXT: 18000105c: d65f03c0 ret 45DISASM-NEXT: ... 46DISASM-NEXT: 180002000: ff 25 82 50 00 00 jmpq *0x5082(%rip) # 0x180007088 47DISASM-NEXT: ... 48DISASM-NEXT: 18000200e: 00 00 addb %al, (%rax) 49DISASM-NEXT: 180002010: ff 25 7a 50 00 00 jmpq *0x507a(%rip) # 0x180007090 50DISASM-NEXT: 180002016: 48 8d 05 6b 50 00 00 leaq 0x506b(%rip), %rax # 0x180007088 51DISASM-NEXT: 18000201d: e9 0c 00 00 00 jmp 0x18000202e <.text+0x102e> 52DISASM-NEXT: 180002022: 48 8d 05 67 50 00 00 leaq 0x5067(%rip), %rax # 0x180007090 53DISASM-NEXT: 180002029: e9 00 00 00 00 jmp 0x18000202e <.text+0x102e> 54DISASM-NEXT: 18000202e: 51 pushq %rcx 55DISASM-NEXT: 18000202f: 52 pushq %rdx 56DISASM-NEXT: 180002030: 41 50 pushq %r8 57DISASM-NEXT: 180002032: 41 51 pushq %r9 58DISASM-NEXT: 180002034: 48 83 ec 48 subq $0x48, %rsp 59DISASM-NEXT: 180002038: 66 0f 7f 04 24 movdqa %xmm0, (%rsp) 60DISASM-NEXT: 18000203d: 66 0f 7f 4c 24 10 movdqa %xmm1, 0x10(%rsp) 61DISASM-NEXT: 180002043: 66 0f 7f 54 24 20 movdqa %xmm2, 0x20(%rsp) 62DISASM-NEXT: 180002049: 66 0f 7f 5c 24 30 movdqa %xmm3, 0x30(%rsp) 63DISASM-NEXT: 18000204f: 48 8b d0 movq %rax, %rdx 64DISASM-NEXT: 180002052: 48 8d 0d a7 21 00 00 leaq 0x21a7(%rip), %rcx # 0x180004200 65DISASM-NEXT: 180002059: e8 aa ef ff ff callq 0x180001008 <.text+0x8> 66DISASM-NEXT: 18000205e: 66 0f 6f 04 24 movdqa (%rsp), %xmm0 67DISASM-NEXT: 180002063: 66 0f 6f 4c 24 10 movdqa 0x10(%rsp), %xmm1 68DISASM-NEXT: 180002069: 66 0f 6f 54 24 20 movdqa 0x20(%rsp), %xmm2 69DISASM-NEXT: 18000206f: 66 0f 6f 5c 24 30 movdqa 0x30(%rsp), %xmm3 70DISASM-NEXT: 180002075: 48 83 c4 48 addq $0x48, %rsp 71DISASM-NEXT: 180002079: 41 59 popq %r9 72DISASM-NEXT: 18000207b: 41 58 popq %r8 73DISASM-NEXT: 18000207d: 5a popq %rdx 74DISASM-NEXT: 18000207e: 59 popq %rcx 75DISASM-NEXT: 18000207f: ff e0 jmpq *%rax 76 77RUN: llvm-readobj --coff-load-config out.dll | FileCheck --check-prefix=LOADCFG %s 78LOADCFG: CHPEMetadata [ 79LOADCFG: AuxiliaryDelayloadIAT: 0x6000 80LOADCFG-NEXT: AuxiliaryDelayloadIATCopy: 0x4000 81 82RUN: llvm-readobj --coff-imports out.dll | FileCheck --check-prefix=IMPORTS %s 83IMPORTS: DelayImport { 84IMPORTS-NEXT: Name: test.dll 85IMPORTS-NEXT: Attributes: 0x1 86IMPORTS-NEXT: ModuleHandle: 0x7080 87IMPORTS-NEXT: ImportAddressTable: 0x7088 88IMPORTS-NEXT: ImportNameTable: 0x4240 89IMPORTS-NEXT: BoundDelayImportTable: 0x0 90IMPORTS-NEXT: UnloadDelayImportTable: 0x0 91IMPORTS-NEXT: Import { 92IMPORTS-NEXT: Symbol: func (0) 93IMPORTS-NEXT: Address: 0x180002016 94IMPORTS-NEXT: } 95IMPORTS-NEXT: Import { 96IMPORTS-NEXT: Symbol: func2 (0) 97IMPORTS-NEXT: Address: 0x180002022 98IMPORTS-NEXT: } 99IMPORTS-NEXT: } 100 101RUN: FileCheck --check-prefix=MAP %s < out.map 102MAP: 0001:00000008 #__delayLoadHelper2 0000000180001008 helper-mangled.obj 103MAP: 0001:00000010 #func 0000000180001010 test-arm64ec:test.dll 104MAP-NEXT: 0001:0000001c __impchk_func 000000018000101c test-arm64ec:test.dll 105MAP-NEXT: 0001:00000030 #func2 0000000180001030 test-arm64ec:test.dll 106MAP-NEXT: 0001:0000003c __impchk_func2 000000018000103c test-arm64ec:test.dll 107MAP-NEXT: 0001:00000050 func_exit_thunk 0000000180001050 test.obj 108MAP-NEXT: 0001:00000058 func2_exit_thunk 0000000180001058 test.obj 109MAP-NEXT: 0001:00001000 func 0000000180002000 test-arm64ec:test.dll 110MAP-NEXT: 0001:00001010 func2 0000000180002010 test-arm64ec:test.dll 111MAP-NEXT: 0002:00000000 __imp_data 0000000180003000 test2-arm64ec:test2.dll 112MAP-NEXT: 0000:00000000 __hybrid_auxiliary_delayload_iat_copy 0000000180004000 <linker-defined> 113MAP-NEXT: 0002:00001000 __auximpcopy_func 0000000180004000 test-arm64ec:test.dll 114MAP-NEXT: 0002:00001008 __auximpcopy_func2 0000000180004008 test-arm64ec:test.dll 115MAP: 0002:00003000 __imp_func 0000000180006000 test-arm64ec:test.dll 116MAP-NEXT: 0002:00003008 __imp_func2 0000000180006008 test-arm64ec:test.dll 117MAP: 0003:00000088 __imp_aux_func 0000000180007088 test-arm64ec:test.dll 118MAP-NEXT: 0003:00000090 __imp_aux_func2 0000000180007090 test-arm64ec:test.dll 119 120RUN: llvm-readobj --hex-dump=.rdata out.dll | FileCheck --check-prefix=RDATA %s 121RDATA: 0x180004000 1c100080 01000000 3c100080 01000000 122RDATA-NEXT: 0x180004010 00000000 00000000 123RDATA: 0x180006000 1c100080 01000000 3c100080 01000000 124RDATA-NEXT: 0x180006010 00000000 00000000 125 126RUN: llvm-readobj --coff-basereloc out.dll | FileCheck --check-prefix=RELOC %s 127RELOC: BaseReloc [ 128RELOC-NEXT: Entry { 129RELOC-NEXT: Type: DIR64 130RELOC-NEXT: Address: 0x4000 131RELOC-NEXT: } 132RELOC-NEXT: Entry { 133RELOC-NEXT: Type: DIR64 134RELOC-NEXT: Address: 0x4008 135RELOC-NEXT: } 136RELOC: Address: 0x6000 137RELOC-NEXT: } 138RELOC-NEXT: Entry { 139RELOC-NEXT: Type: DIR64 140RELOC-NEXT: Address: 0x6008 141RELOC-NEXT: } 142 143RUN: llvm-readobj --hex-dump=.pdata out.dll | FileCheck --check-prefix=PDATA %s 144PDATA: 0x180008000 2e200000 81200000 18400000 145 146Verify that a demangled version of __delayLoadHelper2 can be used. 147 148RUN: lld-link -machine:arm64ec -dll -noentry -out:out2.dll loadconfig-arm64ec.obj test.obj \ 149RUN: helper-demangled.obj test-arm64ec.lib test2-arm64ec.lib -delayload:test.dll 150RUN: llvm-objdump -d out2.dll | FileCheck --check-prefix=DISASM %s 151 152Verify that the mangled version of __delayLoadHelper2 can be used from a library. 153Even if an anti-dependency alias is defined by the helper, it won't appear in 154the archive index, so we need to locate it by its mangled name. 155 156RUN: llvm-lib -machine:arm64ec -out:helper.lib helper-mangled.obj 157RUN: lld-link -machine:arm64ec -dll -noentry -out:out3.dll loadconfig-arm64ec.obj test.obj \ 158RUN: helper.lib test-arm64ec.lib test2-arm64ec.lib -delayload:test.dll 159RUN: llvm-objdump -d out3.dll | FileCheck --check-prefix=DISASM %s 160 161#--- test.s 162 .section .test,"r" 163 .rva __imp_func 164 .rva __imp_aux_func 165 .rva func 166 .rva "#func" 167 .rva __imp_func2 168 .rva __imp_aux_func2 169 .rva func2 170 .rva "#func2" 171 .rva __impchk_func 172 .rva __impchk_func2 173 .rva __imp_data 174 175 .section .text,"xr",discard,__icall_helper_arm64ec 176 .globl __icall_helper_arm64ec 177 .p2align 2, 0x0 178__icall_helper_arm64ec: 179 mov w0, #0 180 ret 181 182 .section .hybmp$x, "yi" 183 .symidx __imp_func 184 .symidx func_exit_thunk 185 .word 4 186 .symidx __imp_func2 187 .symidx func2_exit_thunk 188 .word 4 189 190 .section .wowthk$aa,"xr",discard,func_exit_thunk 191 .globl func_exit_thunk 192func_exit_thunk: 193 mov w0, #2 194 ret 195 196 .section .wowthk$aa,"xr",discard,func2_exit_thunk 197 .globl func2_exit_thunk 198func2_exit_thunk: 199 mov w0, #3 200 ret 201 202#--- helper-mangled.s 203 .section .text,"xr",discard,"#__delayLoadHelper2" 204 .globl "#__delayLoadHelper2" 205 .p2align 2, 0x0 206"#__delayLoadHelper2": 207 mov w0, #1 208 ret 209 210 .weak_anti_dep __delayLoadHelper2 211.set __delayLoadHelper2,"#__delayLoadHelper2" 212 213#--- helper-demangled.s 214 .section .text,"xr",discard,__delayLoadHelper2 215 .globl __delayLoadHelper2 216 .p2align 2, 0x0 217__delayLoadHelper2: 218 mov w0, #1 219 ret 220 221#--- test.def 222NAME test.dll 223EXPORTS 224 func 225 func2 226 227#--- test2.def 228NAME test2.dll 229EXPORTS 230 data DATA 231