231 lines · plain
1REQUIRES: aarch64, x862RUN: split-file %s %t.dir && cd %t.dir3 4RUN: llvm-mc -filetype=obj -triple=arm64ec-windows test.s -o test.obj5RUN: llvm-mc -filetype=obj -triple=arm64ec-windows helper-mangled.s -o helper-mangled.obj6RUN: llvm-mc -filetype=obj -triple=arm64ec-windows helper-demangled.s -o helper-demangled.obj7RUN: llvm-mc -filetype=obj -triple=arm64ec-windows %S/Inputs/loadconfig-arm64ec.s -o loadconfig-arm64ec.obj8RUN: llvm-lib -machine:arm64ec -def:test.def -out:test-arm64ec.lib9RUN: llvm-lib -machine:arm64ec -def:test2.def -out:test2-arm64ec.lib10 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 -map13 14RUN: llvm-readobj --hex-dump=.test out.dll | FileCheck --check-prefix=TESTSEC %s15TESTSEC: 0x18000a000 00600000 88700000 00200000 1010000016TESTSEC-NEXT: 0x18000a010 08600000 90700000 10200000 3010000017TESTSEC-NEXT: 0x18000a020 1c100000 3c100000 0030000018 19RUN: llvm-objdump -d out.dll | FileCheck --check-prefix=DISASM %s20DISASM: 0000000180001000 <.text>:21DISASM-NEXT: 80001000: 52800000 mov w0, #0x0 // =022DISASM-NEXT: 180001004: d65f03c0 ret23DISASM-NEXT: 180001008: 52800020 mov w0, #0x1 // =124DISASM-NEXT: 18000100c: d65f03c0 ret25DISASM-NEXT: 180001010: b0000030 adrp x16, 0x18000600026DISASM-NEXT: 180001014: f9400210 ldr x16, [x16]27DISASM-NEXT: 180001018: d61f0200 br x1628DISASM-NEXT: 18000101c: d000002b adrp x11, 0x18000700029DISASM-NEXT: 180001020: f940456b ldr x11, [x11, #0x88]30DISASM-NEXT: 180001024: 9000000a adrp x10, 0x180001000 <.text>31DISASM-NEXT: 180001028: 9101414a add x10, x10, #0x5032DISASM-NEXT: 18000102c: 17fffff5 b 0x180001000 <.text>33DISASM-NEXT: 180001030: b0000030 adrp x16, 0x18000600034DISASM-NEXT: 180001034: f9400610 ldr x16, [x16, #0x8]35DISASM-NEXT: 180001038: d61f0200 br x1636DISASM-NEXT: 18000103c: d000002b adrp x11, 0x18000700037DISASM-NEXT: 180001040: f940496b ldr x11, [x11, #0x90]38DISASM-NEXT: 180001044: 9000000a adrp x10, 0x180001000 <.text>39DISASM-NEXT: 180001048: 9101614a add x10, x10, #0x5840DISASM-NEXT: 18000104c: 17ffffed b 0x180001000 <.text>41DISASM-NEXT: 180001050: 52800040 mov w0, #0x2 // =242DISASM-NEXT: 180001054: d65f03c0 ret43DISASM-NEXT: 180001058: 52800060 mov w0, #0x3 // =344DISASM-NEXT: 18000105c: d65f03c0 ret45DISASM-NEXT: ...46DISASM-NEXT: 180002000: ff 25 82 50 00 00 jmpq *0x5082(%rip) # 0x18000708847DISASM-NEXT: ...48DISASM-NEXT: 18000200e: 00 00 addb %al, (%rax)49DISASM-NEXT: 180002010: ff 25 7a 50 00 00 jmpq *0x507a(%rip) # 0x18000709050DISASM-NEXT: 180002016: 48 8d 05 6b 50 00 00 leaq 0x506b(%rip), %rax # 0x18000708851DISASM-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 # 0x18000709053DISASM-NEXT: 180002029: e9 00 00 00 00 jmp 0x18000202e <.text+0x102e>54DISASM-NEXT: 18000202e: 48 89 4c 24 08 movq %rcx, 0x8(%rsp)55DISASM-NEXT: 180002033: 48 89 54 24 10 movq %rdx, 0x10(%rsp)56DISASM-NEXT: 180002038: 4c 89 44 24 18 movq %r8, 0x18(%rsp)57DISASM-NEXT: 18000203d: 4c 89 4c 24 20 movq %r9, 0x20(%rsp)58DISASM-NEXT: 180002042: 48 83 ec 68 subq $0x68, %rsp59DISASM-NEXT: 180002046: 66 0f 7f 44 24 20 movdqa %xmm0, 0x20(%rsp)60DISASM-NEXT: 18000204c: 66 0f 7f 4c 24 30 movdqa %xmm1, 0x30(%rsp)61DISASM-NEXT: 180002052: 66 0f 7f 54 24 40 movdqa %xmm2, 0x40(%rsp)62DISASM-NEXT: 180002058: 66 0f 7f 5c 24 50 movdqa %xmm3, 0x50(%rsp)63DISASM-NEXT: 18000205e: 48 8b d0 movq %rax, %rdx64DISASM-NEXT: 180002061: 48 8d 0d 90 21 00 00 leaq 0x2190(%rip), %rcx # 0x1800041f865DISASM-NEXT: 180002068: e8 9b ef ff ff callq 0x180001008 <.text+0x8>66DISASM-NEXT: 18000206d: 66 0f 6f 44 24 20 movdqa 0x20(%rsp), %xmm067DISASM-NEXT: 180002073: 66 0f 6f 4c 24 30 movdqa 0x30(%rsp), %xmm168DISASM-NEXT: 180002079: 66 0f 6f 54 24 40 movdqa 0x40(%rsp), %xmm269DISASM-NEXT: 18000207f: 66 0f 6f 5c 24 50 movdqa 0x50(%rsp), %xmm370DISASM-NEXT: 180002085: 48 8b 4c 24 70 movq 0x70(%rsp), %rcx71DISASM-NEXT: 18000208a: 48 8b 54 24 78 movq 0x78(%rsp), %rdx72DISASM-NEXT: 18000208f: 4c 8b 84 24 80 00 00 00 movq 0x80(%rsp), %r873DISASM-NEXT: 180002097: 4c 8b 8c 24 88 00 00 00 movq 0x88(%rsp), %r974DISASM-NEXT: 18000209f: 48 83 c4 68 addq $0x68, %rsp75DISASM-NEXT: 1800020a3: ff e0 jmpq *%rax76 77RUN: llvm-readobj --coff-load-config out.dll | FileCheck --check-prefix=LOADCFG %s78LOADCFG: CHPEMetadata [79LOADCFG: AuxiliaryDelayloadIAT: 0x600080LOADCFG-NEXT: AuxiliaryDelayloadIATCopy: 0x400081 82RUN: llvm-readobj --coff-imports out.dll | FileCheck --check-prefix=IMPORTS %s83IMPORTS: DelayImport {84IMPORTS-NEXT: Name: test.dll85IMPORTS-NEXT: Attributes: 0x186IMPORTS-NEXT: ModuleHandle: 0x708087IMPORTS-NEXT: ImportAddressTable: 0x708888IMPORTS-NEXT: ImportNameTable: 0x423889IMPORTS-NEXT: BoundDelayImportTable: 0x090IMPORTS-NEXT: UnloadDelayImportTable: 0x091IMPORTS-NEXT: Import {92IMPORTS-NEXT: Symbol: func (0)93IMPORTS-NEXT: Address: 0x18000201694IMPORTS-NEXT: }95IMPORTS-NEXT: Import {96IMPORTS-NEXT: Symbol: func2 (0)97IMPORTS-NEXT: Address: 0x18000202298IMPORTS-NEXT: }99IMPORTS-NEXT: }100 101RUN: FileCheck --check-prefix=MAP %s < out.map102MAP: 0001:00000008 #__delayLoadHelper2 0000000180001008 helper-mangled.obj103MAP: 0001:00000010 #func 0000000180001010 test-arm64ec:test.dll104MAP-NEXT: 0001:0000001c __impchk_func 000000018000101c test-arm64ec:test.dll105MAP-NEXT: 0001:00000030 #func2 0000000180001030 test-arm64ec:test.dll106MAP-NEXT: 0001:0000003c __impchk_func2 000000018000103c test-arm64ec:test.dll107MAP-NEXT: 0001:00000050 func_exit_thunk 0000000180001050 test.obj108MAP-NEXT: 0001:00000058 func2_exit_thunk 0000000180001058 test.obj109MAP-NEXT: 0001:00001000 func 0000000180002000 test-arm64ec:test.dll110MAP-NEXT: 0001:00001010 func2 0000000180002010 test-arm64ec:test.dll111MAP-NEXT: 0002:00000000 __imp_data 0000000180003000 test2-arm64ec:test2.dll112MAP-NEXT: 0000:00000000 __hybrid_auxiliary_delayload_iat_copy 0000000180004000 <linker-defined>113MAP-NEXT: 0002:00001000 __auximpcopy_func 0000000180004000 test-arm64ec:test.dll114MAP-NEXT: 0002:00001008 __auximpcopy_func2 0000000180004008 test-arm64ec:test.dll115MAP: 0002:00003000 __imp_func 0000000180006000 test-arm64ec:test.dll116MAP-NEXT: 0002:00003008 __imp_func2 0000000180006008 test-arm64ec:test.dll117MAP: 0003:00000088 __imp_aux_func 0000000180007088 test-arm64ec:test.dll118MAP-NEXT: 0003:00000090 __imp_aux_func2 0000000180007090 test-arm64ec:test.dll119 120RUN: llvm-readobj --hex-dump=.rdata out.dll | FileCheck --check-prefix=RDATA %s121RDATA: 0x180004000 1c100080 01000000 3c100080 01000000122RDATA-NEXT: 0x180004010 00000000 00000000123RDATA: 0x180006000 1c100080 01000000 3c100080 01000000124RDATA-NEXT: 0x180006010 00000000 00000000125 126RUN: llvm-readobj --coff-basereloc out.dll | FileCheck --check-prefix=RELOC %s127RELOC: BaseReloc [128RELOC-NEXT: Entry {129RELOC-NEXT: Type: DIR64130RELOC-NEXT: Address: 0x4000131RELOC-NEXT: }132RELOC-NEXT: Entry {133RELOC-NEXT: Type: DIR64134RELOC-NEXT: Address: 0x4008135RELOC-NEXT: }136RELOC: Address: 0x6000137RELOC-NEXT: }138RELOC-NEXT: Entry {139RELOC-NEXT: Type: DIR64140RELOC-NEXT: Address: 0x6008141RELOC-NEXT: }142 143RUN: llvm-readobj --hex-dump=.pdata out.dll | FileCheck --check-prefix=PDATA %s144PDATA: 0x180008000 2e200000 a5200000 18400000145 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.dll150RUN: llvm-objdump -d out2.dll | FileCheck --check-prefix=DISASM %s151 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 in154the archive index, so we need to locate it by its mangled name.155 156RUN: llvm-lib -machine:arm64ec -out:helper.lib helper-mangled.obj157RUN: 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.dll159RUN: llvm-objdump -d out3.dll | FileCheck --check-prefix=DISASM %s160 161#--- test.s162 .section .test,"r"163 .rva __imp_func164 .rva __imp_aux_func165 .rva func166 .rva "#func"167 .rva __imp_func2168 .rva __imp_aux_func2169 .rva func2170 .rva "#func2"171 .rva __impchk_func172 .rva __impchk_func2173 .rva __imp_data174 175 .section .text,"xr",discard,__icall_helper_arm64ec176 .globl __icall_helper_arm64ec177 .p2align 2, 0x0178__icall_helper_arm64ec:179 mov w0, #0180 ret181 182 .section .hybmp$x, "yi"183 .symidx __imp_func184 .symidx func_exit_thunk185 .word 4186 .symidx __imp_func2187 .symidx func2_exit_thunk188 .word 4189 190 .section .wowthk$aa,"xr",discard,func_exit_thunk191 .globl func_exit_thunk192func_exit_thunk:193 mov w0, #2194 ret195 196 .section .wowthk$aa,"xr",discard,func2_exit_thunk197 .globl func2_exit_thunk198func2_exit_thunk:199 mov w0, #3200 ret201 202#--- helper-mangled.s203 .section .text,"xr",discard,"#__delayLoadHelper2"204 .globl "#__delayLoadHelper2"205 .p2align 2, 0x0206"#__delayLoadHelper2":207 mov w0, #1208 ret209 210 .weak_anti_dep __delayLoadHelper2211.set __delayLoadHelper2,"#__delayLoadHelper2"212 213#--- helper-demangled.s214 .section .text,"xr",discard,__delayLoadHelper2215 .globl __delayLoadHelper2216 .p2align 2, 0x0217__delayLoadHelper2:218 mov w0, #1219 ret220 221#--- test.def222NAME test.dll223EXPORTS224 func225 func2226 227#--- test2.def228NAME test2.dll229EXPORTS230 data DATA231