blob: 3d80603e2e71b9e4531d00dae4296f90af8445e3 [file] [log] [blame]
Joel Jonesa5752e12018-06-06 13:56:511# REQUIRES: x86
Martin Storsjo7f71acd2017-10-12 05:37:132
3# RUN: llvm-mc -triple=i686-windows-gnu %s -filetype=obj -o %t.obj
4
5# RUN: lld-link -lldmingw -dll -out:%t.dll -entry:DllMainCRTStartup@12 %t.obj -implib:%t.lib
Martin Storsjoe5120a32018-08-30 05:44:366# RUN: llvm-readobj -coff-exports %t.dll | grep Name: | FileCheck %s
Martin Storsjodc95dbf2017-11-03 20:58:207# RUN: llvm-readobj %t.lib | FileCheck -check-prefix=IMPLIB %s
Martin Storsjo7f71acd2017-10-12 05:37:138
Martin Storsjoe5120a32018-08-30 05:44:369# CHECK: Name:
10# CHECK-NEXT: Name: dataSym
11# CHECK-NEXT: Name: foobar
12# CHECK-EMPTY:
Martin Storsjo7f71acd2017-10-12 05:37:1313
Martin Storsjodc95dbf2017-11-03 20:58:2014# IMPLIB: Symbol: __imp__dataSym
15# IMPLIB-NOT: Symbol: _dataSym
16# IMPLIB: Symbol: __imp__foobar
17# IMPLIB: Symbol: _foobar
18
Martin Storsjo7f71acd2017-10-12 05:37:1319.global _foobar
20.global _DllMainCRTStartup@12
Martin Storsjodc95dbf2017-11-03 20:58:2021.global _dataSym
Martin Storsjo00107072017-11-29 05:50:4922.global _unexported
23.global __imp__unexported
Martin Storsjofcd55292018-08-30 05:44:4124.global .refptr._foobar
Martin Storsjo7f71acd2017-10-12 05:37:1325.text
26_DllMainCRTStartup@12:
27 ret
28_foobar:
29 ret
Martin Storsjo00107072017-11-29 05:50:4930_unexported:
31 ret
Martin Storsjodc95dbf2017-11-03 20:58:2032.data
33_dataSym:
34 .int 4
Martin Storsjo00107072017-11-29 05:50:4935__imp__unexported:
36 .int _unexported
Martin Storsjofcd55292018-08-30 05:44:4137.refptr._foobar:
38 .int _foobar
Martin Storsjo7f71acd2017-10-12 05:37:1339
Martin Storsjocbf43f02017-10-15 21:09:5040# Test specifying -export-all-symbols, on an object file that contains
Martin Storsjo7f71acd2017-10-12 05:37:1341# dllexport directive for some of the symbols.
42
43# RUN: yaml2obj < %p/Inputs/export.yaml > %t.obj
44#
45# RUN: lld-link -out:%t.dll -dll %t.obj -lldmingw -export-all-symbols -output-def:%t.def
46# RUN: llvm-readobj -coff-exports %t.dll | FileCheck -check-prefix=CHECK2 %s
47# RUN: cat %t.def | FileCheck -check-prefix=CHECK2-DEF %s
48
49# Note, this will actually export _DllMainCRTStartup as well, since
50# it uses the standard spelling in this object file, not the MinGW one.
51
52# CHECK2: Name: exportfn1
53# CHECK2: Name: exportfn2
54# CHECK2: Name: exportfn3
55
56# CHECK2-DEF: EXPORTS
57# CHECK2-DEF: exportfn1 @3
58# CHECK2-DEF: exportfn2 @4
59# CHECK2-DEF: exportfn3 @5
Martin Storsjob40ccc12017-10-19 06:56:0460
61# Test ignoring certain object files and libs.
62
63# RUN: echo -e ".global foobar\n.global DllMainCRTStartup\n.text\nDllMainCRTStartup:\nret\nfoobar:\ncall mingwfunc\ncall crtfunc\nret\n" > %t.main.s
64# RUN: llvm-mc -triple=x86_64-windows-gnu %t.main.s -filetype=obj -o %t.main.obj
65# RUN: mkdir -p %T/libs
66# RUN: echo -e ".global mingwfunc\n.text\nmingwfunc:\nret\n" > %T/libs/mingwfunc.s
67# RUN: llvm-mc -triple=x86_64-windows-gnu %T/libs/mingwfunc.s -filetype=obj -o %T/libs/mingwfunc.o
Chris Jackson1a721eb2018-08-02 11:33:5468# RUN: rm -f %T/libs/libmingwex.a
Martin Storsjob40ccc12017-10-19 06:56:0469# RUN: llvm-ar rcs %T/libs/libmingwex.a %T/libs/mingwfunc.o
70# RUN: echo -e ".global crtfunc\n.text\ncrtfunc:\nret\n" > %T/libs/crtfunc.s
71# RUN: llvm-mc -triple=x86_64-windows-gnu %T/libs/crtfunc.s -filetype=obj -o %T/libs/crt2.o
72# RUN: lld-link -out:%t.dll -dll -entry:DllMainCRTStartup %t.main.obj -lldmingw %T/libs/crt2.o %T/libs/libmingwex.a -output-def:%t.def
73# RUN: echo "EOF" >> %t.def
74# RUN: cat %t.def | FileCheck -check-prefix=CHECK-EXCLUDE %s
75
76# CHECK-EXCLUDE: EXPORTS
77# CHECK-EXCLUDE-NEXT: foobar @1
78# CHECK-EXCLUDE-NEXT: EOF
Martin Storsjofe3eda92017-11-16 07:22:4479
Martin Storsjoa47957a2018-09-04 20:56:5680# Test that libraries included with -wholearchive: are autoexported, even if
81# they are in a library that otherwise normally would be excluded.
82
83# RUN: lld-link -out:%t.dll -dll -entry:DllMainCRTStartup %t.main.obj -lldmingw %T/libs/crt2.o -wholearchive:%T/libs/libmingwex.a -output-def:%t.def
84# RUN: echo "EOF" >> %t.def
85# RUN: cat %t.def | FileCheck -check-prefix=CHECK-WHOLEARCHIVE %s
86
87# CHECK-WHOLEARCHIVE: EXPORTS
88# CHECK-WHOLEARCHIVE-NEXT: foobar @1
89# CHECK-WHOLEARCHIVE-NEXT: mingwfunc @2
90# CHECK-WHOLEARCHIVE-NEXT: EOF
91
Martin Storsjofe3eda92017-11-16 07:22:4492# Test that we handle import libraries together with -opt:noref.
93
94# RUN: yaml2obj < %p/Inputs/hello32.yaml > %t.obj
95# 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
96# RUN: echo "EOF" >> %t.def
97# RUN: cat %t.def | FileCheck -check-prefix=CHECK-IMPLIB %s
98
99# CHECK-IMPLIB: EXPORTS
100# CHECK-IMPLIB-NEXT: main@0 @1
101# CHECK-IMPLIB-NEXT: EOF