[memprof] Remove an unused using directive (#117004)
[llvm-project.git] / lld / test / COFF / export32.test
blob5bb5fd36ef2afaae8ecc4e0e12d5400cd9d3a42c
1 # RUN: yaml2obj %s -o %t.obj
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
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
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
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
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
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
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
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
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
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
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
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
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
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
79 # CHECK6:     duplicate /export option: _exportfn2
80 # CHECK6-NOT: duplicate /export option: _exportfn1
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
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
92 --- !COFF
93 header:
94   Machine:         IMAGE_FILE_MACHINE_I386
95   Characteristics: []
96 sections:
97   - Name:            .text
98     Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
99     Alignment:       4
100     SectionData:     B800000000506800000000680000000050E80000000050E800000000
101   - Name:            .drectve
102     Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ]
103     Alignment:       1
104     SectionData:     2f6578706f72743a5f6578706f7274666e3300  # /export:_exportfn3
105 symbols:
106   - Name:            .text
107     Value:           0
108     SectionNumber:   1
109     SimpleType:      IMAGE_SYM_TYPE_NULL
110     ComplexType:     IMAGE_SYM_DTYPE_NULL
111     StorageClass:    IMAGE_SYM_CLASS_STATIC
112     SectionDefinition:
113       Length:          28
114       NumberOfRelocations: 4
115       NumberOfLinenumbers: 0
116       CheckSum:        0
117       Number:          0
118   - Name:            __DllMainCRTStartup@12
119     Value:           0
120     SectionNumber:   1
121     SimpleType:      IMAGE_SYM_TYPE_NULL
122     ComplexType:     IMAGE_SYM_DTYPE_NULL
123     StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
124   - Name:            _exportfn1
125     Value:           8
126     SectionNumber:   1
127     SimpleType:      IMAGE_SYM_TYPE_NULL
128     ComplexType:     IMAGE_SYM_DTYPE_NULL
129     StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
130   - Name:            _exportfn2@4
131     Value:           16
132     SectionNumber:   1
133     SimpleType:      IMAGE_SYM_TYPE_NULL
134     ComplexType:     IMAGE_SYM_DTYPE_NULL
135     StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
136   - Name:            _exportfn3
137     Value:           16
138     SectionNumber:   1
139     SimpleType:      IMAGE_SYM_TYPE_NULL
140     ComplexType:     IMAGE_SYM_DTYPE_NULL
141     StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
142   - Name:            '?mangled@@YAHXZ'
143     Value:           16
144     SectionNumber:   1
145     SimpleType:      IMAGE_SYM_TYPE_NULL
146     ComplexType:     IMAGE_SYM_DTYPE_NULL
147     StorageClass:    IMAGE_SYM_CLASS_EXTERNAL