@@ -9,6 +9,77 @@ RUN: lld-link -out:out1.dll -dll -noentry test.obj test.lib
99RUN: llvm-readobj --coff-imports out1.dll | FileCheck --check-prefix=IMPORT %s
1010IMPORT: Symbol: expfunc
1111
12+ Pass -export argument with EXPORTAS.
13+
14+ RUN: llvm-mc -filetype=obj -triple=x86_64-windows func.s -o func.obj
15+ RUN: lld-link -out:out2.dll -dll -noentry func.obj -export:func,EXPORTAS,expfunc
16+ RUN: llvm-readobj --coff-exports out2.dll | FileCheck --check-prefix=EXPORT %s
17+ EXPORT: Name: expfunc
18+
19+ RUN: llvm-readobj out2.lib | FileCheck --check-prefix=IMPLIB %s
20+ IMPLIB: Name type: export as
21+ IMPLIB-NEXT: Export name: expfunc
22+ IMPLIB-NEXT: Symbol: __imp_func
23+ IMPLIB-NEXT: Symbol: func
24+
25+ Use .drectve section with EXPORTAS.
26+
27+ RUN: llvm-mc -filetype=obj -triple=x86_64-windows drectve.s -o drectve.obj
28+ RUN: lld-link -out:out3.dll -dll -noentry func.obj drectve.obj
29+ RUN: llvm-readobj --coff-exports out3.dll | FileCheck --check-prefix=EXPORT %s
30+ RUN: llvm-readobj out3.lib | FileCheck --check-prefix=IMPLIB %s
31+
32+ Use a .def file with EXPORTAS.
33+
34+ RUN: lld-link -out:out4.dll -dll -noentry func.obj -def:test.def
35+ RUN: llvm-readobj --coff-exports out4.dll | FileCheck --check-prefix=EXPORT %s
36+ RUN: llvm-readobj out4.lib | FileCheck --check-prefix=IMPLIB %s
37+
38+ Use a .def file with EXPORTAS in a forwarding export.
39+
40+ RUN: lld-link -out:out5.dll -dll -noentry func.obj -def:test2.def
41+ RUN: llvm-readobj --coff-exports out5.dll | FileCheck --check-prefix=FORWARD-EXPORT %s
42+ FORWARD-EXPORT: Export {
43+ FORWARD-EXPORT-NEXT: Ordinal: 1
44+ FORWARD-EXPORT-NEXT: Name: expfunc
45+ FORWARD-EXPORT-NEXT: ForwardedTo: otherdll.otherfunc
46+ FORWARD-EXPORT-NEXT: }
47+
48+ RUN: llvm-readobj out5.lib | FileCheck --check-prefix=FORWARD-IMPLIB %s
49+ FORWARD-IMPLIB: Name type: export as
50+ FORWARD-IMPLIB-NEXT: Export name: expfunc
51+ FORWARD-IMPLIB-NEXT: Symbol: __imp_func
52+ FORWARD-IMPLIB-NEXT: Symbol: func
53+
54+ Pass -export argument with EXPORTAS in a forwarding export.
55+
56+ RUN: lld-link -out:out6.dll -dll -noentry func.obj -export:func=otherdll.otherfunc,EXPORTAS,expfunc
57+ RUN: llvm-readobj --coff-exports out6.dll | FileCheck --check-prefix=FORWARD-EXPORT %s
58+ RUN: llvm-readobj out6.lib | FileCheck --check-prefix=FORWARD-IMPLIB %s
59+
60+ Pass -export argument with EXPORTAS in a data export.
61+
62+ RUN: lld-link -out:out7.dll -dll -noentry func.obj -export:func,DATA,@5,EXPORTAS,expfunc
63+ RUN: llvm-readobj --coff-exports out7.dll | FileCheck --check-prefix=ORD %s
64+ ORD: Ordinal: 5
65+ ORD-NEXT: Name: expfunc
66+
67+ RUN: llvm-readobj out7.lib | FileCheck --check-prefix=ORD-IMPLIB %s
68+ ORD-IMPLIB: Type: data
69+ ORD-IMPLIB-NEXT: Name type: export as
70+ ORD-IMPLIB-NEXT: Export name: expfunc
71+ ORD-IMPLIB-NEXT: Symbol: __imp_func
72+
73+ Check invalid EXPORTAS syntax.
74+
75+ RUN: not lld-link -out:err1.dll -dll -noentry func.obj -export:func,EXPORTAS, 2>&1 | \
76+ RUN: FileCheck --check-prefix=ERR1 %s
77+ ERR1: error: invalid EXPORTAS value: {{$}}
78+
79+ RUN: not lld-link -out:err2.dll -dll -noentry func.obj -export:func,EXPORTAS,expfunc,DATA 2>&1 | \
80+ RUN: FileCheck --check-prefix=ERR2 %s
81+ ERR2: error: invalid EXPORTAS value: expfunc,DATA
82+
1283#--- test.s
1384 .section ".test", "rd"
1485 .rva __imp_func
@@ -17,3 +88,20 @@ IMPORT: Symbol: expfunc
1788LIBRARY test.dll
1889EXPORTS
1990 func EXPORTAS expfunc
91+
92+ #--- test2.def
93+ LIBRARY test.dll
94+ EXPORTS
95+ func=otherdll.otherfunc EXPORTAS expfunc
96+
97+ #--- func.s
98+ .text
99+ .globl func
100+ .p2align 2, 0x0
101+ func:
102+ movl $1, %eax
103+ retq
104+
105+ #--- drectve.s
106+ .section .drectve, "yn"
107+ .ascii " -export:func,EXPORTAS,expfunc"
0 commit comments