llvm-project
148 строк · 5.4 Кб
1# RUN: yaml2obj %s -o %t.obj
2#
3# RUN: lld-link -safeseh:no /out:%t.dll /dll %t.obj /export:exportfn1 /export:exportfn2
4# RUN: llvm-objdump -p %t.dll | FileCheck --check-prefix=CHECK1 %s
5#
6# RUN: lld-link -safeseh:no /out:%t.dll /dll %t.obj /export:exportfn1 /export:exportfn2 /merge:.edata=.rdata
7# RUN: llvm-objdump -p %t.dll | FileCheck --check-prefix=CHECK1 %s
8# RUN: llvm-readobj --file-headers --sections %t.dll | FileCheck -check-prefix=HEADER-MERGE %s
9
10# CHECK1: Export Table:
11# CHECK1-NEXT: DLL name: export32.test.tmp.dll
12# CHECK1-NEXT: Ordinal base: 1
13# CHECK1-NEXT: Ordinal RVA Name
14# CHECK1-NEXT: 1 0x1008 exportfn1
15# CHECK1-NEXT: 2 0x1010 exportfn2
16
17# HEADER-MERGE: ExportTableRVA: 0x2000
18# HEADER-MERGE-NEXT: ExportTableSize: 0x7A
19# HEADER-MERGE: Name: .rdata
20# HEADER-MERGE-NEXT: VirtualSize: 0x7A
21# HEADER-MERGE-NEXT: VirtualAddress: 0x2000
22
23# RUN: lld-link -safeseh:no /out:%t.dll /dll %t.obj /export:exportfn1,@5 \
24# RUN: /export:exportfn2 /export:mangled
25# RUN: llvm-objdump -p %t.dll | FileCheck --check-prefix=CHECK2 %s
26
27# CHECK2: Export Table:
28# CHECK2-NEXT: DLL name: export32.test.tmp.dll
29# CHECK2-NEXT: Ordinal base: 5
30# CHECK2-NEXT: Ordinal RVA Name
31# CHECK2-NEXT: 5 0x1008 exportfn1
32# CHECK2-NEXT: 6 0x1010 exportfn2
33# CHECK2-NEXT: 7 0x1010 exportfn3
34# CHECK2-NEXT: 8 0x1010 mangled
35
36# RUN: lld-link -safeseh:no /out:%t.dll /dll %t.obj /export:exportfn1,@5,noname /export:exportfn2
37# RUN: llvm-objdump -p %t.dll | FileCheck --check-prefix=CHECK3 %s
38
39# CHECK3: Export Table:
40# CHECK3-NEXT: DLL name: export32.test.tmp.dll
41# CHECK3-NEXT: Ordinal base: 5
42# CHECK3-NEXT: Ordinal RVA Name
43# CHECK3-NEXT: 5 0x1008
44# CHECK3-NEXT: 6 0x1010 exportfn2
45
46# RUN: lld-link -safeseh:no /out:%t.dll /dll %t.obj /export:f1=exportfn1 /export:f2=exportfn2
47# RUN: llvm-objdump -p %t.dll | FileCheck --check-prefix=CHECK4 %s
48
49# CHECK4: Export Table:
50# CHECK4-NEXT: DLL name: export32.test.tmp.dll
51# CHECK4-NEXT: Ordinal base: 1
52# CHECK4-NEXT: Ordinal RVA Name
53# CHECK4-NEXT: 1 0x1010 exportfn3
54# CHECK4-NEXT: 2 0x1008 f1
55# CHECK4-NEXT: 3 0x1010 f2
56
57# RUN: echo "EXPORTS exportfn1 @3" > %t.def
58# RUN: echo "fn2=exportfn2 @2" >> %t.def
59# RUN: lld-link -safeseh:no /out:%t.dll /dll %t.obj /def:%t.def
60# RUN: llvm-objdump -p %t.dll | FileCheck --check-prefix=CHECK5 %s
61
62# RUN: echo "EXPORTS exportfn1 @ 3" > %t.def
63# RUN: echo "fn2=exportfn2 @ 2" >> %t.def
64# RUN: lld-link -safeseh:no /out:%t.dll /dll %t.obj /def:%t.def
65# RUN: llvm-objdump -p %t.dll | FileCheck --check-prefix=CHECK5 %s
66
67# CHECK5: Export Table:
68# CHECK5-NEXT: DLL name: export32.test.tmp.dll
69# CHECK5-NEXT: Ordinal base: 2
70# CHECK5-NEXT: Ordinal RVA Name
71# CHECK5-NEXT: 2 0x1010 fn2
72# CHECK5-NEXT: 3 0x1008 exportfn1
73# CHECK5-NEXT: 4 0x1010 exportfn3
74
75# RUN: lld-link -safeseh:no /out:%t.dll /dll %t.obj /export:exportfn1 /export:exportfn2 \
76# RUN: /export:exportfn1 /export:exportfn2,@5 >& %t.log
77# RUN: FileCheck -check-prefix=CHECK6 %s < %t.log
78
79# CHECK6: duplicate /export option: _exportfn2
80# CHECK6-NOT: duplicate /export option: _exportfn1
81
82# RUN: lld-link -safeseh:no /out:%t.dll /dll %t.obj /export:foo=mangled
83# RUN: llvm-objdump -p %t.dll | FileCheck --check-prefix=CHECK7 %s
84
85# CHECK7: Export Table:
86# CHECK7-NEXT: DLL name: export32.test.tmp.dll
87# CHECK7-NEXT: Ordinal base: 1
88# CHECK7-NEXT: Ordinal RVA Name
89# CHECK7-NEXT: 1 0x1010 exportfn3
90# CHECK7-NEXT: 2 0x1010 foo
91
92--- !COFF
93header:
94Machine: IMAGE_FILE_MACHINE_I386
95Characteristics: []
96sections:
97- Name: .text
98Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
99Alignment: 4
100SectionData: B800000000506800000000680000000050E80000000050E800000000
101- Name: .drectve
102Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ]
103Alignment: 1
104SectionData: 2f6578706f72743a5f6578706f7274666e3300 # /export:_exportfn3
105symbols:
106- Name: .text
107Value: 0
108SectionNumber: 1
109SimpleType: IMAGE_SYM_TYPE_NULL
110ComplexType: IMAGE_SYM_DTYPE_NULL
111StorageClass: IMAGE_SYM_CLASS_STATIC
112SectionDefinition:
113Length: 28
114NumberOfRelocations: 4
115NumberOfLinenumbers: 0
116CheckSum: 0
117Number: 0
118- Name: __DllMainCRTStartup@12
119Value: 0
120SectionNumber: 1
121SimpleType: IMAGE_SYM_TYPE_NULL
122ComplexType: IMAGE_SYM_DTYPE_NULL
123StorageClass: IMAGE_SYM_CLASS_EXTERNAL
124- Name: _exportfn1
125Value: 8
126SectionNumber: 1
127SimpleType: IMAGE_SYM_TYPE_NULL
128ComplexType: IMAGE_SYM_DTYPE_NULL
129StorageClass: IMAGE_SYM_CLASS_EXTERNAL
130- Name: _exportfn2@4
131Value: 16
132SectionNumber: 1
133SimpleType: IMAGE_SYM_TYPE_NULL
134ComplexType: IMAGE_SYM_DTYPE_NULL
135StorageClass: IMAGE_SYM_CLASS_EXTERNAL
136- Name: _exportfn3
137Value: 16
138SectionNumber: 1
139SimpleType: IMAGE_SYM_TYPE_NULL
140ComplexType: IMAGE_SYM_DTYPE_NULL
141StorageClass: IMAGE_SYM_CLASS_EXTERNAL
142- Name: '?mangled@@YAHXZ'
143Value: 16
144SectionNumber: 1
145SimpleType: IMAGE_SYM_TYPE_NULL
146ComplexType: IMAGE_SYM_DTYPE_NULL
147StorageClass: IMAGE_SYM_CLASS_EXTERNAL
148...
149