llvm-project
350 строк · 12.4 Кб
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
4
5# To regenerate the object file:
6# $ cat symbol-types.c
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
12
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.
15
16# CHECK-LABEL: Global Symbols
17# CHECK-NEXT: ============================================================
18# CHECK-NEXT: Records
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
27
28# CHECK: Symbols
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 *`:
46
47--- !COFF48header:49Machine: IMAGE_FILE_MACHINE_AMD6450Characteristics: [ ]51sections:52- Name: .drectve53Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ]54Alignment: 155SectionData: 2020202F44454641554C544C49423A224C4942434D5422202F44454641554C544C49423A224F4C444E414D4553222056- Name: '.debug$S'57Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ]58Alignment: 159Subsections:60- !Symbols61Records:62- Kind: S_OBJNAME63ObjNameSym:64Signature: 065ObjectName: 'C:\src\llvm-project\build\symbol-types.obj'66- Kind: S_COMPILE367Compile3Sym:68Flags: [ SecurityChecks, HotPatch ]69Machine: X6470FrontendMajor: 1971FrontendMinor: 072FrontendBuild: 2421573FrontendQFE: 174BackendMajor: 1975BackendMinor: 076BackendBuild: 2421577BackendQFE: 178Version: 'Microsoft (R) Optimizing Compiler'79- !Symbols80Records:81- Kind: S_GPROC32_ID82ProcSym:83CodeSize: 784DbgStart: 085DbgEnd: 686FunctionType: 409887Flags: [ ]88DisplayName: main89- Kind: S_FRAMEPROC90FrameProcSym:91TotalFrameBytes: 092PaddingFrameBytes: 093OffsetToPadding: 094BytesOfCalleeSavedRegisters: 095OffsetOfExceptionHandler: 096SectionIdOfExceptionHandler: 097Flags: [ AsynchronousExceptionHandling, OptimizedForSpeed ]98- Kind: S_PROC_ID_END99ScopeEndSym:100- !Lines101CodeSize: 7102Flags: [ ]103RelocOffset: 0104RelocSegment: 0105Blocks:106- FileName: 'c:\src\llvm-project\build\symbol-types.c'107Lines:108- Offset: 0109LineStart: 4110IsStatement: true111EndDelta: 0112- Offset: 0113LineStart: 5114IsStatement: true115EndDelta: 0116- Offset: 6117LineStart: 6118IsStatement: true119EndDelta: 0120Columns:121- !Symbols122Records:123- Kind: S_GDATA32124DataSym:125Type: 4101126DisplayName: global_foo127- Kind: S_UDT128UDTSym:129Type: 4101130UDTName: UDT_Foo131- Kind: S_UDT132UDTSym:133Type: 4101134UDTName: Foo135- !FileChecksums136Checksums:137- FileName: 'c:\src\llvm-project\build\symbol-types.c'138Kind: MD5139Checksum: F833E1A4909FF6FEC5689A664F3BE725140- !StringTable141Strings:142- 'c:\src\llvm-project\build\symbol-types.c'143- !Symbols144Records:145- Kind: S_BUILDINFO146BuildInfoSym:147BuildId: 4111148Relocations:149- VirtualAddress: 164150SymbolName: main151Type: IMAGE_REL_AMD64_SECREL152- VirtualAddress: 168153SymbolName: main154Type: IMAGE_REL_AMD64_SECTION155- VirtualAddress: 220156SymbolName: main157Type: IMAGE_REL_AMD64_SECREL158- VirtualAddress: 224159SymbolName: main160Type: IMAGE_REL_AMD64_SECTION161- VirtualAddress: 284162SymbolName: global_foo163Type: IMAGE_REL_AMD64_SECREL164- VirtualAddress: 288165SymbolName: global_foo166Type: IMAGE_REL_AMD64_SECTION167- Name: '.debug$T'168Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ]169Alignment: 1170Types:171- Kind: LF_ARGLIST172ArgList:173ArgIndices: [ 0 ]174- Kind: LF_PROCEDURE175Procedure:176ReturnType: 116177CallConv: NearC178Options: [ None ]179ParameterCount: 0180ArgumentList: 4096181- Kind: LF_FUNC_ID182FuncId:183ParentScope: 0184FunctionType: 4097185Name: main186- Kind: LF_STRUCTURE187Class:188MemberCount: 0189Options: [ None, ForwardReference, HasUniqueName ]190FieldList: 0191Name: Foo192UniqueName: '.?AUFoo@@'193DerivationList: 0194VTableShape: 0195Size: 0196- Kind: LF_FIELDLIST197FieldList:198- Kind: LF_MEMBER199DataMember:200Attrs: 3201Type: 116202FieldOffset: 0203Name: x204- Kind: LF_STRUCTURE205Class:206MemberCount: 1207Options: [ None, HasUniqueName ]208FieldList: 4100209Name: Foo210UniqueName: '.?AUFoo@@'211DerivationList: 0212VTableShape: 0213Size: 4214- Kind: LF_STRING_ID215StringId:216Id: 0217String: 'c:\src\llvm-project\build\symbol-types.c'218- Kind: LF_UDT_SRC_LINE219UdtSourceLine:220UDT: 4101221SourceFile: 4102222LineNumber: 1223- Kind: LF_STRING_ID224StringId:225Id: 0226String: 'C:\src\llvm-project\build'227- Kind: LF_STRING_ID228StringId:229Id: 0230String: 'C:\PROGRA~2\MICROS~1.0\VC\Bin\amd64\cl.exe'231- Kind: LF_STRING_ID232StringId:233Id: 0234String: '-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_LIST236StringList:237StringIndices: [ 4106 ]238- Kind: LF_STRING_ID239StringId:240Id: 4107241String: ' -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.14393.0\winrt -TC -X'242- Kind: LF_STRING_ID243StringId:244Id: 0245String: symbol-types.c246- Kind: LF_STRING_ID247StringId:248Id: 0249String: 'C:\src\llvm-project\build\vc140.pdb'250- Kind: LF_BUILDINFO251BuildInfo:252ArgIndices: [ 4104, 4105, 4109, 4110, 4108 ]253- Name: .data254Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ]255Alignment: 4256SectionData: 2A000000257- Name: '.text$mn'258Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]259Alignment: 16260SectionData: 8B0500000000C3261Relocations:262- VirtualAddress: 2263SymbolName: global_foo264Type: IMAGE_REL_AMD64_REL32265symbols:266- Name: '@comp.id'267Value: 17063575268SectionNumber: -1269SimpleType: IMAGE_SYM_TYPE_NULL270ComplexType: IMAGE_SYM_DTYPE_NULL271StorageClass: IMAGE_SYM_CLASS_STATIC272- Name: '@feat.00'273Value: 2147484048274SectionNumber: -1275SimpleType: IMAGE_SYM_TYPE_NULL276ComplexType: IMAGE_SYM_DTYPE_NULL277StorageClass: IMAGE_SYM_CLASS_STATIC278- Name: .drectve279Value: 0280SectionNumber: 1281SimpleType: IMAGE_SYM_TYPE_NULL282ComplexType: IMAGE_SYM_DTYPE_NULL283StorageClass: IMAGE_SYM_CLASS_STATIC284SectionDefinition:285Length: 47286NumberOfRelocations: 0287NumberOfLinenumbers: 0288CheckSum: 0289Number: 0290- Name: '.debug$S'291Value: 0292SectionNumber: 2293SimpleType: IMAGE_SYM_TYPE_NULL294ComplexType: IMAGE_SYM_DTYPE_NULL295StorageClass: IMAGE_SYM_CLASS_STATIC296SectionDefinition:297Length: 432298NumberOfRelocations: 6299NumberOfLinenumbers: 0300CheckSum: 0301Number: 0302- Name: '.debug$T'303Value: 0304SectionNumber: 3305SimpleType: IMAGE_SYM_TYPE_NULL306ComplexType: IMAGE_SYM_DTYPE_NULL307StorageClass: IMAGE_SYM_CLASS_STATIC308SectionDefinition:309Length: 732310NumberOfRelocations: 0311NumberOfLinenumbers: 0312CheckSum: 0313Number: 0314- Name: .data315Value: 0316SectionNumber: 4317SimpleType: IMAGE_SYM_TYPE_NULL318ComplexType: IMAGE_SYM_DTYPE_NULL319StorageClass: IMAGE_SYM_CLASS_STATIC320SectionDefinition:321Length: 4322NumberOfRelocations: 0323NumberOfLinenumbers: 0324CheckSum: 3482275674325Number: 0326- Name: global_foo327Value: 0328SectionNumber: 4329SimpleType: IMAGE_SYM_TYPE_NULL330ComplexType: IMAGE_SYM_DTYPE_NULL331StorageClass: IMAGE_SYM_CLASS_EXTERNAL332- Name: '.text$mn'333Value: 0334SectionNumber: 5335SimpleType: IMAGE_SYM_TYPE_NULL336ComplexType: IMAGE_SYM_DTYPE_NULL337StorageClass: IMAGE_SYM_CLASS_STATIC338SectionDefinition:339Length: 7340NumberOfRelocations: 1341NumberOfLinenumbers: 0342CheckSum: 3635526833343Number: 0344- Name: main345Value: 0346SectionNumber: 5347SimpleType: IMAGE_SYM_TYPE_NULL348ComplexType: IMAGE_SYM_DTYPE_FUNCTION349StorageClass: IMAGE_SYM_CLASS_EXTERNAL350...
351