Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / COFF / symtab.test
blob48c749957a422a0ccacc115d40648a3c10a03b09
1 # RUN: yaml2obj %s -o %t.obj
2 # RUN: lld-link /debug:dwarf /out:%t.exe /entry:main %t.obj %p/Inputs/std64.lib
3 # RUN: llvm-readobj --symbols %t.exe | FileCheck %s
4 # RUN: lld-link /debug:dwarf /opt:noref /out:%t.exe /entry:main %t.obj %p/Inputs/std64.lib
5 # RUN: llvm-readobj --symbols %t.exe | FileCheck %s
6 # RUN: lld-link /debug:symtab /opt:noref /out:%t.exe /entry:main %t.obj %p/Inputs/std64.lib
7 # RUN: llvm-readobj --symbols %t.exe | FileCheck %s
9 # RUN: lld-link /debug /out:%t.exe /entry:main %t.obj %p/Inputs/std64.lib
10 # RUN: llvm-readobj --symbols %t.exe | FileCheck -check-prefix=NO %s
12 # CHECK:      Symbols [
13 # CHECK-NEXT:   Symbol {
14 # CHECK-NEXT:     Name: MessageBoxA
15 # CHECK-NEXT:     Value: 80
16 # CHECK-NEXT:     Section: .text (1)
17 # CHECK-NEXT:     BaseType: Null (0x0)
18 # CHECK-NEXT:     ComplexType: Function (0x2)
19 # CHECK-NEXT:     StorageClass: External (0x2)
20 # CHECK-NEXT:     AuxSymbolCount: 0
21 # CHECK-NEXT:   }
22 # CHECK-NEXT:   Symbol {
23 # CHECK-NEXT:     Name: __imp_MessageBoxA
24 # CHECK-NEXT:     Value:
25 # CHECK-NEXT:     Section: .rdata (2)
26 # CHECK-NEXT:     BaseType: Null (0x0)
27 # CHECK-NEXT:     ComplexType: Null (0x0)
28 # CHECK-NEXT:     StorageClass: External (0x2)
29 # CHECK-NEXT:     AuxSymbolCount: 0
30 # CHECK-NEXT:   }
31 # CHECK-NEXT:   Symbol {
32 # CHECK-NEXT:     Name: ExitProcess
33 # CHECK-NEXT:     Value: 64
34 # CHECK-NEXT:     Section: .text (1)
35 # CHECK-NEXT:     BaseType: Null (0x0)
36 # CHECK-NEXT:     ComplexType: Function (0x2)
37 # CHECK-NEXT:     StorageClass: External (0x2)
38 # CHECK-NEXT:     AuxSymbolCount: 0
39 # CHECK-NEXT:   }
40 # CHECK-NEXT:   Symbol {
41 # CHECK-NEXT:     Name: __imp_ExitProcess
42 # CHECK-NEXT:     Value:
43 # CHECK-NEXT:     Section: .rdata (2)
44 # CHECK-NEXT:     BaseType: Null (0x0)
45 # CHECK-NEXT:     ComplexType: Null (0x0)
46 # CHECK-NEXT:     StorageClass: External (0x2)
47 # CHECK-NEXT:     AuxSymbolCount: 0
48 # CHECK-NEXT:   }
49 # CHECK-NEXT:   Symbol {
50 # CHECK-NEXT:     Name: message
51 # CHECK-NEXT:     Value: 6
52 # CHECK-NEXT:     Section: .text2
53 # CHECK-NEXT:     BaseType: Null (0x0)
54 # CHECK-NEXT:     ComplexType: Null (0x0)
55 # CHECK-NEXT:     StorageClass: Static (0x3)
56 # CHECK-NEXT:     AuxSymbolCount: 0
57 # CHECK-NEXT:   }
58 # CHECK-NEXT:   Symbol {
59 # CHECK-NEXT:     Name: main
60 # CHECK-NEXT:     Value: 0
61 # CHECK-NEXT:     Section: .text (1)
62 # CHECK-NEXT:     BaseType: Null (0x0)
63 # CHECK-NEXT:     ComplexType: Null (0x0)
64 # CHECK-NEXT:     StorageClass: External (0x2)
65 # CHECK-NEXT:     AuxSymbolCount: 0
66 # CHECK-NEXT:   }
67 # CHECK-NEXT:   Symbol {
68 # CHECK-NEXT:     Name: caption
69 # CHECK-NEXT:     Value: 0
70 # CHECK-NEXT:     Section: .text2
71 # CHECK-NEXT:     BaseType: Null (0x0)
72 # CHECK-NEXT:     ComplexType: Null (0x0)
73 # CHECK-NEXT:     StorageClass: Static (0x3)
74 # CHECK-NEXT:     AuxSymbolCount: 0
75 # CHECK-NEXT:   }
76 # CHECK-NEXT:   Symbol {
77 # CHECK-NEXT:     Name: abs_symbol
78 # CHECK-NEXT:     Value: 3735928559
79 # CHECK-NEXT:     Section: IMAGE_SYM_ABSOLUTE (-1)
80 # CHECK-NEXT:     BaseType: Null (0x0)
81 # CHECK-NEXT:     ComplexType: Null (0x0)
82 # CHECK-NEXT:     StorageClass: External (0x2)
83 # CHECK-NEXT:     AuxSymbolCount: 0
84 # CHECK-NEXT:   }
85 # CHECK-NEXT: ]
87 # NO:       Symbols [
88 # NO-NEXT:  ]
90 --- !COFF
91 header:
92   Machine:         IMAGE_FILE_MACHINE_AMD64
93   Characteristics: []
94 sections:
95   - Name:            .text
96     Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
97     Alignment:       4096
98     SectionData:     B800000000000000005068000000000000000068000000000000000050E8000000000000000050E8000000000000000050E80000000000000000
99     Relocations:
100       - VirtualAddress:  0
101         SymbolName:      abs_symbol
102         Type:            IMAGE_REL_AMD64_ADDR64
103       - VirtualAddress:  7
104         SymbolName:      caption
105         Type:            IMAGE_REL_AMD64_ADDR64
106       - VirtualAddress:  12
107         SymbolName:      message
108         Type:            IMAGE_REL_AMD64_ADDR64
109       - VirtualAddress:  18
110         SymbolName:      MessageBoxA
111         Type:            IMAGE_REL_AMD64_REL32
112       - VirtualAddress:  24
113         SymbolName:      ExitProcess
114         Type:            IMAGE_REL_AMD64_REL32
115       - VirtualAddress:  30
116         SymbolName:      __ImageBase
117         Type:            IMAGE_REL_AMD64_ADDR64
118   - Name:            .text2
119     Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
120     Alignment:       4096
121     SectionData:     B800000000000000005068000000000000000068000000000000000050E8000000000000000050E8000000000000000050E80000000000000000
122     Relocations:
123       - VirtualAddress:  0
124         SymbolName:      abs_symbol
125         Type:            IMAGE_REL_AMD64_ADDR64
126       - VirtualAddress:  7
127         SymbolName:      caption
128         Type:            IMAGE_REL_AMD64_ADDR64
129       - VirtualAddress:  12
130         SymbolName:      message
131         Type:            IMAGE_REL_AMD64_ADDR64
132       - VirtualAddress:  18
133         SymbolName:      MessageBoxA
134         Type:            IMAGE_REL_AMD64_REL32
135       - VirtualAddress:  24
136         SymbolName:      ExitProcess
137         Type:            IMAGE_REL_AMD64_REL32
138       - VirtualAddress:  30
139         SymbolName:      __ImageBase
140         Type:            IMAGE_REL_AMD64_ADDR64
141   - Name:            .data
142     Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ]
143     Alignment:       4
144     SectionData:     48656C6C6F0048656C6C6F20576F726C6400
145 symbols:
146   - Name:            "@comp.id"
147     Value:           10394907
148     SectionNumber:   65535
149     SimpleType:      IMAGE_SYM_TYPE_NULL
150     ComplexType:     IMAGE_SYM_DTYPE_NULL
151     StorageClass:    IMAGE_SYM_CLASS_STATIC
152   - Name:            .text
153     Value:           0
154     SectionNumber:   1
155     SimpleType:      IMAGE_SYM_TYPE_NULL
156     ComplexType:     IMAGE_SYM_DTYPE_NULL
157     StorageClass:    IMAGE_SYM_CLASS_STATIC
158     SectionDefinition:
159       Length:          28
160       NumberOfRelocations: 6
161       NumberOfLinenumbers: 0
162       CheckSum:        0
163       Number:          0
164   - Name:            .text2
165     Value:           0
166     SectionNumber:   1
167     SimpleType:      IMAGE_SYM_TYPE_NULL
168     ComplexType:     IMAGE_SYM_DTYPE_NULL
169     StorageClass:    IMAGE_SYM_CLASS_STATIC
170     SectionDefinition:
171       Length:          28
172       NumberOfRelocations: 6
173       NumberOfLinenumbers: 0
174       CheckSum:        0
175       Number:          0
176   - Name:            .data
177     Value:           0
178     SectionNumber:   3
179     SimpleType:      IMAGE_SYM_TYPE_NULL
180     ComplexType:     IMAGE_SYM_DTYPE_NULL
181     StorageClass:    IMAGE_SYM_CLASS_STATIC
182     SectionDefinition:
183       Length:          18
184       NumberOfRelocations: 0
185       NumberOfLinenumbers: 0
186       CheckSum:        0
187       Number:          0
188   - Name:            MessageBoxA
189     Value:           0
190     SectionNumber:   0
191     SimpleType:      IMAGE_SYM_TYPE_NULL
192     ComplexType:     IMAGE_SYM_DTYPE_NULL
193     StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
194   - Name:            ExitProcess
195     Value:           0
196     SectionNumber:   0
197     SimpleType:      IMAGE_SYM_TYPE_NULL
198     ComplexType:     IMAGE_SYM_DTYPE_NULL
199     StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
200   - Name:            message
201     Value:           6
202     SectionNumber:   2
203     SimpleType:      IMAGE_SYM_TYPE_NULL
204     ComplexType:     IMAGE_SYM_DTYPE_NULL
205     StorageClass:    IMAGE_SYM_CLASS_STATIC
206   - Name:            main
207     Value:           0
208     SectionNumber:   1
209     SimpleType:      IMAGE_SYM_TYPE_NULL
210     ComplexType:     IMAGE_SYM_DTYPE_NULL
211     StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
212   - Name:            caption
213     Value:           0
214     SectionNumber:   2
215     SimpleType:      IMAGE_SYM_TYPE_NULL
216     ComplexType:     IMAGE_SYM_DTYPE_NULL
217     StorageClass:    IMAGE_SYM_CLASS_STATIC
218   - Name:            abs_symbol
219     Value:           0xDEADBEEF
220     SectionNumber:   -1
221     SimpleType:      IMAGE_SYM_TYPE_NULL
222     ComplexType:     IMAGE_SYM_DTYPE_NULL
223     StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
224   - Name:            __ImageBase
225     Value:           0
226     SectionNumber:   0
227     SimpleType:      IMAGE_SYM_TYPE_NULL
228     ComplexType:     IMAGE_SYM_DTYPE_NULL
229     StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
230   - Name:            .Ltemp_symbol
231     Value:           1
232     SectionNumber:   1
233     SimpleType:      IMAGE_SYM_TYPE_NULL
234     ComplexType:     IMAGE_SYM_DTYPE_NULL
235     StorageClass:    IMAGE_SYM_CLASS_LABEL