@@ -7,10 +7,16 @@ RUN: llvm-mc -filetype=obj -triple=aarch64-windows nsymref.s -o nsymref-aarch64.
7
7
RUN: llvm-mc -filetype=obj -triple=arm64ec-windows sym.s -o sym-arm64ec.obj
8
8
RUN: llvm-mc -filetype=obj -triple=x86_64-windows sym.s -o sym-x86_64.obj
9
9
RUN: 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
10
14
RUN: llvm-mc -filetype=obj -triple=arm64ec-windows %S/Inputs/loadconfig-arm64ec.s -o loadconfig-arm64ec.obj
11
15
12
16
RUN: llvm-lib -machine:arm64ec -out:sym-arm64ec.lib sym-arm64ec.obj nsym-aarch64.obj
13
17
RUN: 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
14
20
15
21
Verify that a symbol can be referenced from ECSYMBOLS.
16
22
RUN: lld-link -machine:arm64ec -dll -noentry -out:test.dll symref-arm64ec.obj sym-arm64ec.lib loadconfig-arm64ec.obj
@@ -26,6 +32,49 @@ RUN: not lld-link -machine:arm64ec -dll -noentry -out:test-err.dll nsymref-arm64
26
32
RUN: FileCheck --check-prefix=ERR %s
27
33
ERR: error: undefined symbol: nsym
28
34
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
+ A similar test using -start-lib for linking.
74
+ RUN: lld-link -machine:arm64ec -dll -noentry -out:start-lib-1.dll ref-thunk.obj -start-lib func.obj -end-lib loadconfig-arm64ec.obj
75
+ RUN: llvm-objdump -d start-lib-1.dll | FileCheck -check-prefix=DISASM %s
76
+ RUN: llvm-readobj --hex-dump=.test start-lib-1.dll | FileCheck -check-prefix=TESTSEC %s
77
+
29
78
#--- symref.s
30
79
.data
31
80
.rva sym
45
94
.globl nsym
46
95
nsym:
47
96
.word 0
97
+
98
+ #--- ref-alias.s
99
+ .weak_anti_dep func
100
+ .set func,"#func"
101
+
102
+ .section .test, "r"
103
+ .rva func
104
+
105
+ #--- ref-thunk.s
106
+ .weak_anti_dep func
107
+ .set func, "#func"
108
+ .weak_anti_dep "#func"
109
+ .set "#func", thunksym
110
+
111
+ .section .test, "r"
112
+ .rva func
113
+
114
+ .section .thnk,"xr",discard,thunksym
115
+ thunksym:
116
+ mov w0, #2
117
+ ret
118
+
119
+ #--- func.s
120
+ .text
121
+ .globl "#func"
122
+ "#func":
123
+ ret
124
+
125
+ .weak_anti_dep func
126
+ .set func,"#func"
127
+
128
+ #--- func-x86_64.s
129
+ .text
130
+ .globl func
131
+ func:
132
+ ret
0 commit comments