2 RUN: split-file %s %t.dir && cd %t.dir
4 Link to an import library containing EXPORTAS and verify that we use proper name for the import.
6 RUN: llvm-mc -filetype=obj -triple=x86_64-windows test.s -o test.obj
7 RUN: llvm-lib -machine:amd64 -out:test.lib -def:test.def
8 RUN: lld-link -out:out1.dll -dll -noentry test.obj test.lib
9 RUN: llvm-readobj --coff-imports out1.dll | FileCheck --check-prefix=IMPORT %s
10 IMPORT: Symbol: expfunc
12 Pass -export argument with EXPORTAS.
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
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
25 Use .drectve section with EXPORTAS.
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
32 Use a .def file with EXPORTAS.
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
38 Use a .def file with EXPORTAS in a forwarding export.
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: }
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
54 Pass -export argument with EXPORTAS in a forwarding export.
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
60 Pass -export argument with EXPORTAS in a data export.
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
65 ORD-NEXT: Name: expfunc
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
73 Check invalid EXPORTAS syntax.
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: {{$}}
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
84 .section ".test", "rd"
95 func=otherdll.otherfunc EXPORTAS expfunc
106 .section .drectve, "yn"
107 .ascii " -export:func,EXPORTAS,expfunc"