llvm-project
120 строк · 4.2 Кб
1# REQUIRES: x86
2
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
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
9
10# CHECK: Name:
11# CHECK-SAME: comdatFunc
12# CHECK-NEXT: Name: dataSym
13# CHECK-NEXT: Name: foobar
14# CHECK-EMPTY:
15
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
22
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
29
30.global _foobar
31.global _DllMainCRTStartup@12
32.global _dataSym
33.global _unexported
34.global __imp__unexported
35.global .refptr._foobar
36.global _comdatFunc
37.text
38_DllMainCRTStartup@12:
39ret
40_foobar:
41ret
42_unexported:
43ret
44.section .text$_comdatFunc,"xr",one_only,_comdatFunc
45_comdatFunc:
46ret
47.data
48_dataSym:
49.int 4
50__imp__unexported:
51.int _unexported
52.refptr._foobar:
53.int _foobar
54
55# Test specifying -export-all-symbols, on an object file that contains
56# dllexport directive for some of the symbols.
57
58# RUN: yaml2obj %p/Inputs/export.yaml -o %t.obj
59#
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
63
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
67
68# Note, this will actually export _DllMainCRTStartup as well, since
69# it uses the standard spelling in this object file, not the MinGW one.
70
71# CHECK2: Name: exportfn1
72# CHECK2: Name: exportfn2
73# CHECK2: Name: exportfn3
74
75# CHECK2-DEF: EXPORTS
76# CHECK2-DEF: exportfn1 @3
77# CHECK2-DEF: exportfn2 @4
78# CHECK2-DEF: exportfn3 @5
79
80# Test ignoring certain object files and libs.
81
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
94
95# CHECK-EXCLUDE: EXPORTS
96# CHECK-EXCLUDE-NEXT: foobar @1
97# CHECK-EXCLUDE-NEXT: EOF
98
99# Test that libraries included with -wholearchive: are autoexported, even if
100# they are in a library that otherwise normally would be excluded.
101
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
105
106# CHECK-WHOLEARCHIVE: EXPORTS
107# CHECK-WHOLEARCHIVE-NEXT: foobar @1
108# CHECK-WHOLEARCHIVE-NEXT: mingwfunc @2
109# CHECK-WHOLEARCHIVE-NEXT: EOF
110
111# Test that we handle import libraries together with -opt:noref.
112
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
117
118# CHECK-IMPLIB: EXPORTS
119# CHECK-IMPLIB-NEXT: main@0 @1
120# CHECK-IMPLIB-NEXT: EOF
121