1REQUIRES: aarch64, x86 2RUN: split-file %s %t.dir && cd %t.dir 3 4RUN: llvm-mc -filetype=obj -triple=arm64ec-windows symref.s -o symref-arm64ec.obj 5RUN: llvm-mc -filetype=obj -triple=arm64ec-windows nsymref.s -o nsymref-arm64ec.obj 6RUN: llvm-mc -filetype=obj -triple=aarch64-windows nsymref.s -o nsymref-aarch64.obj 7RUN: llvm-mc -filetype=obj -triple=arm64ec-windows sym.s -o sym-arm64ec.obj 8RUN: llvm-mc -filetype=obj -triple=x86_64-windows sym.s -o sym-x86_64.obj 9RUN: llvm-mc -filetype=obj -triple=aarch64-windows nsym.s -o nsym-aarch64.obj 10RUN: llvm-mc -filetype=obj -triple=arm64ec-windows ref-alias.s -o ref-alias.obj 11RUN: llvm-mc -filetype=obj -triple=arm64ec-windows ref-thunk.s -o ref-thunk.obj 12RUN: llvm-mc -filetype=obj -triple=arm64ec-windows func.s -o func.obj 13RUN: llvm-mc -filetype=obj -triple=x86_64-windows func-x86_64.s -o func-x86_64.obj 14RUN: llvm-mc -filetype=obj -triple=aarch64-windows %S/Inputs/loadconfig-arm64.s -o loadconfig-arm64.obj 15RUN: llvm-mc -filetype=obj -triple=arm64ec-windows %S/Inputs/loadconfig-arm64ec.s -o loadconfig-arm64ec.obj 16 17RUN: llvm-lib -machine:arm64ec -out:sym-arm64ec.lib sym-arm64ec.obj nsym-aarch64.obj 18RUN: llvm-lib -machine:amd64 -out:sym-x86_64.lib sym-x86_64.obj 19RUN: llvm-lib -machine:arm64ec -out:func.lib func.obj 20RUN: llvm-lib -machine:arm64ec -out:func-x86_64.lib func-x86_64.obj 21RUN: llvm-lib -machine:arm64ec -out:func-imp.lib -def:func.def 22 23Verify that a symbol can be referenced from ECSYMBOLS. 24RUN: lld-link -machine:arm64ec -dll -noentry -out:test.dll symref-arm64ec.obj sym-arm64ec.lib loadconfig-arm64ec.obj 25 26Verify that a symbol can be referenced from a regular archive map when ECSYMBOLS is absent (using an x86_64 archive). 27RUN: lld-link -machine:arm64ec -dll -noentry -out:test2.dll symref-arm64ec.obj sym-x86_64.lib loadconfig-arm64ec.obj 28 29Verify that both native and EC symbols can be referenced in a hybrid target. 30RUN: lld-link -machine:arm64x -dll -noentry -out:test3.dll symref-arm64ec.obj nsymref-aarch64.obj sym-arm64ec.lib \ 31RUN: loadconfig-arm64.obj loadconfig-arm64ec.obj 32 33Ensure that an EC symbol is not resolved using a regular symbol map. 34RUN: not lld-link -machine:arm64ec -dll -noentry -out:test-err.dll nsymref-arm64ec.obj sym-arm64ec.lib loadconfig-arm64ec.obj 2>&1 |\ 35RUN: FileCheck --check-prefix=ERR %s 36ERR: error: undefined symbol: nsym 37 38Verify that a library symbol can be referenced, even if its name conflicts with an anti-dependency alias. 39RUN: lld-link -machine:arm64ec -dll -noentry -out:ref-alias-1.dll ref-alias.obj func.lib loadconfig-arm64ec.obj 40RUN: llvm-objdump -d ref-alias-1.dll | FileCheck -check-prefix=DISASM %s 41DISASM: 0000000180001000 <.text>: 42DISASM-NEXT: 180001000: d65f03c0 ret 43DISASM-EMPTY: 44 45RUN: llvm-readobj --hex-dump=.test ref-alias-1.dll | FileCheck -check-prefix=TESTSEC %s 46TESTSEC: 0x180005000 00100000 47 48The same test, but with a different input order. 49RUN: lld-link -machine:arm64ec -dll -noentry -out:ref-alias-2.dll func.lib ref-alias.obj loadconfig-arm64ec.obj 50RUN: llvm-objdump -d ref-alias-2.dll | FileCheck -check-prefix=DISASM %s 51RUN: llvm-readobj --hex-dump=.test ref-alias-2.dll | FileCheck -check-prefix=TESTSEC %s 52 53Verify that when an anti-dependency to a guess exit thunk is present, it is overridden by an archive symbol. 54RUN: lld-link -machine:arm64ec -dll -noentry -out:ref-thunk-1.dll ref-thunk.obj func.lib loadconfig-arm64ec.obj 55RUN: llvm-objdump -d ref-thunk-1.dll | FileCheck -check-prefix=DISASM %s 56RUN: llvm-readobj --hex-dump=.test ref-thunk-1.dll | FileCheck -check-prefix=TESTSEC %s 57 58The same test, but with a different input order. 59RUN: lld-link -machine:arm64ec -dll -noentry -out:ref-thunk-2.dll func.lib ref-thunk.obj loadconfig-arm64ec.obj 60RUN: llvm-objdump -d ref-thunk-2.dll | FileCheck -check-prefix=DISASM %s 61RUN: llvm-readobj --hex-dump=.test ref-thunk-2.dll | FileCheck -check-prefix=TESTSEC %s 62 63Pass multiple libraries containing `func` with different manglings and ensure they don't conflict with each other. 64RUN: lld-link -machine:arm64ec -dll -noentry -out:ref-thunk-3.dll func.lib loadconfig-arm64ec.obj func-x86_64.lib func-imp.lib ref-thunk.obj 65RUN: llvm-objdump -d ref-thunk-3.dll | FileCheck -check-prefix=DISASM %s 66RUN: llvm-readobj --hex-dump=.test ref-thunk-3.dll | FileCheck -check-prefix=TESTSEC %s 67 68RUN: lld-link -machine:arm64ec -dll -noentry -out:ref-thunk-4.dll ref-thunk.obj func.lib loadconfig-arm64ec.obj func-x86_64.lib func-imp.lib 69RUN: llvm-objdump -d ref-thunk-4.dll | FileCheck -check-prefix=DISASM %s 70RUN: llvm-readobj --hex-dump=.test ref-thunk-4.dll | FileCheck -check-prefix=TESTSEC %s 71 72Test linking against an x86_64 library (which uses a demangled function name). 73RUN: lld-link -machine:arm64ec -dll -noentry -out:ref-x86-1.dll ref-thunk.obj func-x86_64.lib loadconfig-arm64ec.obj 74RUN: llvm-objdump -d ref-x86-1.dll | FileCheck -check-prefix=DISASM-X86 %s 75RUN: llvm-readobj --hex-dump=.test ref-x86-1.dll | FileCheck -check-prefix=TESTSEC %s 76 77DISASM-X86: 0000000180001000 <.text>: 78DISASM-X86-NEXT: 180001000: c3 retq 79 80The same test, but with a different input order. 81RUN: lld-link -machine:arm64ec -dll -noentry -out:ref-x86-2.dll func-x86_64.lib ref-thunk.obj loadconfig-arm64ec.obj 82RUN: llvm-objdump -d ref-x86-2.dll | FileCheck -check-prefix=DISASM-X86 %s 83RUN: llvm-readobj --hex-dump=.test ref-x86-2.dll | FileCheck -check-prefix=TESTSEC %s 84 85Check that an alias to the implementation takes precedence over an archive symbol. 86RUN: lld-link -machine:arm64ec -dll -noentry -out:ref-x86-2.dll func-x86_64.lib func.obj ref-thunk.obj loadconfig-arm64ec.obj 87RUN: llvm-objdump -d ref-x86-2.dll | FileCheck -check-prefix=DISASM %s 88RUN: llvm-readobj --hex-dump=.test ref-x86-2.dll | FileCheck -check-prefix=TESTSEC %s 89 90A similar test using -start-lib for linking. 91RUN: lld-link -machine:arm64ec -dll -noentry -out:start-lib-1.dll ref-thunk.obj -start-lib func.obj -end-lib loadconfig-arm64ec.obj 92RUN: llvm-objdump -d start-lib-1.dll | FileCheck -check-prefix=DISASM %s 93RUN: llvm-readobj --hex-dump=.test start-lib-1.dll | FileCheck -check-prefix=TESTSEC %s 94 95RUN: lld-link -machine:arm64ec -dll -noentry -out:start-lib-2.dll ref-thunk.obj -start-lib func.obj -end-lib loadconfig-arm64ec.obj \ 96RUN: -start-lib func-x86_64.obj -end-lib func-imp.lib 97RUN: llvm-objdump -d ref-thunk-3.dll | FileCheck -check-prefix=DISASM %s 98RUN: llvm-readobj --hex-dump=.test ref-thunk-3.dll | FileCheck -check-prefix=TESTSEC %s 99 100#--- symref.s 101 .data 102 .rva sym 103 104#--- nsymref.s 105 .data 106 .rva nsym 107 108#--- sym.s 109 .data 110 .globl sym 111sym: 112 .word 0 113 114#--- nsym.s 115 .data 116 .globl nsym 117nsym: 118 .word 0 119 120#--- ref-alias.s 121 .weak_anti_dep func 122.set func,"#func" 123 124 .section .test, "r" 125 .rva func 126 127#--- ref-thunk.s 128 .weak_anti_dep func 129.set func, "#func" 130 .weak_anti_dep "#func" 131.set "#func", thunksym 132 133 .section .test, "r" 134 .rva func 135 136 .section .thnk,"xr",discard,thunksym 137thunksym: 138 mov w0, #2 139 ret 140 141#--- func.s 142 .text 143 .globl "#func" 144"#func": 145 ret 146 147 .weak_anti_dep func 148.set func,"#func" 149 150#--- func-x86_64.s 151 .text 152 .globl func 153func: 154 ret 155 156#--- func.def 157LIBRARY func.dll 158EXPORTS 159 func 160