REQUIRES: aarch64, x86
RUN: split-file %s %t.dir && cd %t.dir

RUN: llvm-mc -filetype=obj -triple=arm64ec-windows test-arm64ec.s -o test-arm64ec.obj
RUN: llvm-mc -filetype=obj -triple=aarch64-windows test-arm64.s -o test-arm64.obj
RUN: llvm-mc -filetype=obj -triple=arm64ec-windows arm64ec-helper.s -o arm64ec-helper.obj
RUN: llvm-mc -filetype=obj -triple=aarch64-windows arm64-helper.s -o arm64-helper.obj
RUN: llvm-mc -filetype=obj -triple=arm64ec-windows %S/Inputs/loadconfig-arm64ec.s -o loadconfig-arm64ec.obj
RUN: llvm-mc -filetype=obj -triple=aarch64-windows %S/Inputs/loadconfig-arm64.s -o loadconfig-arm64.obj
RUN: llvm-lib -machine:arm64ec -def:test.def -out:test-arm64ec.lib
RUN: llvm-lib -machine:arm64 -def:test.def -out:test-arm64.lib

# Test delayed-load import from both native and EC code.

RUN: lld-link -machine:arm64x -dll -noentry -out:out.dll loadconfig-arm64.obj loadconfig-arm64ec.obj \
RUN:          arm64-helper.obj arm64ec-helper.obj test-arm64.obj test-arm64ec.obj test-arm64.lib test-arm64ec.lib -delayload:test.dll

RUN: llvm-readobj --coff-imports out.dll | FileCheck --check-prefix=IMPORTS %s
IMPORTS:      DelayImport {
IMPORTS-NEXT:   Name: test.dll
IMPORTS-NEXT:   Attributes: 0x1
IMPORTS-NEXT:   ModuleHandle: 0x6080
IMPORTS-NEXT:   ImportAddressTable: 0x6088
IMPORTS-NEXT:   ImportNameTable: 0x4388
IMPORTS-NEXT:   BoundDelayImportTable: 0x0
IMPORTS-NEXT:   UnloadDelayImportTable: 0x0
IMPORTS-NEXT:   Import {
IMPORTS-NEXT:     Symbol: func (0)
IMPORTS-NEXT:     Address: 0x180001014
IMPORTS-NEXT:   }
IMPORTS-NEXT: }
IMPORTS-NEXT: HybridObject {
IMPORTS:        DelayImport {
IMPORTS-NEXT:     Name: test.dll
IMPORTS-NEXT:     Attributes: 0x1
IMPORTS-NEXT:     ModuleHandle: 0x6080
IMPORTS-NEXT:     ImportAddressTable: 0x6098
IMPORTS-NEXT:     ImportNameTable: 0x4398
IMPORTS-NEXT:     BoundDelayImportTable: 0x0
IMPORTS-NEXT:     UnloadDelayImportTable: 0x0
IMPORTS-NEXT:     Import {
IMPORTS-NEXT:       Symbol: func (0)
IMPORTS-NEXT:       Address: 0x180003006
IMPORTS-NEXT:     }
IMPORTS-NEXT:   }
IMPORTS-NEXT: }

RUN: llvm-readobj --hex-dump=.test out.dll | FileCheck --check-prefix=TESTSEC %s
TESTSEC: 0x180009000 10500000 98600000 00300000 10200000

RUN: llvm-readobj --hex-dump=.testa out.dll | FileCheck --check-prefix=TESTSECA %s
TESTSECA: 0x18000a000 88600000 08100000

RUN: llvm-objdump -d out.dll | FileCheck --check-prefix=DISASM %s
DISASM:      0000000180001000 <.text>:
DISASM-NEXT: 180001000: 52800060     mov     w0, #0x3                // =3
DISASM-NEXT: 180001004: d65f03c0     ret
DISASM-NEXT: 180001008: b0000030     adrp    x16, 0x180006000
DISASM-NEXT: 18000100c: f9404610     ldr     x16, [x16, #0x88]
DISASM-NEXT: 180001010: d61f0200     br      x16
DISASM-NEXT: 180001014: b0000031     adrp    x17, 0x180006000
DISASM-NEXT: 180001018: 91022231     add     x17, x17, #0x88
DISASM-NEXT: 18000101c: 14000001     b       0x180001020 <.text+0x20>
DISASM-NEXT: 180001020: a9b27bfd     stp     x29, x30, [sp, #-0xe0]!
DISASM-NEXT: 180001024: 910003fd     mov     x29, sp
DISASM-NEXT: 180001028: a90107e0     stp     x0, x1, [sp, #0x10]
DISASM-NEXT: 18000102c: a9020fe2     stp     x2, x3, [sp, #0x20]
DISASM-NEXT: 180001030: a90317e4     stp     x4, x5, [sp, #0x30]
DISASM-NEXT: 180001034: a9041fe6     stp     x6, x7, [sp, #0x40]
DISASM-NEXT: 180001038: f9002be8     str     x8,     [sp, #0x50]
DISASM-NEXT: 18000103c: ad0307e0     stp     q0, q1, [sp, #0x60]
DISASM-NEXT: 180001040: ad040fe2     stp     q2, q3, [sp, #0x80]
DISASM-NEXT: 180001044: ad0517e4     stp     q4, q5, [sp, #0xa0]
DISASM-NEXT: 180001048: ad061fe6     stp     q6, q7, [sp, #0xc0]
DISASM-NEXT: 18000104c: aa1103e1     mov     x1, x17
DISASM-NEXT: 180001050: f0000000     adrp    x0, 0x180004000
DISASM-NEXT: 180001054: 910d2000     add     x0, x0, #0x348
DISASM-NEXT: 180001058: 90000002     adrp    x2, 0x180001000 <.text>
DISASM-NEXT: 18000105c: 91000042     add     x2, x2, #0x0
DISASM-NEXT: 180001060: d63f0040     blr     x2
DISASM-NEXT: 180001064: aa0003f0     mov     x16, x0
DISASM-NEXT: 180001068: ad461fe6     ldp     q6, q7, [sp, #0xc0]
DISASM-NEXT: 18000106c: ad4517e4     ldp     q4, q5, [sp, #0xa0]
DISASM-NEXT: 180001070: ad440fe2     ldp     q2, q3, [sp, #0x80]
DISASM-NEXT: 180001074: ad4307e0     ldp     q0, q1, [sp, #0x60]
DISASM-NEXT: 180001078: f9402be8     ldr     x8,     [sp, #0x50]
DISASM-NEXT: 18000107c: a9441fe6     ldp     x6, x7, [sp, #0x40]
DISASM-NEXT: 180001080: a94317e4     ldp     x4, x5, [sp, #0x30]
DISASM-NEXT: 180001084: a9420fe2     ldp     x2, x3, [sp, #0x20]
DISASM-NEXT: 180001088: a94107e0     ldp     x0, x1, [sp, #0x10]
DISASM-NEXT: 18000108c: a8ce7bfd     ldp     x29, x30, [sp], #0xe0
DISASM-NEXT: 180001090: d61f0200     br      x16
DISASM-NEXT:                 ...
DISASM-NEXT: 180002000: 52800040     mov     w0, #0x2                // =2
DISASM-NEXT: 180002004: d65f03c0     ret
DISASM-NEXT: 180002008: 52800060     mov     w0, #0x3                // =3
DISASM-NEXT: 18000200c: d65f03c0     ret
DISASM-NEXT: 180002010: f0000010     adrp    x16, 0x180005000
DISASM-NEXT: 180002014: f9400a10     ldr     x16, [x16, #0x10]
DISASM-NEXT: 180002018: d61f0200     br      x16
DISASM-NEXT: 18000201c: 9000002b     adrp    x11, 0x180006000
DISASM-NEXT: 180002020: f9404d6b     ldr     x11, [x11, #0x98]
DISASM-NEXT: 180002024: 9000000a     adrp    x10, 0x180002000 <.text+0x1000>
DISASM-NEXT: 180002028: 9100c14a     add     x10, x10, #0x30
DISASM-NEXT: 18000202c: 17fffff5     b       0x180002000 <.text+0x1000>
DISASM-NEXT: 180002030: 52800080     mov     w0, #0x4                // =4
DISASM-NEXT: 180002034: d65f03c0     ret
DISASM-NEXT:                 ...
DISASM-NEXT: 180003000: ff 25 92 30 00 00            jmpq    *0x3092(%rip)           # 0x180006098
DISASM-NEXT: 180003006: 48 8d 05 8b 30 00 00         leaq    0x308b(%rip), %rax      # 0x180006098
DISASM-NEXT: 18000300d: e9 00 00 00 00               jmp     0x180003012 <.text+0x2012>
DISASM-NEXT: 180003012: 48 89 4c 24 08               movq    %rcx, 0x8(%rsp)
DISASM-NEXT: 180003017: 48 89 54 24 10               movq    %rdx, 0x10(%rsp)
DISASM-NEXT: 18000301c: 4c 89 44 24 18               movq    %r8, 0x18(%rsp)
DISASM-NEXT: 180003021: 4c 89 4c 24 20               movq    %r9, 0x20(%rsp)
DISASM-NEXT: 180003026: 48 83 ec 68                  subq    $0x68, %rsp
DISASM-NEXT: 18000302a: 66 0f 7f 44 24 20            movdqa  %xmm0, 0x20(%rsp)
DISASM-NEXT: 180003030: 66 0f 7f 4c 24 30            movdqa  %xmm1, 0x30(%rsp)
DISASM-NEXT: 180003036: 66 0f 7f 54 24 40            movdqa  %xmm2, 0x40(%rsp)
DISASM-NEXT: 18000303c: 66 0f 7f 5c 24 50            movdqa  %xmm3, 0x50(%rsp)
DISASM-NEXT: 180003042: 48 8b d0                     movq    %rax, %rdx
DISASM-NEXT: 180003045: 48 8d 0d fc 12 00 00         leaq    0x12fc(%rip), %rcx      # 0x180004348
DISASM-NEXT: 18000304c: e8 b7 ef ff ff               callq   0x180002008 <.text+0x1008>
DISASM-NEXT: 180003051: 66 0f 6f 44 24 20            movdqa  0x20(%rsp), %xmm0
DISASM-NEXT: 180003057: 66 0f 6f 4c 24 30            movdqa  0x30(%rsp), %xmm1
DISASM-NEXT: 18000305d: 66 0f 6f 54 24 40            movdqa  0x40(%rsp), %xmm2
DISASM-NEXT: 180003063: 66 0f 6f 5c 24 50            movdqa  0x50(%rsp), %xmm3
DISASM-NEXT: 180003069: 48 8b 4c 24 70               movq    0x70(%rsp), %rcx
DISASM-NEXT: 18000306e: 48 8b 54 24 78               movq    0x78(%rsp), %rdx
DISASM-NEXT: 180003073: 4c 8b 84 24 80 00 00 00      movq    0x80(%rsp), %r8
DISASM-NEXT: 18000307b: 4c 8b 8c 24 88 00 00 00      movq    0x88(%rsp), %r9
DISASM-NEXT: 180003083: 48 83 c4 68                  addq    $0x68, %rsp
DISASM-NEXT: 180003087: ff e0                        jmpq    *%rax

RUN: llvm-readobj --coff-load-config out.dll | FileCheck --check-prefix=LOADCFG %s
LOADCFG:      AuxiliaryDelayloadIAT: 0x5000
LOADCFG-NEXT: AuxiliaryDelayloadIATCopy: 0x4140

RUN: llvm-readobj --hex-dump=.rdata out.dll | FileCheck --check-prefix=AUXIAT %s
AUXIAT:      0x180005000 00000000 00000000 00000000 00000000
AUXIAT-NEXT: 0x180005010 1c200080 01000000 00000000 00000000


# Test delayed-load import from native code only.

RUN: lld-link -machine:arm64x -dll -noentry -out:out-native.dll loadconfig-arm64.obj loadconfig-arm64ec.obj \
RUN:          arm64-helper.obj arm64ec-helper.obj test-arm64.obj test-arm64.lib test-arm64ec.lib -delayload:test.dll

RUN: llvm-readobj --coff-imports out-native.dll | FileCheck --check-prefix=NATIVE-IMPORTS %s
NATIVE-IMPORTS:      DelayImport {
NATIVE-IMPORTS-NEXT:   Name: test.dll
NATIVE-IMPORTS-NEXT:   Attributes: 0x1
NATIVE-IMPORTS-NEXT:   ModuleHandle: 0x5080
NATIVE-IMPORTS-NEXT:   ImportAddressTable: 0x5088
NATIVE-IMPORTS-NEXT:   ImportNameTable: 0x3370
NATIVE-IMPORTS-NEXT:   BoundDelayImportTable: 0x0
NATIVE-IMPORTS-NEXT:   UnloadDelayImportTable: 0x0
NATIVE-IMPORTS-NEXT:   Import {
NATIVE-IMPORTS-NEXT:     Symbol: func (0)
NATIVE-IMPORTS-NEXT:     Address: 0x180001014
NATIVE-IMPORTS-NEXT:   }
NATIVE-IMPORTS-NEXT: }
NATIVE-IMPORTS-NEXT: HybridObject {
NATIVE-IMPORTS-NEXT:   Format: COFF-ARM64EC
NATIVE-IMPORTS-NEXT:   Arch: aarch64
NATIVE-IMPORTS-NEXT:   AddressSize: 64bit
NATIVE-IMPORTS-NEXT:   DelayImport {
NATIVE-IMPORTS-NEXT:     Name: test.dll
NATIVE-IMPORTS-NEXT:     Attributes: 0x1
NATIVE-IMPORTS-NEXT:     ModuleHandle: 0x5080
NATIVE-IMPORTS-NEXT:     ImportAddressTable: 0x5098
NATIVE-IMPORTS-NEXT:     ImportNameTable: 0x3380
NATIVE-IMPORTS-NEXT:     BoundDelayImportTable: 0x0
NATIVE-IMPORTS-NEXT:     UnloadDelayImportTable: 0x0
NATIVE-IMPORTS-NEXT:   }
NATIVE-IMPORTS-NEXT: }

RUN: llvm-readobj --hex-dump=.testa out-native.dll | FileCheck --check-prefix=NATIVE-TESTSECA %s
NATIVE-TESTSECA: 0x180007000 88500000 08100000

RUN: llvm-objdump -d out-native.dll | FileCheck --check-prefix=NATIVE-DISASM %s
NATIVE-DISASM:      0000000180001000 <.text>:
NATIVE-DISASM-NEXT: 180001000: 52800060     mov     w0, #0x3                // =3
NATIVE-DISASM-NEXT: 180001004: d65f03c0     ret
NATIVE-DISASM-NEXT: 180001008: 90000030     adrp    x16, 0x180005000
NATIVE-DISASM-NEXT: 18000100c: f9404610     ldr     x16, [x16, #0x88]
NATIVE-DISASM-NEXT: 180001010: d61f0200     br      x16
NATIVE-DISASM-NEXT: 180001014: 90000031     adrp    x17, 0x180005000
NATIVE-DISASM-NEXT: 180001018: 91022231     add     x17, x17, #0x88
NATIVE-DISASM-NEXT: 18000101c: 14000001     b       0x180001020 <.text+0x20>
NATIVE-DISASM-NEXT: 180001020: a9b27bfd     stp     x29, x30, [sp, #-0xe0]!
NATIVE-DISASM-NEXT: 180001024: 910003fd     mov     x29, sp
NATIVE-DISASM-NEXT: 180001028: a90107e0     stp     x0, x1, [sp, #0x10]
NATIVE-DISASM-NEXT: 18000102c: a9020fe2     stp     x2, x3, [sp, #0x20]
NATIVE-DISASM-NEXT: 180001030: a90317e4     stp     x4, x5, [sp, #0x30]
NATIVE-DISASM-NEXT: 180001034: a9041fe6     stp     x6, x7, [sp, #0x40]
NATIVE-DISASM-NEXT: 180001038: f9002be8     str     x8,     [sp, #0x50]
NATIVE-DISASM-NEXT: 18000103c: ad0307e0     stp     q0, q1, [sp, #0x60]
NATIVE-DISASM-NEXT: 180001040: ad040fe2     stp     q2, q3, [sp, #0x80]
NATIVE-DISASM-NEXT: 180001044: ad0517e4     stp     q4, q5, [sp, #0xa0]
NATIVE-DISASM-NEXT: 180001048: ad061fe6     stp     q6, q7, [sp, #0xc0]
NATIVE-DISASM-NEXT: 18000104c: aa1103e1     mov     x1, x17
NATIVE-DISASM-NEXT: 180001050: d0000000     adrp    x0, 0x180003000
NATIVE-DISASM-NEXT: 180001054: 910cc000     add     x0, x0, #0x330
NATIVE-DISASM-NEXT: 180001058: 90000002     adrp    x2, 0x180001000 <.text>
NATIVE-DISASM-NEXT: 18000105c: 91000042     add     x2, x2, #0x0
NATIVE-DISASM-NEXT: 180001060: d63f0040     blr     x2
NATIVE-DISASM-NEXT: 180001064: aa0003f0     mov     x16, x0
NATIVE-DISASM-NEXT: 180001068: ad461fe6     ldp     q6, q7, [sp, #0xc0]
NATIVE-DISASM-NEXT: 18000106c: ad4517e4     ldp     q4, q5, [sp, #0xa0]
NATIVE-DISASM-NEXT: 180001070: ad440fe2     ldp     q2, q3, [sp, #0x80]
NATIVE-DISASM-NEXT: 180001074: ad4307e0     ldp     q0, q1, [sp, #0x60]
NATIVE-DISASM-NEXT: 180001078: f9402be8     ldr     x8,     [sp, #0x50]
NATIVE-DISASM-NEXT: 18000107c: a9441fe6     ldp     x6, x7, [sp, #0x40]
NATIVE-DISASM-NEXT: 180001080: a94317e4     ldp     x4, x5, [sp, #0x30]
NATIVE-DISASM-NEXT: 180001084: a9420fe2     ldp     x2, x3, [sp, #0x20]
NATIVE-DISASM-NEXT: 180001088: a94107e0     ldp     x0, x1, [sp, #0x10]
NATIVE-DISASM-NEXT: 18000108c: a8ce7bfd     ldp     x29, x30, [sp], #0xe0
NATIVE-DISASM-NEXT: 180001090: d61f0200     br      x16

RUN: llvm-readobj --coff-load-config out-native.dll | FileCheck --check-prefix=NATIVE-LOADCFG %s
NATIVE-LOADCFG:      AuxiliaryDelayloadIAT: 0x4000
NATIVE-LOADCFG-NEXT: AuxiliaryDelayloadIATCopy: 0x3140

RUN: llvm-readobj --hex-dump=.rdata out-native.dll | FileCheck --check-prefix=NATIVE-AUXIAT %s
NATIVE-AUXIAT:      0x180004000 00000000 00000000 00000000 00000000
NATIVE-AUXIAT-NEXT: 0x180004010 00000000 00000000


# Test delayed-load import from EC code only.

RUN: lld-link -machine:arm64x -dll -noentry -out:out-ec.dll loadconfig-arm64.obj loadconfig-arm64ec.obj \
RUN:          arm64-helper.obj arm64ec-helper.obj test-arm64ec.obj test-arm64.lib test-arm64ec.lib -delayload:test.dll

RUN: llvm-readobj --coff-imports out-ec.dll | FileCheck --check-prefix=EC-IMPORTS %s
EC-IMPORTS:      DelayImport {
EC-IMPORTS-NEXT:   Name: test.dll
EC-IMPORTS-NEXT:   Attributes: 0x1
EC-IMPORTS-NEXT:   ModuleHandle: 0x6080
EC-IMPORTS-NEXT:   ImportAddressTable: 0x6088
EC-IMPORTS-NEXT:   ImportNameTable: 0x4380
EC-IMPORTS-NEXT:   BoundDelayImportTable: 0x0
EC-IMPORTS-NEXT:   UnloadDelayImportTable: 0x0
EC-IMPORTS-NEXT: }
EC-IMPORTS-NEXT: HybridObject {
EC-IMPORTS-NEXT:   Format: COFF-ARM64EC
EC-IMPORTS-NEXT:   Arch: aarch64
EC-IMPORTS-NEXT:   AddressSize: 64bit
EC-IMPORTS-NEXT:   DelayImport {
EC-IMPORTS-NEXT:     Name: test.dll
EC-IMPORTS-NEXT:     Attributes: 0x1
EC-IMPORTS-NEXT:     ModuleHandle: 0x6080
EC-IMPORTS-NEXT:     ImportAddressTable: 0x6090
EC-IMPORTS-NEXT:     ImportNameTable: 0x4388
EC-IMPORTS-NEXT:     BoundDelayImportTable: 0x0
EC-IMPORTS-NEXT:     UnloadDelayImportTable: 0x0
EC-IMPORTS-NEXT:     Import {
EC-IMPORTS-NEXT:       Symbol: func (0)
EC-IMPORTS-NEXT:       Address: 0x180003006
EC-IMPORTS-NEXT:     }
EC-IMPORTS-NEXT:   }
EC-IMPORTS-NEXT: }

RUN: llvm-readobj --hex-dump=.test out-ec.dll | FileCheck --check-prefix=EC-TESTSEC %s
EC-TESTSEC: 0x180009000 08500000 90600000 00300000 10200000

RUN: llvm-objdump -d out-ec.dll | FileCheck --check-prefix=EC-DISASM %s
EC-DISASM:      0000000180001000 <.text>:
EC-DISASM-NEXT: 180001000: 52800060     mov     w0, #0x3                // =3
EC-DISASM-NEXT: 180001004: d65f03c0     ret
EC-DISASM-NEXT:                 ...
EC-DISASM-NEXT: 180002000: 52800040     mov     w0, #0x2                // =2
EC-DISASM-NEXT: 180002004: d65f03c0     ret
EC-DISASM-NEXT: 180002008: 52800060     mov     w0, #0x3                // =3
EC-DISASM-NEXT: 18000200c: d65f03c0     ret
EC-DISASM-NEXT: 180002010: f0000010     adrp    x16, 0x180005000
EC-DISASM-NEXT: 180002014: f9400610     ldr     x16, [x16, #0x8]
EC-DISASM-NEXT: 180002018: d61f0200     br      x16
EC-DISASM-NEXT: 18000201c: 9000002b     adrp    x11, 0x180006000
EC-DISASM-NEXT: 180002020: f940496b     ldr     x11, [x11, #0x90]
EC-DISASM-NEXT: 180002024: 9000000a     adrp    x10, 0x180002000 <.text+0x1000>
EC-DISASM-NEXT: 180002028: 9100c14a     add     x10, x10, #0x30
EC-DISASM-NEXT: 18000202c: 17fffff5     b       0x180002000 <.text+0x1000>
EC-DISASM-NEXT: 180002030: 52800080     mov     w0, #0x4                // =4
EC-DISASM-NEXT: 180002034: d65f03c0     ret
EC-DISASM-NEXT:                 ...
EC-DISASM-NEXT: 180003000: ff 25 8a 30 00 00            jmpq    *0x308a(%rip)           # 0x180006090
EC-DISASM-NEXT: 180003006: 48 8d 05 83 30 00 00         leaq    0x3083(%rip), %rax      # 0x180006090
EC-DISASM-NEXT: 18000300d: e9 00 00 00 00               jmp     0x180003012 <.text+0x2012>
EC-DISASM-NEXT: 180003012: 48 89 4c 24 08               movq    %rcx, 0x8(%rsp)
EC-DISASM-NEXT: 180003017: 48 89 54 24 10               movq    %rdx, 0x10(%rsp)
EC-DISASM-NEXT: 18000301c: 4c 89 44 24 18               movq    %r8, 0x18(%rsp)
EC-DISASM-NEXT: 180003021: 4c 89 4c 24 20               movq    %r9, 0x20(%rsp)
EC-DISASM-NEXT: 180003026: 48 83 ec 68                  subq    $0x68, %rsp
EC-DISASM-NEXT: 18000302a: 66 0f 7f 44 24 20            movdqa  %xmm0, 0x20(%rsp)
EC-DISASM-NEXT: 180003030: 66 0f 7f 4c 24 30            movdqa  %xmm1, 0x30(%rsp)
EC-DISASM-NEXT: 180003036: 66 0f 7f 54 24 40            movdqa  %xmm2, 0x40(%rsp)
EC-DISASM-NEXT: 18000303c: 66 0f 7f 5c 24 50            movdqa  %xmm3, 0x50(%rsp)
EC-DISASM-NEXT: 180003042: 48 8b d0                     movq    %rax, %rdx
EC-DISASM-NEXT: 180003045: 48 8d 0d f4 12 00 00         leaq    0x12f4(%rip), %rcx      # 0x180004340
EC-DISASM-NEXT: 18000304c: e8 b7 ef ff ff               callq   0x180002008 <.text+0x1008>
EC-DISASM-NEXT: 180003051: 66 0f 6f 44 24 20            movdqa  0x20(%rsp), %xmm0
EC-DISASM-NEXT: 180003057: 66 0f 6f 4c 24 30            movdqa  0x30(%rsp), %xmm1
EC-DISASM-NEXT: 18000305d: 66 0f 6f 54 24 40            movdqa  0x40(%rsp), %xmm2
EC-DISASM-NEXT: 180003063: 66 0f 6f 5c 24 50            movdqa  0x50(%rsp), %xmm3
EC-DISASM-NEXT: 180003069: 48 8b 4c 24 70               movq    0x70(%rsp), %rcx
EC-DISASM-NEXT: 18000306e: 48 8b 54 24 78               movq    0x78(%rsp), %rdx
EC-DISASM-NEXT: 180003073: 4c 8b 84 24 80 00 00 00      movq    0x80(%rsp), %r8
EC-DISASM-NEXT: 18000307b: 4c 8b 8c 24 88 00 00 00      movq    0x88(%rsp), %r9
EC-DISASM-NEXT: 180003083: 48 83 c4 68                  addq    $0x68, %rsp
EC-DISASM-NEXT: 180003087: ff e0                        jmpq    *%rax

RUN: llvm-readobj --coff-load-config out-ec.dll | FileCheck --check-prefix=EC-LOADCFG %s
EC-LOADCFG:      AuxiliaryDelayloadIAT: 0x5000
EC-LOADCFG-NEXT: AuxiliaryDelayloadIATCopy: 0x4140

RUN: llvm-readobj --hex-dump=.rdata out-ec.dll | FileCheck --check-prefix=EC-AUXIAT %s
EC-AUXIAT:      0x180005000 00000000 00000000 1c200080 01000000
EC-AUXIAT-NEXT: 0x180005010 00000000 00000000


#--- test-arm64ec.s
    .section .test, "rd"
    .rva __imp_func
    .rva __imp_aux_func
    .rva func
    .rva "#func"

#--- test-arm64.s
    .section .testa, "rd"
    .rva __imp_func
    .rva func

#--- arm64ec-helper.s
    .section .text,"xr",discard,__icall_helper_arm64ec
    .globl __icall_helper_arm64ec
    .p2align 2, 0x0
__icall_helper_arm64ec:
    mov w0, #2
    ret

    .section .text,"xr",discard,"#__delayLoadHelper2"
    .globl "#__delayLoadHelper2"
    .p2align 2, 0x0
"#__delayLoadHelper2":
    mov w0, #3
    ret

    .section .hybmp$x, "yi"
    .symidx __imp_func
    .symidx func_exit_thunk
    .word 4

    .section .wowthk$aa,"xr",discard,func_exit_thunk
    .globl func_exit_thunk
func_exit_thunk:
    mov w0, #4
    ret

#--- arm64-helper.s
    .section .text,"xr",discard,__delayLoadHelper2
    .globl __delayLoadHelper2
    .p2align 2, 0x0
__delayLoadHelper2:
    mov w0, #3
    ret

#--- test.def
NAME test.dll
EXPORTS
    func
