1 # RUN: yaml2obj %s -o %t.obj
2 # RUN: lld-link %t.obj -nodefaultlib -entry:main -debug -out:%t.exe -pdb:%t.pdb
3 # RUN: llvm-pdbutil dump -symbols -globals %t.pdb | FileCheck %s
5 # To regenerate the object file:
7 # struct Foo { int x; };
8 # typedef struct Foo UDT_Foo;
9 # UDT_Foo global_foo = {42};
10 # int main() { return global_foo.x; }
11 # $ cl -c -Z7 symbol-types.c
13 # Note that the type of 'global' goes from 0x1005 in the object file to 0x1004
14 # in the PDB because the LF_FUNC_ID is moved to the id stream.
16 # CHECK-LABEL: Global Symbols
17 # CHECK-NEXT: ============================================================
19 # CHECK-NEXT: 48 | S_PROCREF [size = 20] `main`
20 # CHECK-NEXT: module = 1, sum name = 0, offset = 116
21 # CHECK-NEXT: 96 | S_UDT [size = 16] `UDT_Foo`
22 # CHECK-NEXT: original type = 0x1004
23 # CHECK-NEXT: 112 | S_UDT [size = 12] `Foo`
24 # CHECK-NEXT: original type = 0x1004
25 # CHECK-NEXT: 68 | S_GDATA32 [size = 28] `global_foo`
26 # CHECK-NEXT: type = 0x1004 (Foo), addr = 0003:0000
29 # CHECK: ============================================================
30 # CHECK-LABEL: Mod 0000 | `{{.*}}pdb-symbol-types.yaml.tmp.obj`:
31 # CHECK: 4 | S_OBJNAME [size = 52] sig=0, `C:\src\llvm-project\build\symbol-types.obj`
32 # CHECK: 56 | S_COMPILE3 [size = 60]
33 # CHECK: machine = intel x86-x64, Ver = Microsoft (R) Optimizing Compiler, language = c
34 # CHECK: frontend = 19.0.24215.1, backend = 19.0.24215.1
35 # CHECK: flags = security checks | hot patchable
36 # CHECK: 116 | S_GPROC32 [size = 44] `main`
37 # CHECK: parent = 0, end = 192, addr = 0001:0000, code size = 7
38 # CHECK: debug start = 0, debug end = 6, flags = none
39 # CHECK: 160 | S_FRAMEPROC [size = 32]
40 # CHECK: size = 0, padding size = 0, offset to padding = 0
41 # CHECK: bytes of callee saved registers = 0, exception handler addr = 0000:0000
42 # CHECK: flags = has async eh | opt speed
43 # CHECK: 192 | S_END [size = 4]
44 # CHECK: 196 | S_BUILDINFO [size = 8] BuildId = `0x100A`
45 # CHECK-LABEL: Mod 0001 | `* Linker *`:
49 Machine: IMAGE_FILE_MACHINE_AMD64
53 Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ]
55 SectionData: 2020202F44454641554C544C49423A224C4942434D5422202F44454641554C544C49423A224F4C444E414D45532220
57 Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ]
65 ObjectName: 'C:\src\llvm-project\build\symbol-types.obj'
68 Flags: [ SecurityChecks, HotPatch ]
78 Version: 'Microsoft (R) Optimizing Compiler'
94 BytesOfCalleeSavedRegisters: 0
95 OffsetOfExceptionHandler: 0
96 SectionIdOfExceptionHandler: 0
97 Flags: [ AsynchronousExceptionHandling, OptimizedForSpeed ]
106 - FileName: 'c:\src\llvm-project\build\symbol-types.c'
126 DisplayName: global_foo
137 - FileName: 'c:\src\llvm-project\build\symbol-types.c'
139 Checksum: F833E1A4909FF6FEC5689A664F3BE725
142 - 'c:\src\llvm-project\build\symbol-types.c'
149 - VirtualAddress: 164
151 Type: IMAGE_REL_AMD64_SECREL
152 - VirtualAddress: 168
154 Type: IMAGE_REL_AMD64_SECTION
155 - VirtualAddress: 220
157 Type: IMAGE_REL_AMD64_SECREL
158 - VirtualAddress: 224
160 Type: IMAGE_REL_AMD64_SECTION
161 - VirtualAddress: 284
162 SymbolName: global_foo
163 Type: IMAGE_REL_AMD64_SECREL
164 - VirtualAddress: 288
165 SymbolName: global_foo
166 Type: IMAGE_REL_AMD64_SECTION
168 Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ]
189 Options: [ None, ForwardReference, HasUniqueName ]
192 UniqueName: '.?AUFoo@@'
207 Options: [ None, HasUniqueName ]
210 UniqueName: '.?AUFoo@@'
217 String: 'c:\src\llvm-project\build\symbol-types.c'
218 - Kind: LF_UDT_SRC_LINE
226 String: 'C:\src\llvm-project\build'
230 String: 'C:\PROGRA~2\MICROS~1.0\VC\Bin\amd64\cl.exe'
234 String: '-c -Z7 -MT -IC:\PROGRA~2\MICROS~1.0\VC\include -IC:\PROGRA~2\MICROS~1.0\VC\atlmfc\include -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.14393.0\ucrt -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.14393.0\shared -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.14393.0\um'
235 - Kind: LF_SUBSTR_LIST
237 StringIndices: [ 4106 ]
241 String: ' -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.14393.0\winrt -TC -X'
245 String: symbol-types.c
249 String: 'C:\src\llvm-project\build\vc140.pdb'
252 ArgIndices: [ 4104, 4105, 4109, 4110, 4108 ]
254 Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ]
256 SectionData: 2A000000
258 Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
260 SectionData: 8B0500000000C3
263 SymbolName: global_foo
264 Type: IMAGE_REL_AMD64_REL32
269 SimpleType: IMAGE_SYM_TYPE_NULL
270 ComplexType: IMAGE_SYM_DTYPE_NULL
271 StorageClass: IMAGE_SYM_CLASS_STATIC
275 SimpleType: IMAGE_SYM_TYPE_NULL
276 ComplexType: IMAGE_SYM_DTYPE_NULL
277 StorageClass: IMAGE_SYM_CLASS_STATIC
281 SimpleType: IMAGE_SYM_TYPE_NULL
282 ComplexType: IMAGE_SYM_DTYPE_NULL
283 StorageClass: IMAGE_SYM_CLASS_STATIC
286 NumberOfRelocations: 0
287 NumberOfLinenumbers: 0
293 SimpleType: IMAGE_SYM_TYPE_NULL
294 ComplexType: IMAGE_SYM_DTYPE_NULL
295 StorageClass: IMAGE_SYM_CLASS_STATIC
298 NumberOfRelocations: 6
299 NumberOfLinenumbers: 0
305 SimpleType: IMAGE_SYM_TYPE_NULL
306 ComplexType: IMAGE_SYM_DTYPE_NULL
307 StorageClass: IMAGE_SYM_CLASS_STATIC
310 NumberOfRelocations: 0
311 NumberOfLinenumbers: 0
317 SimpleType: IMAGE_SYM_TYPE_NULL
318 ComplexType: IMAGE_SYM_DTYPE_NULL
319 StorageClass: IMAGE_SYM_CLASS_STATIC
322 NumberOfRelocations: 0
323 NumberOfLinenumbers: 0
329 SimpleType: IMAGE_SYM_TYPE_NULL
330 ComplexType: IMAGE_SYM_DTYPE_NULL
331 StorageClass: IMAGE_SYM_CLASS_EXTERNAL
335 SimpleType: IMAGE_SYM_TYPE_NULL
336 ComplexType: IMAGE_SYM_DTYPE_NULL
337 StorageClass: IMAGE_SYM_CLASS_STATIC
340 NumberOfRelocations: 1
341 NumberOfLinenumbers: 0
347 SimpleType: IMAGE_SYM_TYPE_NULL
348 ComplexType: IMAGE_SYM_DTYPE_FUNCTION
349 StorageClass: IMAGE_SYM_CLASS_EXTERNAL