3 # RUN: llvm-mc -triple=i686-windows-gnu %s -filetype=obj -o %t.obj
5 # RUN: lld-link -lldmingw -dll -out:%t.dll -entry:DllMainCRTStartup@12 %t.obj -implib:%t.lib
6 # RUN: llvm-readobj --coff-exports %t.dll | grep Name: | FileCheck %s
7 # RUN: llvm-readobj --coff-exports %t.dll | FileCheck %s --check-prefix=CHECK-RVA
8 # RUN: llvm-readobj %t.lib | FileCheck -check-prefix=IMPLIB %s
11 # CHECK-SAME: comdatFunc
12 # CHECK-NEXT: Name: dataSym
13 # CHECK-NEXT: Name: foobar
16 # CHECK-RVA: Name: comdatFunc
17 # CHECK-RVA-NEXT: RVA: 0x1003
18 # CHECK-RVA: Name: dataSym
19 # CHECK-RVA-NEXT: RVA: 0x3000
20 # CHECK-RVA: Name: foobar
21 # CHECK-RVA-NEXT: RVA: 0x1001
23 # IMPLIB: Symbol: __imp__comdatFunc
24 # IMPLIB: Symbol: _comdatFunc
25 # IMPLIB: Symbol: __imp__dataSym
26 # IMPLIB-NOT: Symbol: _dataSym
27 # IMPLIB: Symbol: __imp__foobar
28 # IMPLIB: Symbol: _foobar
31 .global _DllMainCRTStartup@12
34 .global __imp__unexported
35 .global .refptr._foobar
38 _DllMainCRTStartup@
12:
44 .section .text$_comdatFunc,"xr",one_only,_comdatFunc
55 # Test specifying -export-all-symbols, on an object file that contains
56 # dllexport directive for some of the symbols.
58 # RUN: yaml2obj %p/Inputs/export.yaml -o %t.obj
60 # RUN: lld-link -safeseh:no -out:%t.dll -dll %t.obj -lldmingw -export-all-symbols -output-def:%t.def
61 # RUN: llvm-readobj --coff-exports %t.dll | FileCheck -check-prefix=CHECK2 %s
62 # RUN: cat %t.def | FileCheck -check-prefix=CHECK2-DEF %s
64 # RUN: lld-link -safeseh:no -out:%t.exe %t.obj -lldmingw -export-all-symbols -output-def:%t.def -entry:_DllMainCRTStartup
65 # RUN: llvm-readobj --coff-exports %t.exe | FileCheck -check-prefix=CHECK2 %s
66 # RUN: cat %t.def | FileCheck -check-prefix=CHECK2-DEF %s
68 # Note, this will actually export _DllMainCRTStartup as well, since
69 # it uses the standard spelling in this object file, not the MinGW one.
71 # CHECK2: Name: exportfn1
72 # CHECK2: Name: exportfn2
73 # CHECK2: Name: exportfn3
76 # CHECK2-DEF: exportfn1 @3
77 # CHECK2-DEF: exportfn2 @4
78 # CHECK2-DEF: exportfn3 @5
80 # Test ignoring certain object files and libs.
82 # RUN: echo -e ".global foobar\n.global DllMainCRTStartup\n.text\nDllMainCRTStartup:\nret\nfoobar:\ncall mingwfunc\ncall crtfunc\nret\n" > %t.main.s
83 # RUN: llvm-mc -triple=x86_64-windows-gnu %t.main.s -filetype=obj -o %t.main.obj
84 # RUN: mkdir -p %T/libs
85 # RUN: echo -e ".global mingwfunc\n.text\nmingwfunc:\nret\n" > %T/libs/mingwfunc.s
86 # RUN: llvm-mc -triple=x86_64-windows-gnu %T/libs/mingwfunc.s -filetype=obj -o %T/libs/mingwfunc.o
87 # RUN: rm -f %T/libs/libmingwex.a
88 # RUN: llvm-ar rcs %T/libs/libmingwex.a %T/libs/mingwfunc.o
89 # RUN: echo -e ".global crtfunc\n.text\ncrtfunc:\nret\n" > %T/libs/crtfunc.s
90 # RUN: llvm-mc -triple=x86_64-windows-gnu %T/libs/crtfunc.s -filetype=obj -o %T/libs/crt2.o
91 # RUN: lld-link -safeseh:no -out:%t.dll -dll -entry:DllMainCRTStartup %t.main.obj -lldmingw %T/libs/crt2.o %T/libs/libmingwex.a -output-def:%t.def
92 # RUN: echo "EOF" >> %t.def
93 # RUN: cat %t.def | FileCheck -check-prefix=CHECK-EXCLUDE %s
95 # CHECK-EXCLUDE: EXPORTS
96 # CHECK-EXCLUDE-NEXT: foobar @1
97 # CHECK-EXCLUDE-NEXT: EOF
99 # Test that libraries included with -wholearchive: are autoexported, even if
100 # they are in a library that otherwise normally would be excluded.
102 # RUN: lld-link -safeseh:no -out:%t.dll -dll -entry:DllMainCRTStartup %t.main.obj -lldmingw %T/libs/crt2.o -wholearchive:%T/libs/libmingwex.a -output-def:%t.def
103 # RUN: echo "EOF" >> %t.def
104 # RUN: cat %t.def | FileCheck -check-prefix=CHECK-WHOLEARCHIVE %s
106 # CHECK-WHOLEARCHIVE: EXPORTS
107 # CHECK-WHOLEARCHIVE-NEXT: foobar @1
108 # CHECK-WHOLEARCHIVE-NEXT: mingwfunc @2
109 # CHECK-WHOLEARCHIVE-NEXT: EOF
111 # Test that we handle import libraries together with -opt:noref.
113 # RUN: yaml2obj %p/Inputs/hello32.yaml -o %t.obj
114 # RUN: lld-link -lldmingw -dll -out:%t.dll -entry:main@0 %t.obj -implib:%t.lib -opt:noref %p/Inputs/std32.lib -output-def:%t.def
115 # RUN: echo "EOF" >> %t.def
116 # RUN: cat %t.def | FileCheck -check-prefix=CHECK-IMPLIB %s
118 # CHECK-IMPLIB: EXPORTS
119 # CHECK-IMPLIB-NEXT: main@0 @1
120 # CHECK-IMPLIB-NEXT: EOF