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