1 # RUN: yaml2obj %p/Inputs/export.yaml -o %t.obj
3 # RUN: lld-link /out:%t.dll /dll %t.obj /export:exportfn1 /export:exportfn2
4 # RUN: llvm-objdump -p %t.dll | FileCheck --check-prefix=CHECK1 %s
7 CHECK1-NEXT: DLL name: export.test.tmp.dll
8 CHECK1-NEXT: Ordinal base: 1
9 CHECK1-NEXT: Ordinal RVA Name
10 CHECK1-NEXT: 1 0x1008 exportfn1
11 CHECK1-NEXT: 2 0x1010 exportfn2
13 # RUN: lld-link /out:%t.dll /dll %t.obj /export:exportfn1,@5 /export:exportfn2
14 # RUN: llvm-objdump -p %t.dll | FileCheck --check-prefix=CHECK2 %s
17 CHECK2-NEXT: DLL name: export.test.tmp.dll
18 CHECK2-NEXT: Ordinal base: 5
19 CHECK2-NEXT: Ordinal RVA Name
20 CHECK2-NEXT: 5 0x1008 exportfn1
21 CHECK2-NEXT: 6 0x1010 exportfn2
22 CHECK2-NEXT: 7 0x1010 exportfn3
24 # RUN: lld-link /out:%t.dll /dll %t.obj /export:exportfn1,@5,noname /export:exportfn2
25 # RUN: llvm-objdump -p %t.dll | FileCheck --check-prefix=CHECK3 %s
28 CHECK3-NEXT: DLL name: export.test.tmp.dll
29 CHECK3-NEXT: Ordinal base: 5
30 CHECK3-NEXT: Ordinal RVA Name
32 CHECK3-NEXT: 6 0x1010 exportfn2
34 # RUN: lld-link /out:%t.dll /dll %t.obj /export:f1=exportfn1 /export:f2=exportfn2 /implib:%t.lib
35 # RUN: llvm-objdump -p %t.dll | FileCheck --check-prefix=CHECK4 %s
36 # RUN: llvm-nm %t.lib | FileCheck -check-prefix=CHECK4-NM %s
39 CHECK4-NEXT: DLL name: export.test.tmp.dll
40 CHECK4-NEXT: Ordinal base: 1
41 CHECK4-NEXT: Ordinal RVA Name
42 CHECK4-NEXT: 1 0x1010 exportfn3
43 CHECK4-NEXT: 2 0x1008 f1
44 CHECK4-NEXT: 3 0x1010 f2
45 CHECK4-NM: 00000000 T f1
46 CHECK4-NM: 00000000 T f2
48 # RUN: echo "EXPORTS exportfn1 @3" > %t.def
49 # RUN: echo "fn2=exportfn2 @2" >> %t.def
50 # RUN: lld-link /out:%t.dll /dll %t.obj /def:%t.def
51 # RUN: llvm-objdump -p %t.dll | FileCheck --check-prefix=CHECK5 %s
54 CHECK5-NEXT: DLL name: export.test.tmp.dll
55 CHECK5-NEXT: Ordinal base: 2
56 CHECK5-NEXT: Ordinal RVA Name
57 CHECK5-NEXT: 2 0x1010 fn2
58 CHECK5-NEXT: 3 0x1008 exportfn1
59 CHECK5-NEXT: 4 0x1010 exportfn3
61 # RUN: lld-link /out:%t.DLL /dll %t.obj /export:exportfn1 /export:exportfn2 \
62 # RUN: /export:exportfn1 /export:exportfn2,@5 >& %t.log
63 # RUN: FileCheck -check-prefix=CHECK6 %s < %t.log
65 CHECK6: duplicate /export option: exportfn2
66 CHECK6-NOT: duplicate /export option: exportfn1
68 # RUN: llvm-nm -M %t.lib | FileCheck --check-prefix=SYMTAB %s
70 SYMTAB: __imp_exportfn1 in export.test.tmp.DLL
71 SYMTAB: __imp_exportfn2 in export.test.tmp.DLL
72 SYMTAB: __imp_exportfn3 in export.test.tmp.DLL
73 SYMTAB: exportfn1 in export.test.tmp.DLL
74 SYMTAB: exportfn2 in export.test.tmp.DLL
75 SYMTAB: exportfn3 in export.test.tmp.DLL
77 # RUN: lld-link /out:%t.dll /dll %t.obj /export:foo=kernel32.foobar
78 # RUN: llvm-objdump -p %t.dll | FileCheck --check-prefix=FORWARDER %s
79 # RUN: llvm-nm -M %t.lib | FileCheck --check-prefix=SYMTAB-FWD %s
81 # RUN: echo "EXPORTS foo=kernel32.foobar" > %t.def
82 # RUN: lld-link /out:%t-def.dll /dll %t.obj /def:%t.def
83 # RUN: llvm-objdump -p %t-def.dll | FileCheck --check-prefix=FORWARDER %s
84 # RUN: llvm-nm -M %t-def.lib | FileCheck --check-prefix=SYMTAB-FWD %s
86 FORWARDER: Export Table:
87 FORWARDER: DLL name: export.test.tmp
88 FORWARDER: Ordinal base: 1
89 FORWARDER: Ordinal RVA Name
90 FORWARDER: 1 0x1010 exportfn
91 FORWARDER: 2 foo (forwarded to kernel32.foobar)
93 SYMTAB-FWD: __imp_exportfn3 in export.test.tmp
94 SYMTAB-FWD-NEXT: __imp_foo in export.test.tmp
95 SYMTAB-FWD-NEXT: exportfn3 in export.test.tmp
96 SYMTAB-FWD-NEXT: foo in export.test.tmp
98 # RUN: lld-link /out:%t-fwd-priv.dll /dll %t.obj /export:foo=kernel32.foobar,DATA,PRIVATE
99 # RUN: llvm-objdump -p %t-fwd-priv.dll | FileCheck --check-prefix=FORWARDER %s
100 # RUN: llvm-nm -M %t-fwd-priv.lib | FileCheck --check-prefix=SYMTAB-FWD-PRIV %s
102 SYMTAB-FWD-PRIV: __imp_exportfn3 in export.test.tmp-fwd-priv
103 SYMTAB-FWD-PRIV-NOT: __imp_foo
104 SYMTAB-FWD-PRIV-NEXT: exportfn3 in export.test.tmp-fwd-priv
105 SYMTAB-FWD-PRIV-NOT: foo
107 # RUN: echo "EXPORTS foo=kernel32.foobar DATA PRIVATE" > %t-fwd-priv.def
108 # RUN: lld-link /out:%t-fwd-priv-def.dll /dll %t.obj /def:%t-fwd-priv.def
109 # RUN: llvm-objdump -p %t-fwd-priv-def.dll | FileCheck --check-prefix=FORWARDER %s
110 # RUN: llvm-nm -M %t-fwd-priv-def.lib | FileCheck --check-prefix=SYMTAB-FWD-PRIV %s
112 # RUN: lld-link /out:%t-fwd-ord.dll /dll %t.obj /export:foo=kernel32.foobar,@3,NONAME
113 # RUN: llvm-objdump -p %t-fwd-ord.dll | FileCheck --check-prefix=FORWARDER-ORD %s
114 # RUN: llvm-nm -M %t-fwd-ord.lib | FileCheck --check-prefix=SYMTAB-FWD %s
116 FORWARDER-ORD: Export Table:
117 FORWARDER-ORD-NEXT: DLL name: export.test.tmp-fwd-ord
118 FORWARDER-ORD-NEXT: Ordinal base: 3
119 FORWARDER-ORD-NEXT: Ordinal RVA Name
120 FORWARDER-ORD-NEXT: 3 (forwarded to kernel32.foobar)
121 FORWARDER-ORD-NEXT: 4 0x1010 exportfn3
123 # RUN: echo "EXPORTS foo=kernel32.foobar @3 NONAME" > %t-fwd-ord.def
124 # RUN: lld-link /out:%t-fwd-ord-def.dll /dll %t.obj /def:%t-fwd-ord.def
125 # RUN: llvm-objdump -p %t-fwd-ord-def.dll | FileCheck --check-prefix=FORWARDER-ORD %s
126 # RUN: llvm-nm -M %t-fwd-ord-def.lib | FileCheck --check-prefix=SYMTAB-FWD %s
128 # RUN: lld-link /out:%t.dll /dll %t.obj /merge:.rdata=.text /export:exportfn1 /export:exportfn2
129 # RUN: llvm-objdump -p %t.dll | FileCheck --check-prefix=MERGE --match-full-lines %s
131 MERGE: DLL name: export.test.tmp.dll
132 MERGE: Ordinal RVA Name
133 MERGE-NEXT: 1 0x1008 exportfn1
134 MERGE-NEXT: 2 0x1010 exportfn2