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