@@ -7,10 +7,16 @@ RUN: llvm-mc -filetype=obj -triple=aarch64-windows nsymref.s -o nsymref-aarch64.
77RUN: llvm-mc -filetype=obj -triple=arm64ec-windows sym.s -o sym-arm64ec.obj
88RUN: llvm-mc -filetype=obj -triple=x86_64-windows sym.s -o sym-x86_64.obj
99RUN: llvm-mc -filetype=obj -triple=aarch64-windows nsym.s -o nsym-aarch64.obj
10+ RUN: llvm-mc -filetype=obj -triple=arm64ec-windows ref-alias.s -o ref-alias.obj
11+ RUN: llvm-mc -filetype=obj -triple=arm64ec-windows ref-thunk.s -o ref-thunk.obj
12+ RUN: llvm-mc -filetype=obj -triple=arm64ec-windows func.s -o func.obj
13+ RUN: llvm-mc -filetype=obj -triple=x86_64-windows func-x86_64.s -o func-x86_64.obj
1014RUN: llvm-mc -filetype=obj -triple=arm64ec-windows %S/Inputs/loadconfig-arm64ec.s -o loadconfig-arm64ec.obj
1115
1216RUN: llvm-lib -machine:arm64ec -out:sym-arm64ec.lib sym-arm64ec.obj nsym-aarch64.obj
1317RUN: llvm-lib -machine:amd64 -out:sym-x86_64.lib sym-x86_64.obj
18+ RUN: llvm-lib -machine:arm64ec -out:func.lib func.obj
19+ RUN: llvm-lib -machine:arm64ec -out:func-x86_64.lib func-x86_64.obj
1420
1521Verify that a symbol can be referenced from ECSYMBOLS.
1622RUN: lld-link -machine:arm64ec -dll -noentry -out:test.dll symref-arm64ec.obj sym-arm64ec.lib loadconfig-arm64ec.obj
@@ -26,6 +32,54 @@ RUN: not lld-link -machine:arm64ec -dll -noentry -out:test-err.dll nsymref-arm64
2632RUN: FileCheck --check-prefix=ERR %s
2733ERR: error: undefined symbol: nsym
2834
35+ Verify that a library symbol can be referenced, even if its name conflicts with an anti-dependency alias.
36+ RUN: lld-link -machine:arm64ec -dll -noentry -out:ref-alias-1.dll ref-alias.obj func.lib loadconfig-arm64ec.obj
37+ RUN: llvm-objdump -d ref-alias-1.dll | FileCheck -check-prefix=DISASM %s
38+ DISASM: 0000000180001000 <.text>:
39+ DISASM-NEXT: 180001000: d65f03c0 ret
40+ DISASM-EMPTY:
41+
42+ RUN: llvm-readobj --hex-dump=.test ref-alias-1.dll | FileCheck -check-prefix=TESTSEC %s
43+ TESTSEC: 0x180004000 00100000
44+
45+ The same test, but with a different input order.
46+ RUN: lld-link -machine:arm64ec -dll -noentry -out:ref-alias-2.dll func.lib ref-alias.obj loadconfig-arm64ec.obj
47+ RUN: llvm-objdump -d ref-alias-2.dll | FileCheck -check-prefix=DISASM %s
48+ RUN: llvm-readobj --hex-dump=.test ref-alias-2.dll | FileCheck -check-prefix=TESTSEC %s
49+
50+ Verify that when an anti-dependency to a guess exit thunk is present, it is overridden by an archive symbol.
51+ RUN: lld-link -machine:arm64ec -dll -noentry -out:ref-thunk-1.dll ref-thunk.obj func.lib loadconfig-arm64ec.obj
52+ RUN: llvm-objdump -d ref-thunk-1.dll | FileCheck -check-prefix=DISASM %s
53+ RUN: llvm-readobj --hex-dump=.test ref-thunk-1.dll | FileCheck -check-prefix=TESTSEC %s
54+
55+ The same test, but with a different input order.
56+ RUN: lld-link -machine:arm64ec -dll -noentry -out:ref-thunk-2.dll func.lib ref-thunk.obj loadconfig-arm64ec.obj
57+ RUN: llvm-objdump -d ref-thunk-2.dll | FileCheck -check-prefix=DISASM %s
58+ RUN: llvm-readobj --hex-dump=.test ref-thunk-2.dll | FileCheck -check-prefix=TESTSEC %s
59+
60+ Test linking against an x86_64 library (which uses a demangled function name).
61+ RUN: lld-link -machine:arm64ec -dll -noentry -out:ref-x86-1.dll ref-thunk.obj func-x86_64.lib loadconfig-arm64ec.obj
62+ RUN: llvm-objdump -d ref-x86-1.dll | FileCheck -check-prefix=DISASM-X86 %s
63+ RUN: llvm-readobj --hex-dump=.test ref-x86-1.dll | FileCheck -check-prefix=TESTSEC %s
64+
65+ DISASM-X86: 0000000180001000 <.text>:
66+ DISASM-X86-NEXT: 180001000: c3 retq
67+
68+ The same test, but with a different input order.
69+ RUN: lld-link -machine:arm64ec -dll -noentry -out:ref-x86-2.dll func-x86_64.lib ref-thunk.obj loadconfig-arm64ec.obj
70+ RUN: llvm-objdump -d ref-x86-2.dll | FileCheck -check-prefix=DISASM-X86 %s
71+ RUN: llvm-readobj --hex-dump=.test ref-x86-2.dll | FileCheck -check-prefix=TESTSEC %s
72+
73+ Check that an alias to the implementation takes precedence over an archive symbol.
74+ RUN: lld-link -machine:arm64ec -dll -noentry -out:ref-x86-2.dll func-x86_64.lib func.obj ref-thunk.obj loadconfig-arm64ec.obj
75+ RUN: llvm-objdump -d ref-x86-2.dll | FileCheck -check-prefix=DISASM %s
76+ RUN: llvm-readobj --hex-dump=.test ref-x86-2.dll | FileCheck -check-prefix=TESTSEC %s
77+
78+ A similar test using -start-lib for linking.
79+ RUN: lld-link -machine:arm64ec -dll -noentry -out:start-lib-1.dll ref-thunk.obj -start-lib func.obj -end-lib loadconfig-arm64ec.obj
80+ RUN: llvm-objdump -d start-lib-1.dll | FileCheck -check-prefix=DISASM %s
81+ RUN: llvm-readobj --hex-dump=.test start-lib-1.dll | FileCheck -check-prefix=TESTSEC %s
82+
2983#--- symref.s
3084 .data
3185 .rva sym
4599 .globl nsym
46100nsym:
47101 .word 0
102+
103+ #--- ref-alias.s
104+ .weak_anti_dep func
105+ .set func,"#func"
106+
107+ .section .test, "r"
108+ .rva func
109+
110+ #--- ref-thunk.s
111+ .weak_anti_dep func
112+ .set func, "#func"
113+ .weak_anti_dep "#func"
114+ .set "#func", thunksym
115+
116+ .section .test, "r"
117+ .rva func
118+
119+ .section .thnk,"xr",discard,thunksym
120+ thunksym:
121+ mov w0, #2
122+ ret
123+
124+ #--- func.s
125+ .text
126+ .globl "#func"
127+ "#func":
128+ ret
129+
130+ .weak_anti_dep func
131+ .set func,"#func"
132+
133+ #--- func-x86_64.s
134+ .text
135+ .globl func
136+ func:
137+ ret
0 commit comments