[LLD][COFF] Fix TypeServerSource matcher with more than one collision
[llvm-project.git] / lld / test / COFF / export32.test
blob7c8f831d9654ebc508e71bf7fbecbe74ade34a12
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:      DLL name: export32.test.tmp.dll
12 # CHECK1:      Ordinal      RVA  Name
13 # CHECK1-NEXT:       0        0
14 # CHECK1-NEXT:       1   0x1008  exportfn1
15 # CHECK1-NEXT:       2   0x1010  exportfn2
17 # HEADER-MERGE: ExportTableRVA: 0x2000
18 # HEADER-MERGE-NEXT: ExportTableSize: 0x7E
19 # HEADER-MERGE: Name: .rdata
20 # HEADER-MERGE-NEXT: VirtualSize: 0x7E
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:      DLL name: export32.test.tmp.dll
29 # CHECK2:      Ordinal      RVA  Name
30 # CHECK2-NEXT:       0        0
31 # CHECK2-NEXT:       1        0
32 # CHECK2-NEXT:       2        0
33 # CHECK2-NEXT:       3        0
34 # CHECK2-NEXT:       4        0
35 # CHECK2-NEXT:       5   0x1008  exportfn1
36 # CHECK2-NEXT:       6   0x1010  exportfn2
37 # CHECK2-NEXT:       7   0x1010  exportfn3
38 # CHECK2-NEXT:       8   0x1010  mangled
40 # RUN: lld-link -safeseh:no /out:%t.dll /dll %t.obj /export:exportfn1,@5,noname /export:exportfn2
41 # RUN: llvm-objdump -p %t.dll | FileCheck --check-prefix=CHECK3 %s
43 # CHECK3:      Export Table:
44 # CHECK3:      DLL name: export32.test.tmp.dll
45 # CHECK3:      Ordinal      RVA  Name
46 # CHECK3-NEXT:       0        0
47 # CHECK3-NEXT:       1        0
48 # CHECK3-NEXT:       2        0
49 # CHECK3-NEXT:       3        0
50 # CHECK3-NEXT:       4        0
51 # CHECK3-NEXT:       5   0x1008
52 # CHECK3-NEXT:       6   0x1010  exportfn2
54 # RUN: lld-link -safeseh:no /out:%t.dll /dll %t.obj /export:f1=exportfn1 /export:f2=exportfn2
55 # RUN: llvm-objdump -p %t.dll | FileCheck --check-prefix=CHECK4 %s
57 # CHECK4:      Export Table:
58 # CHECK4:      DLL name: export32.test.tmp.dll
59 # CHECK4:      Ordinal      RVA  Name
60 # CHECK4-NEXT:       0        0
61 # CHECK4-NEXT:       1   0x1010  exportfn3
62 # CHECK4-NEXT:       2   0x1008  f1
63 # CHECK4-NEXT:       3   0x1010  f2
65 # RUN: echo "EXPORTS exportfn1 @3" > %t.def
66 # RUN: echo "fn2=exportfn2 @2" >> %t.def
67 # RUN: lld-link -safeseh:no /out:%t.dll /dll %t.obj /def:%t.def
68 # RUN: llvm-objdump -p %t.dll | FileCheck --check-prefix=CHECK5 %s
70 # RUN: echo "EXPORTS exportfn1 @ 3" > %t.def
71 # RUN: echo "fn2=exportfn2 @ 2" >> %t.def
72 # RUN: lld-link -safeseh:no /out:%t.dll /dll %t.obj /def:%t.def
73 # RUN: llvm-objdump -p %t.dll | FileCheck --check-prefix=CHECK5 %s
75 # CHECK5:      Export Table:
76 # CHECK5:      DLL name: export32.test.tmp.dll
77 # CHECK5:      Ordinal      RVA  Name
78 # CHECK5-NEXT:       0        0
79 # CHECK5-NEXT:       1        0
80 # CHECK5-NEXT:       2   0x1010  fn2
81 # CHECK5-NEXT:       3   0x1008  exportfn1
82 # CHECK5-NEXT:       4   0x1010  exportfn3
84 # RUN: lld-link -safeseh:no /out:%t.dll /dll %t.obj /export:exportfn1 /export:exportfn2 \
85 # RUN:   /export:exportfn1 /export:exportfn2,@5 >& %t.log
86 # RUN: FileCheck -check-prefix=CHECK6 %s < %t.log
88 # CHECK6:     duplicate /export option: _exportfn2
89 # CHECK6-NOT: duplicate /export option: _exportfn1
91 # RUN: lld-link -safeseh:no /out:%t.dll /dll %t.obj /export:foo=mangled
92 # RUN: llvm-objdump -p %t.dll | FileCheck --check-prefix=CHECK7 %s
94 # CHECK7:      Export Table:
95 # CHECK7:      DLL name: export32.test.tmp.dll
96 # CHECK7:      Ordinal      RVA  Name
97 # CHECK7-NEXT:       0        0
98 # CHECK7-NEXT:       1        0
99 # CHECK7-NEXT:       2   0x1010  foo
101 --- !COFF
102 header:
103   Machine:         IMAGE_FILE_MACHINE_I386
104   Characteristics: []
105 sections:
106   - Name:            .text
107     Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
108     Alignment:       4
109     SectionData:     B800000000506800000000680000000050E80000000050E800000000
110   - Name:            .drectve
111     Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ]
112     Alignment:       1
113     SectionData:     2f6578706f72743a5f6578706f7274666e3300  # /export:_exportfn3
114 symbols:
115   - Name:            .text
116     Value:           0
117     SectionNumber:   1
118     SimpleType:      IMAGE_SYM_TYPE_NULL
119     ComplexType:     IMAGE_SYM_DTYPE_NULL
120     StorageClass:    IMAGE_SYM_CLASS_STATIC
121     SectionDefinition:
122       Length:          28
123       NumberOfRelocations: 4
124       NumberOfLinenumbers: 0
125       CheckSum:        0
126       Number:          0
127   - Name:            __DllMainCRTStartup@12
128     Value:           0
129     SectionNumber:   1
130     SimpleType:      IMAGE_SYM_TYPE_NULL
131     ComplexType:     IMAGE_SYM_DTYPE_NULL
132     StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
133   - Name:            _exportfn1
134     Value:           8
135     SectionNumber:   1
136     SimpleType:      IMAGE_SYM_TYPE_NULL
137     ComplexType:     IMAGE_SYM_DTYPE_NULL
138     StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
139   - Name:            _exportfn2@4
140     Value:           16
141     SectionNumber:   1
142     SimpleType:      IMAGE_SYM_TYPE_NULL
143     ComplexType:     IMAGE_SYM_DTYPE_NULL
144     StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
145   - Name:            _exportfn3
146     Value:           16
147     SectionNumber:   1
148     SimpleType:      IMAGE_SYM_TYPE_NULL
149     ComplexType:     IMAGE_SYM_DTYPE_NULL
150     StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
151   - Name:            '?mangled@@YAHXZ'
152     Value:           16
153     SectionNumber:   1
154     SimpleType:      IMAGE_SYM_TYPE_NULL
155     ComplexType:     IMAGE_SYM_DTYPE_NULL
156     StorageClass:    IMAGE_SYM_CLASS_EXTERNAL