diff --git a/lld/COFF/PDB.cpp b/lld/COFF/PDB.cpp --- a/lld/COFF/PDB.cpp +++ b/lld/COFF/PDB.cpp @@ -795,6 +795,7 @@ switch (sym.kind()) { case SymbolKind::S_GDATA32: case SymbolKind::S_CONSTANT: + case SymbolKind::S_GTHREAD32: // We really should not be seeing S_PROCREF and S_LPROCREF in the first place // since they are synthesized by the linker in response to S_GPROC32 and // S_LPROC32, but if we do see them, don't put them in the module stream I @@ -816,6 +817,7 @@ switch (sym.kind()) { case SymbolKind::S_CONSTANT: case SymbolKind::S_GDATA32: + case SymbolKind::S_GTHREAD32: // S_LDATA32 goes in both the module stream and the globals stream. case SymbolKind::S_LDATA32: case SymbolKind::S_GPROC32: @@ -840,6 +842,7 @@ case SymbolKind::S_CONSTANT: case SymbolKind::S_UDT: case SymbolKind::S_GDATA32: + case SymbolKind::S_GTHREAD32: case SymbolKind::S_LDATA32: case SymbolKind::S_PROCREF: case SymbolKind::S_LPROCREF: diff --git a/lld/test/COFF/Inputs/pdb-globals.yaml b/lld/test/COFF/Inputs/pdb-globals.yaml --- a/lld/test/COFF/Inputs/pdb-globals.yaml +++ b/lld/test/COFF/Inputs/pdb-globals.yaml @@ -1,5 +1,5 @@ # // YAML Generated from the following source code: -# // Compile with clang-cl /Z7 /GS- /c t.obj pdb-globals.cpp +# // Compile with clang-cl /Z7 /GS- /c a.cpp && obj2yaml a.obj >pdb-globals.yaml # # void *__purecall = 0; # @@ -27,58 +27,77 @@ # // S_UDT # typedef HelloPoint HelloPointTypedef; # +# // S_GTHREAD32 +# thread_local int ThreadLocalVar = 254; +# # int main(int argc, char **argv) { # HelloPointTypedef P; # int N = P.X + P.Y + P.Z; # N += LocalFunc() + GlobalFunc(); # N += *GlobalVar; # N += ConstexprVar; +# N += ThreadLocalVar; +# return N; # } --- !COFF header: - Machine: IMAGE_FILE_MACHINE_I386 + Machine: IMAGE_FILE_MACHINE_AMD64 Characteristics: [ ] sections: - Name: .text Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] Alignment: 16 - SectionData: 5589E5B82B0000005DC3660F1F4400005589E583EC208B450C8B4D088D55F4894DEC89D18945E8E8000000008B4DF4034DF8034DFC894DF08945E4E8000000008945E0E80000000031C98B55E001C20355F08955F0A1000000008B000345F08945F08B45F083C0128945F089C883C4205DC366666666662E0F1F8400000000005589E5B82A0000005DC3 + SectionData: B82B000000C3662E0F1F8400000000004883EC58C7442454000000004889542448894C2444488D4C2438E800000000448B442438448B4C243C4501C8448B4C24404501C844894424344889442428E80000000089442424E800000000448B4424244101C08B4424344401C089442434488B0D000000008B01448B4424344101C044894424348B44243483C012894424348B050000000089C165488B142558000000488B0CCA8B810000000003442434894424348B4424344883C458C30F1F4000B82A000000C3 Relocations: - - VirtualAddress: 40 - SymbolName: '??0HelloPoint@@QAE@XZ' - Type: IMAGE_REL_I386_REL32 - - VirtualAddress: 60 + - VirtualAddress: 43 + SymbolName: '??0HelloPoint@@QEAA@XZ' + Type: IMAGE_REL_AMD64_REL32 + - VirtualAddress: 79 SymbolName: '?LocalFunc@@YAHXZ' - Type: IMAGE_REL_I386_REL32 - - VirtualAddress: 68 + Type: IMAGE_REL_AMD64_REL32 + - VirtualAddress: 88 SymbolName: '?GlobalFunc@@YAHXZ' - Type: IMAGE_REL_I386_REL32 - - VirtualAddress: 86 - SymbolName: '?GlobalVar@@3PBHB' - Type: IMAGE_REL_I386_DIR32 + Type: IMAGE_REL_AMD64_REL32 + - VirtualAddress: 114 + SymbolName: '?GlobalVar@@3PEBHEB' + Type: IMAGE_REL_AMD64_REL32 + - VirtualAddress: 146 + SymbolName: _tls_index + Type: IMAGE_REL_AMD64_REL32 + - VirtualAddress: 167 + SymbolName: '?ThreadLocalVar@@3HA' + Type: IMAGE_REL_AMD64_SECREL - Name: .data Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ] - Alignment: 4 - SectionData: '00000000' + Alignment: 8 + SectionData: '0000000000000000' Relocations: - VirtualAddress: 0 - SymbolName: _ConstantVar - Type: IMAGE_REL_I386_DIR32 + SymbolName: ConstantVar + Type: IMAGE_REL_AMD64_ADDR64 - Name: .bss Characteristics: [ IMAGE_SCN_CNT_UNINITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ] - Alignment: 4 + Alignment: 8 SectionData: '' - SizeOfRawData: 4 + SizeOfRawData: 8 + - Name: .xdata + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: 0104010004A20000 - Name: .text Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] Alignment: 16 - SectionData: 5589E550894DFC8B4DFCC70103000000C7410404000000C741080500000089C883C4045DC3 + SectionData: 5048890C24488B0424C70003000000C7400404000000C740080500000059C3 - Name: .rdata Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ] Alignment: 4 SectionData: '11000000' + - Name: '.tls$' + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ] + Alignment: 4 + SectionData: FE000000 - Name: .drectve Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ] Alignment: 1 @@ -86,88 +105,233 @@ - Name: '.debug$S' Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] Alignment: 4 - SectionData: 04000000F10000002F0000002D003C1101000000070006000000000000007017000000000000636C616E672076657273696F6E20362E302E30200000F100000036000000300047110000000000000000000000000A00000000000000000000000210000000000000000000476C6F62616C46756E630002004F110000F20000002000000000000000000000000A0000000000000001000000140000000000000010000000F1000000B60000002A00471100000000000000000000000062000000000000000000000006100000000000000000006D61696E000D003E1174000000010061726763001200451116000000080000001F000000000053000D003E11031000000100617267760012004511160000000C0000001F000000000053000A003E1107100000000050001200451116000000F4FFFFFF1F000000000053000A003E117400000000004E001200451116000000F0FFFFFF1F0000000000530002004F110000F200000050000000000000000000000062000000000000000700000044000000000000001E0000000F0000001F0000001C000000200000002800000021000000450000002200000052000000230000005B00000024000000F1000000350000002F0046110000000000000000000000000A00000000000000000000000F100000000000000000004C6F63616C46756E630002004F11000000F20000002000000000000000000000000A000000000000000100000014000000000000000D000000F10000004B00000017000D11030400000000000000005F5F7075726563616C6C0016000D1111100000000000000000476C6F62616C5661720018000C1110100000000000000000436F6E7374616E745661720000F10000002D000000180008110710000048656C6C6F506F696E745479706564656600110008110910000048656C6C6F506F696E7400000000F4000000080000000100000000000000F30000003800000000643A5C7372635C6C6C766D2D6D6F6E6F5C6C6C645C746573745C636F66665C696E707574735C7064622D676C6F62616C732E6370700000 + SectionData: 04000000F10000008400000082003C1101000000D0000B00000000000000F82A000000000000636C616E672076657273696F6E2031312E302E30202868747470733A2F2F6769746875622E636F6D2F6C6C766D2F6C6C766D2D70726F6A6563742E6769742066356231333031636538353735663664383265383730333161316135343835633333363337613933290000F100000058000000320047110000000000000000000000000600000000000000000000000210000000000000000000476C6F62616C46756E630000001E0012100000000000000000000000000000000000000000000000000000000002004F11F200000020000000000000000000000006000000000000000100000014000000000000000D000000F1000000C80000002A004711000000000000000000000000AC000000000000000000000006100000000000000000006D61696E001E001210580000000000000000000000000000000000000000000040010000000E003E117400000001006172676300000E004211440000002A000000000092000E003E110310000001006172677600000E004211480000002A000000000092000A003E1109100000000050000E004211380000002A000000000092000A003E117400000000004E000E004211340000002A0000000000920002004F11F2000000580000000000000000000000AC00000000000000080000004C000000000000001E0000001A0000001F0000001F000000200000003E000000210000005F0000002200000075000000230000008000000024000000A300000025000000F1000000580000003200461100000000000000000000000006000000000000000000000010100000000000000000004C6F63616C46756E63000000001E0012100000000000000000000000000000000000000000000000000000000002004F11F200000020000000000000000000000006000000000000000100000014000000000000000A000000F1000000880000001A000D11030600000000000000005F5F7075726563616C6C0000000016000D1112100000000000000000476C6F62616C566172001E001311740000000000000000005468726561644C6F63616C5661720000000016000711111000001200436F6E73746578707256617200001A000C1111100000000000000000436F6E7374616E74566172000000F1000000300000001A0008110910000048656C6C6F506F696E7454797065646566000000120008110910000048656C6C6F506F696E740000F4000000180000000100000010017639038016E1B39B4DF1A599A76BF8290000F30000002000000000463A5C6C6C766D2D70726F6A6563745C5F5F746573745C612E637070000000F10000000800000006004C1115100000 Subsections: - !Symbols Records: - Kind: S_COMPILE3 Compile3Sym: Flags: [ ] - Machine: Pentium3 - FrontendMajor: 6 + Machine: X64 + FrontendMajor: 11 FrontendMinor: 0 FrontendBuild: 0 FrontendQFE: 0 - BackendMajor: 6000 + BackendMajor: 11000 BackendMinor: 0 BackendBuild: 0 BackendQFE: 0 - Version: 'clang version 6.0.0 ' + Version: 'clang version 11.0.0 (https://github.com/llvm/llvm-project.git f5b1301ce8575f6d82e87031a1a5485c33637a93)' + - !Symbols + Records: - Kind: S_GPROC32_ID ProcSym: - CodeSize: 10 + CodeSize: 6 DbgStart: 0 DbgEnd: 0 FunctionType: 4098 Flags: [ ] DisplayName: GlobalFunc + - Kind: S_FRAMEPROC + FrameProcSym: + TotalFrameBytes: 0 + PaddingFrameBytes: 0 + OffsetToPadding: 0 + BytesOfCalleeSavedRegisters: 0 + OffsetOfExceptionHandler: 0 + SectionIdOfExceptionHandler: 0 + Flags: [ ] - Kind: S_PROC_ID_END - ScopeEndSym: + ScopeEndSym: {} + - !Lines + CodeSize: 6 + Flags: [ ] + RelocOffset: 0 + RelocSegment: 0 + Blocks: + - FileName: 'F:\llvm-project\__test\a.cpp' + Lines: + - Offset: 0 + LineStart: 13 + IsStatement: false + EndDelta: 0 + Columns: [] + - !Symbols + Records: - Kind: S_GPROC32_ID ProcSym: - CodeSize: 98 + CodeSize: 172 DbgStart: 0 DbgEnd: 0 FunctionType: 4102 Flags: [ ] DisplayName: main + - Kind: S_FRAMEPROC + FrameProcSym: + TotalFrameBytes: 88 + PaddingFrameBytes: 0 + OffsetToPadding: 0 + BytesOfCalleeSavedRegisters: 0 + OffsetOfExceptionHandler: 0 + SectionIdOfExceptionHandler: 0 + Flags: [ ] - Kind: S_LOCAL LocalSym: Type: 116 Flags: [ IsParameter ] VarName: argc + - Kind: S_DEFRANGE_FRAMEPOINTER_REL + DefRangeFramePointerRelSym: + Offset: 68 + Range: + OffsetStart: 42 + ISectStart: 0 + Range: 146 + Gaps: [] - Kind: S_LOCAL LocalSym: Type: 4099 Flags: [ IsParameter ] VarName: argv + - Kind: S_DEFRANGE_FRAMEPOINTER_REL + DefRangeFramePointerRelSym: + Offset: 72 + Range: + OffsetStart: 42 + ISectStart: 0 + Range: 146 + Gaps: [] - Kind: S_LOCAL LocalSym: - Type: 4103 + Type: 4105 Flags: [ ] VarName: P + - Kind: S_DEFRANGE_FRAMEPOINTER_REL + DefRangeFramePointerRelSym: + Offset: 56 + Range: + OffsetStart: 42 + ISectStart: 0 + Range: 146 + Gaps: [] - Kind: S_LOCAL LocalSym: Type: 116 Flags: [ ] VarName: N + - Kind: S_DEFRANGE_FRAMEPOINTER_REL + DefRangeFramePointerRelSym: + Offset: 52 + Range: + OffsetStart: 42 + ISectStart: 0 + Range: 146 + Gaps: [] - Kind: S_PROC_ID_END - ScopeEndSym: + ScopeEndSym: {} + - !Lines + CodeSize: 172 + Flags: [ ] + RelocOffset: 0 + RelocSegment: 0 + Blocks: + - FileName: 'F:\llvm-project\__test\a.cpp' + Lines: + - Offset: 0 + LineStart: 30 + IsStatement: false + EndDelta: 0 + - Offset: 26 + LineStart: 31 + IsStatement: false + EndDelta: 0 + - Offset: 31 + LineStart: 32 + IsStatement: false + EndDelta: 0 + - Offset: 62 + LineStart: 33 + IsStatement: false + EndDelta: 0 + - Offset: 95 + LineStart: 34 + IsStatement: false + EndDelta: 0 + - Offset: 117 + LineStart: 35 + IsStatement: false + EndDelta: 0 + - Offset: 128 + LineStart: 36 + IsStatement: false + EndDelta: 0 + - Offset: 163 + LineStart: 37 + IsStatement: false + EndDelta: 0 + Columns: [] + - !Symbols + Records: - Kind: S_LPROC32_ID ProcSym: - CodeSize: 10 + CodeSize: 6 DbgStart: 0 DbgEnd: 0 - FunctionType: 4111 + FunctionType: 4112 Flags: [ ] DisplayName: LocalFunc + - Kind: S_FRAMEPROC + FrameProcSym: + TotalFrameBytes: 0 + PaddingFrameBytes: 0 + OffsetToPadding: 0 + BytesOfCalleeSavedRegisters: 0 + OffsetOfExceptionHandler: 0 + SectionIdOfExceptionHandler: 0 + Flags: [ ] - Kind: S_PROC_ID_END - ScopeEndSym: + ScopeEndSym: {} + - !Lines + CodeSize: 6 + Flags: [ ] + RelocOffset: 0 + RelocSegment: 0 + Blocks: + - FileName: 'F:\llvm-project\__test\a.cpp' + Lines: + - Offset: 0 + LineStart: 10 + IsStatement: false + EndDelta: 0 + Columns: [] + - !Symbols + Records: - Kind: S_GDATA32 DataSym: - Type: 1027 + Type: 1539 DisplayName: __purecall - Kind: S_GDATA32 DataSym: - Type: 4113 + Type: 4114 DisplayName: GlobalVar + - Kind: S_GTHREAD32 + ThreadLocalDataSym: + Type: 116 + DisplayName: ThreadLocalVar + - Kind: S_CONSTANT + ConstantSym: + Type: 4113 + Value: 18 + Name: ConstexprVar - Kind: S_LDATA32 DataSym: - Type: 4112 + Type: 4113 DisplayName: ConstantVar + - !Symbols + Records: - Kind: S_UDT UDTSym: - Type: 4103 + Type: 4105 UDTName: HelloPointTypedef - Kind: S_UDT UDTSym: @@ -175,95 +339,108 @@ UDTName: HelloPoint - !FileChecksums Checksums: - - FileName: 'd:\src\llvm-mono\lld\test\coff\inputs\pdb-globals.cpp' - Kind: None - Checksum: '' + - FileName: 'F:\llvm-project\__test\a.cpp' + Kind: MD5 + Checksum: 7639038016E1B39B4DF1A599A76BF829 - !StringTable Strings: - - 'd:\src\llvm-mono\lld\test\coff\inputs\pdb-globals.cpp' + - 'F:\llvm-project\__test\a.cpp' + - '' - '' + - !Symbols + Records: + - Kind: S_BUILDINFO + BuildInfoSym: + BuildId: 4117 Relocations: - - VirtualAddress: 100 + - VirtualAddress: 184 SymbolName: '?GlobalFunc@@YAHXZ' - Type: IMAGE_REL_I386_SECREL - - VirtualAddress: 104 + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 188 SymbolName: '?GlobalFunc@@YAHXZ' - Type: IMAGE_REL_I386_SECTION - - VirtualAddress: 132 + Type: IMAGE_REL_AMD64_SECTION + - VirtualAddress: 248 SymbolName: '?GlobalFunc@@YAHXZ' - Type: IMAGE_REL_I386_SECREL - - VirtualAddress: 136 + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 252 SymbolName: '?GlobalFunc@@YAHXZ' - Type: IMAGE_REL_I386_SECTION - - VirtualAddress: 204 - SymbolName: _main - Type: IMAGE_REL_I386_SECREL - - VirtualAddress: 208 - SymbolName: _main - Type: IMAGE_REL_I386_SECTION - - VirtualAddress: 243 - SymbolName: .text - Type: IMAGE_REL_I386_SECREL - - VirtualAddress: 247 - SymbolName: .text - Type: IMAGE_REL_I386_SECTION - - VirtualAddress: 278 - SymbolName: .text - Type: IMAGE_REL_I386_SECREL - - VirtualAddress: 282 - SymbolName: .text - Type: IMAGE_REL_I386_SECTION - - VirtualAddress: 310 - SymbolName: .text - Type: IMAGE_REL_I386_SECREL - - VirtualAddress: 314 - SymbolName: .text - Type: IMAGE_REL_I386_SECTION - - VirtualAddress: 342 - SymbolName: .text - Type: IMAGE_REL_I386_SECREL - - VirtualAddress: 346 - SymbolName: .text - Type: IMAGE_REL_I386_SECTION - - VirtualAddress: 364 - SymbolName: _main - Type: IMAGE_REL_I386_SECREL - - VirtualAddress: 368 - SymbolName: _main - Type: IMAGE_REL_I386_SECTION - - VirtualAddress: 484 + Type: IMAGE_REL_AMD64_SECTION + - VirtualAddress: 320 + SymbolName: main + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 324 + SymbolName: main + Type: IMAGE_REL_AMD64_SECTION + - VirtualAddress: 388 + SymbolTableIndex: 0 + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 392 + SymbolTableIndex: 0 + Type: IMAGE_REL_AMD64_SECTION + - VirtualAddress: 420 + SymbolTableIndex: 0 + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 424 + SymbolTableIndex: 0 + Type: IMAGE_REL_AMD64_SECTION + - VirtualAddress: 448 + SymbolTableIndex: 0 + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 452 + SymbolTableIndex: 0 + Type: IMAGE_REL_AMD64_SECTION + - VirtualAddress: 476 + SymbolTableIndex: 0 + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 480 + SymbolTableIndex: 0 + Type: IMAGE_REL_AMD64_SECTION + - VirtualAddress: 496 + SymbolName: main + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 500 + SymbolName: main + Type: IMAGE_REL_AMD64_SECTION + - VirtualAddress: 624 SymbolName: '?LocalFunc@@YAHXZ' - Type: IMAGE_REL_I386_SECREL - - VirtualAddress: 488 + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 628 SymbolName: '?LocalFunc@@YAHXZ' - Type: IMAGE_REL_I386_SECTION - - VirtualAddress: 516 + Type: IMAGE_REL_AMD64_SECTION + - VirtualAddress: 688 SymbolName: '?LocalFunc@@YAHXZ' - Type: IMAGE_REL_I386_SECREL - - VirtualAddress: 520 + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 692 SymbolName: '?LocalFunc@@YAHXZ' - Type: IMAGE_REL_I386_SECTION - - VirtualAddress: 564 - SymbolName: '?__purecall@@3PAXA' - Type: IMAGE_REL_I386_SECREL - - VirtualAddress: 568 - SymbolName: '?__purecall@@3PAXA' - Type: IMAGE_REL_I386_SECTION - - VirtualAddress: 589 - SymbolName: '?GlobalVar@@3PBHB' - Type: IMAGE_REL_I386_SECREL - - VirtualAddress: 593 - SymbolName: '?GlobalVar@@3PBHB' - Type: IMAGE_REL_I386_SECTION - - VirtualAddress: 613 - SymbolName: _ConstantVar - Type: IMAGE_REL_I386_SECREL - - VirtualAddress: 617 - SymbolName: _ConstantVar - Type: IMAGE_REL_I386_SECTION + Type: IMAGE_REL_AMD64_SECTION + - VirtualAddress: 736 + SymbolName: '?__purecall@@3PEAXEA' + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 740 + SymbolName: '?__purecall@@3PEAXEA' + Type: IMAGE_REL_AMD64_SECTION + - VirtualAddress: 764 + SymbolName: '?GlobalVar@@3PEBHEB' + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 768 + SymbolName: '?GlobalVar@@3PEBHEB' + Type: IMAGE_REL_AMD64_SECTION + - VirtualAddress: 788 + SymbolName: '?ThreadLocalVar@@3HA' + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 792 + SymbolName: '?ThreadLocalVar@@3HA' + Type: IMAGE_REL_AMD64_SECTION + - VirtualAddress: 844 + SymbolName: ConstantVar + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 848 + SymbolName: ConstantVar + Type: IMAGE_REL_AMD64_SECTION - Name: '.debug$T' Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] Alignment: 4 + SectionData: 0400000006000112000000000E000810740000000000000000100000160001160000000001100000476C6F62616C46756E6300F10A000210700600000C0001000E0001120200000074000000031000000E0008107400000000000200041000001200011600000000051000006D61696E00F3F2F13200051500008002000000000000000000000000000048656C6C6F506F696E74002E3F415548656C6C6F506F696E74404000F2F1260003120D15030074000000000058000D15030074000000040059000D1503007400000008005A0032000515030002020810000000000000000000000C0048656C6C6F506F696E74002E3F415548656C6C6F506F696E74404000F2F12600051600000000463A5C6C6C766D2D70726F6A6563745C5F5F746573745C612E63707000F3F2F10E000616091000000A100000030000000A000210071000000C0401001A00091003000000071000000C10000000020000001000000000000016000216071000000D10000048656C6C6F506F696E7400F10A000210071000000C0001001600011600000000011000004C6F63616C46756E6300F2F10A000110740000000100F2F10A000210111000000C0001001E00051600000000463A5C6C6C766D2D70726F6A6563745C5F5F7465737400F10E00051600000000612E63707000F2F11A00031605001310000000000000141000000000000000000000F2F1 Types: - Kind: LF_ARGLIST ArgList: @@ -282,8 +459,8 @@ Name: GlobalFunc - Kind: LF_POINTER Pointer: - ReferentType: 1136 - Attrs: 32778 + ReferentType: 1648 + Attrs: 65548 - Kind: LF_ARGLIST ArgList: ArgIndices: [ 116, 4099 ] @@ -332,7 +509,7 @@ - Kind: LF_STRUCTURE Class: MemberCount: 3 - Options: [ None, HasUniqueName ] + Options: [ None, HasConstructorOrDestructor, HasUniqueName ] FieldList: 4104 Name: HelloPoint UniqueName: '.?AUHelloPoint@@' @@ -342,23 +519,23 @@ - Kind: LF_STRING_ID StringId: Id: 0 - String: 'd:\src\llvm-mono\lld\test\coff\inputs\pdb-globals.cpp' + String: 'F:\llvm-project\__test\a.cpp' - Kind: LF_UDT_SRC_LINE UdtSourceLine: UDT: 4105 SourceFile: 4106 - LineNumber: 6 + LineNumber: 3 - Kind: LF_POINTER Pointer: ReferentType: 4103 - Attrs: 32778 + Attrs: 66572 - Kind: LF_MFUNCTION MemberFunction: ReturnType: 3 ClassType: 4103 ThisType: 4108 - CallConv: ThisCall - Options: [ None ] + CallConv: NearC + Options: [ None, Constructor ] ParameterCount: 0 ArgumentList: 4096 ThisPointerAdjustment: 0 @@ -367,6 +544,10 @@ ClassType: 4103 FunctionType: 4109 Name: HelloPoint + - Kind: LF_POINTER + Pointer: + ReferentType: 4103 + Attrs: 65548 - Kind: LF_FUNC_ID FuncId: ParentScope: 0 @@ -378,49 +559,126 @@ Modifiers: [ None, Const ] - Kind: LF_POINTER Pointer: - ReferentType: 4112 - Attrs: 32778 + ReferentType: 4113 + Attrs: 65548 + - Kind: LF_STRING_ID + StringId: + Id: 0 + String: 'F:\llvm-project\__test' + - Kind: LF_STRING_ID + StringId: + Id: 0 + String: a.cpp + - Kind: LF_BUILDINFO + BuildInfo: + ArgIndices: [ 4115, 0, 4116, 0, 0 ] + - Name: .pdata + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: 00000000AC00000000000000 + Relocations: + - VirtualAddress: 0 + SymbolName: main + Type: IMAGE_REL_AMD64_ADDR32NB + - VirtualAddress: 4 + SymbolName: main + Type: IMAGE_REL_AMD64_ADDR32NB + - VirtualAddress: 8 + SymbolTableIndex: 6 + Type: IMAGE_REL_AMD64_ADDR32NB + - Name: .llvm_addrsig + Characteristics: [ IMAGE_SCN_LNK_REMOVE ] + Alignment: 1 + SectionData: '20222723' + - Name: .xdata + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: '0101010001020000' - Name: '.debug$S' Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] Alignment: 4 - SectionData: 04000000F1000000650000003C0047110000000000000000000000002500000000000000000000000E1000000000000000000048656C6C6F506F696E743A3A48656C6C6F506F696E74000D003E110C100000010074686973001200451116000000FCFFFFFF0A00000000001B0002004F11000000F20000004000000000000000000000002500000000000000050000003400000000000000060000000A00000007000000100000000800000017000000090000001E00000006000000 + SectionData: 04000000F1000000840000003E0047110000000000000000000000001F00000000000000000000000E1000000000000000000048656C6C6F506F696E743A3A48656C6C6F506F696E740000001E001210080000000000000000000000000000000000000000000040010000000E003E110F10000001007468697300000E00421100000000090000000000160002004F11F20000002000000000000000000000001F0000000000000001000000140000000000000003000000 Subsections: - !Symbols Records: - Kind: S_GPROC32_ID ProcSym: - CodeSize: 37 + CodeSize: 31 DbgStart: 0 DbgEnd: 0 FunctionType: 4110 Flags: [ ] DisplayName: 'HelloPoint::HelloPoint' + - Kind: S_FRAMEPROC + FrameProcSym: + TotalFrameBytes: 8 + PaddingFrameBytes: 0 + OffsetToPadding: 0 + BytesOfCalleeSavedRegisters: 0 + OffsetOfExceptionHandler: 0 + SectionIdOfExceptionHandler: 0 + Flags: [ ] - Kind: S_LOCAL LocalSym: - Type: 4108 + Type: 4111 Flags: [ IsParameter ] VarName: this + - Kind: S_DEFRANGE_FRAMEPOINTER_REL + DefRangeFramePointerRelSym: + Offset: 0 + Range: + OffsetStart: 9 + ISectStart: 0 + Range: 22 + Gaps: [] - Kind: S_PROC_ID_END - ScopeEndSym: + ScopeEndSym: {} + - !Lines + CodeSize: 31 + Flags: [ ] + RelocOffset: 0 + RelocSegment: 0 + Blocks: + - FileName: 'F:\llvm-project\__test\a.cpp' + Lines: + - Offset: 0 + LineStart: 3 + IsStatement: false + EndDelta: 0 + Columns: [] Relocations: - VirtualAddress: 44 - SymbolName: '??0HelloPoint@@QAE@XZ' - Type: IMAGE_REL_I386_SECREL + SymbolName: '??0HelloPoint@@QEAA@XZ' + Type: IMAGE_REL_AMD64_SECREL - VirtualAddress: 48 - SymbolName: '??0HelloPoint@@QAE@XZ' - Type: IMAGE_REL_I386_SECTION - - VirtualAddress: 101 - SymbolName: .text - Type: IMAGE_REL_I386_SECREL - - VirtualAddress: 105 - SymbolName: .text - Type: IMAGE_REL_I386_SECTION - - VirtualAddress: 124 - SymbolName: '??0HelloPoint@@QAE@XZ' - Type: IMAGE_REL_I386_SECREL - - VirtualAddress: 128 - SymbolName: '??0HelloPoint@@QAE@XZ' - Type: IMAGE_REL_I386_SECTION + SymbolName: '??0HelloPoint@@QEAA@XZ' + Type: IMAGE_REL_AMD64_SECTION + - VirtualAddress: 132 + SymbolTableIndex: 8 + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 136 + SymbolTableIndex: 8 + Type: IMAGE_REL_AMD64_SECTION + - VirtualAddress: 152 + SymbolName: '??0HelloPoint@@QEAA@XZ' + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 156 + SymbolName: '??0HelloPoint@@QEAA@XZ' + Type: IMAGE_REL_AMD64_SECTION + - Name: .pdata + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: 000000001F00000000000000 + Relocations: + - VirtualAddress: 0 + SymbolName: '??0HelloPoint@@QEAA@XZ' + Type: IMAGE_REL_AMD64_ADDR32NB + - VirtualAddress: 4 + SymbolName: '??0HelloPoint@@QEAA@XZ' + Type: IMAGE_REL_AMD64_ADDR32NB + - VirtualAddress: 8 + SymbolTableIndex: 11 + Type: IMAGE_REL_AMD64_ADDR32NB symbols: - Name: .text Value: 0 @@ -429,10 +687,10 @@ ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC SectionDefinition: - Length: 138 - NumberOfRelocations: 4 + Length: 198 + NumberOfRelocations: 6 NumberOfLinenumbers: 0 - CheckSum: 3215092891 + CheckSum: 470599849 Number: 1 - Name: .data Value: 0 @@ -441,7 +699,7 @@ ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC SectionDefinition: - Length: 4 + Length: 8 NumberOfRelocations: 1 NumberOfLinenumbers: 0 CheckSum: 0 @@ -453,33 +711,58 @@ ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC SectionDefinition: - Length: 4 + Length: 8 NumberOfRelocations: 0 NumberOfLinenumbers: 0 CheckSum: 0 Number: 3 - - Name: .text + - Name: .xdata Value: 0 SectionNumber: 4 SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC SectionDefinition: - Length: 37 + Length: 8 NumberOfRelocations: 0 NumberOfLinenumbers: 0 - CheckSum: 77530982 + CheckSum: 2787633521 Number: 4 + - Name: .text + Value: 0 + SectionNumber: 5 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 31 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 1433541371 + Number: 5 Selection: IMAGE_COMDAT_SELECT_ANY - - Name: '??0HelloPoint@@QAE@XZ' + - Name: '??0HelloPoint@@QEAA@XZ' Value: 0 - SectionNumber: 4 + SectionNumber: 5 SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_FUNCTION StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: .xdata + Value: 0 + SectionNumber: 13 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 8 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 448359300 + Number: 5 + Selection: IMAGE_COMDAT_SELECT_ASSOCIATIVE - Name: .rdata Value: 0 - SectionNumber: 5 + SectionNumber: 6 SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC @@ -488,10 +771,22 @@ NumberOfRelocations: 0 NumberOfLinenumbers: 0 CheckSum: 3903140090 - Number: 5 + Number: 6 + - Name: '.tls$' + Value: 0 + SectionNumber: 7 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 4 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 1723425172 + Number: 7 - Name: .drectve Value: 0 - SectionNumber: 6 + SectionNumber: 8 SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC @@ -500,46 +795,83 @@ NumberOfRelocations: 0 NumberOfLinenumbers: 0 CheckSum: 149686238 - Number: 6 + Number: 8 - Name: '.debug$S' Value: 0 - SectionNumber: 7 + SectionNumber: 9 SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC SectionDefinition: - Length: 768 - NumberOfRelocations: 26 + Length: 1008 + NumberOfRelocations: 28 NumberOfLinenumbers: 0 - CheckSum: 2940884584 - Number: 7 + CheckSum: 228068427 + Number: 9 - Name: '.debug$S' Value: 0 - SectionNumber: 9 + SectionNumber: 14 SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC SectionDefinition: - Length: 188 + Length: 184 NumberOfRelocations: 6 NumberOfLinenumbers: 0 - CheckSum: 1246640575 - Number: 4 + CheckSum: 3176560104 + Number: 5 Selection: IMAGE_COMDAT_SELECT_ASSOCIATIVE - Name: '.debug$T' Value: 0 - SectionNumber: 8 + SectionNumber: 10 SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC SectionDefinition: - Length: 452 + Length: 516 NumberOfRelocations: 0 NumberOfLinenumbers: 0 - CheckSum: 2561906059 - Number: 8 + CheckSum: 176878986 + Number: 10 + - Name: .pdata + Value: 0 + SectionNumber: 11 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 12 + NumberOfRelocations: 3 + NumberOfLinenumbers: 0 + CheckSum: 4259508931 + Number: 11 + - Name: .pdata + Value: 0 + SectionNumber: 15 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 12 + NumberOfRelocations: 3 + NumberOfLinenumbers: 0 + CheckSum: 2778407815 + Number: 5 + Selection: IMAGE_COMDAT_SELECT_ASSOCIATIVE + - Name: .llvm_addrsig + Value: 0 + SectionNumber: 12 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 4 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 3814325927 + Number: 12 - Name: '@feat.00' - Value: 1 + Value: 0 SectionNumber: -1 SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL @@ -550,34 +882,53 @@ SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_FUNCTION StorageClass: IMAGE_SYM_CLASS_EXTERNAL - - Name: _main + - Name: main Value: 16 SectionNumber: 1 SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_FUNCTION StorageClass: IMAGE_SYM_CLASS_EXTERNAL - Name: '?LocalFunc@@YAHXZ' - Value: 128 + Value: 192 SectionNumber: 1 SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_FUNCTION StorageClass: IMAGE_SYM_CLASS_STATIC - - Name: '?GlobalVar@@3PBHB' + - Name: '?GlobalVar@@3PEBHEB' Value: 0 SectionNumber: 2 SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_EXTERNAL - - Name: '?__purecall@@3PAXA' + - Name: _tls_index + Value: 0 + SectionNumber: 0 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: '?ThreadLocalVar@@3HA' + Value: 0 + SectionNumber: 7 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: '?__purecall@@3PEAXEA' Value: 0 SectionNumber: 3 SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_EXTERNAL - - Name: _ConstantVar + - Name: ConstantVar Value: 0 - SectionNumber: 5 + SectionNumber: 6 SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC + - Name: .file + Value: 0 + SectionNumber: -2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_FILE + File: a.cpp ... diff --git a/lld/test/COFF/pdb-globals.test b/lld/test/COFF/pdb-globals.test --- a/lld/test/COFF/pdb-globals.test +++ b/lld/test/COFF/pdb-globals.test @@ -1,10 +1,10 @@ RUN: yaml2obj %S/Inputs/pdb-globals.yaml > %t.obj -RUN: lld-link /debug /nodefaultlib /entry:main /out:%t.exe /pdb:%t.pdb %t.obj +RUN: lld-link /debug /nodefaultlib /entry:main /force /out:%t.exe /pdb:%t.pdb %t.obj RUN: llvm-pdbutil dump -symbols -globals %t.pdb | FileCheck %s -RUN: lld-link /debug /nodefaultlib /entry:main /out:%t.exe /pdb:%t.pdb %t.obj /threads:1 +RUN: lld-link /debug /nodefaultlib /entry:main /force /out:%t.exe /pdb:%t.pdb %t.obj /threads:1 RUN: llvm-pdbutil dump -symbols -globals %t.pdb | FileCheck %s -RUN: lld-link /debug /nodefaultlib /entry:main /out:%t.exe /pdb:%t.pdb %t.obj /threads:2 +RUN: lld-link /debug /nodefaultlib /entry:main /force /out:%t.exe /pdb:%t.pdb %t.obj /threads:2 RUN: llvm-pdbutil dump -symbols -globals %t.pdb | FileCheck %s # Test that we correctly distribute symbols between the globals and module @@ -18,34 +18,39 @@ CHECK-LABEL: Global Symbols -CHECK-NEXT: ============================================================ +CHECK-NEXT: ============================================================ CHECK-NEXT: Records -CHECK-NEXT: 340 | S_UDT [size = 20] `HelloPoint` +CHECK-NEXT: 440 | S_UDT [size = 20] `HelloPoint` +CHECK-NEXT: original type = 0x1007 +CHECK-NEXT: 252 | S_LPROCREF [size = 24] `LocalFunc` +CHECK-NEXT: module = 1, sum name = 0, offset = 424 +CHECK-NEXT: 204 | S_PROCREF [size = 28] `GlobalFunc` +CHECK-NEXT: module = 1, sum name = 0, offset = 136 +CHECK-NEXT: 232 | S_PROCREF [size = 20] `main` +CHECK-NEXT: module = 1, sum name = 0, offset = 224 +CHECK-NEXT: 360 | S_CONSTANT [size = 24] `ConstexprVar` +CHECK-NEXT: type = 0x100B (const int), value = 18 +CHECK-NEXT: 276 | S_GDATA32 [size = 28] `__purecall` +CHECK-NEXT: type = 0x0603 (void*), addr = 0003:0008 +CHECK-NEXT: 304 | S_GDATA32 [size = 24] `GlobalVar` +CHECK-NEXT: type = 0x100C (const int*), addr = 0003:0000 +CHECK-NEXT: 412 | S_UDT [size = 28] `HelloPointTypedef` CHECK-NEXT: original type = 0x1007 -CHECK-NEXT: 208 | S_LPROCREF [size = 24] `LocalFunc` -CHECK-NEXT: module = 1, sum name = 0, offset = 292 -CHECK-NEXT: 160 | S_PROCREF [size = 28] `GlobalFunc` -CHECK-NEXT: module = 1, sum name = 0, offset = 52 -CHECK-NEXT: 188 | S_PROCREF [size = 20] `main` -CHECK-NEXT: module = 1, sum name = 0, offset = 108 -CHECK-NEXT: 232 | S_GDATA32 [size = 28] `__purecall` -CHECK-NEXT: type = 0x0403 (void*), addr = 0003:0004 -CHECK-NEXT: 260 | S_GDATA32 [size = 24] `GlobalVar` -CHECK-NEXT: type = 0x100B (const int*), addr = 0003:0000 -CHECK-NEXT: 312 | S_UDT [size = 28] `HelloPointTypedef` -CHECK-NEXT: original type = 0x1005 -CHECK-NEXT: 284 | S_LDATA32 [size = 28] `ConstantVar` -CHECK-NEXT: type = 0x100A (const int), addr = 0002:0000 -CHECK-NEXT: 360 | S_PROCREF [size = 40] `HelloPoint::HelloPoint` -CHECK-NEXT: module = 1, sum name = 0, offset = 376 +CHECK-NEXT: 384 | S_LDATA32 [size = 28] `ConstantVar` +CHECK-NEXT: type = 0x100B (const int), addr = 0002:0000 +CHECK-NEXT: 328 | S_GTHREAD32 [size = 32] `ThreadLocalVar` +CHECK-NEXT: type = 0x0074 (int), addr = 0005:0000 +CHECK-NEXT: 460 | S_PROCREF [size = 40] `HelloPoint::HelloPoint` +CHECK-NEXT: module = 1, sum name = 0, offset = 548 CHECK-LABEL: Symbols CHECK-NEXT: ============================================================ CHECK-NEXT: Mod 0000 CHECK-NOT: | S_GDATA32 CHECK-NOT: | S_UDT -CHECK: 52 | S_GPROC32 [size = 52] `GlobalFunc` -CHECK: 108 | S_GPROC32 [size = 44] `main` -CHECK: 292 | S_LPROC32 [size = 52] `LocalFunc` -CHECK: 348 | S_LDATA32 [size = 28] `ConstantVar` -CHECK: 376 | S_GPROC32 [size = 64] `HelloPoint::HelloPoint` +CHECK-NOT: | S_GTHREAD32 +CHECK: 136 | S_GPROC32 [size = 52] `GlobalFunc` +CHECK: 224 | S_GPROC32 [size = 44] `main` +CHECK: 424 | S_LPROC32 [size = 52] `LocalFunc` +CHECK: 512 | S_LDATA32 [size = 28] `ConstantVar` +CHECK: 548 | S_GPROC32 [size = 64] `HelloPoint::HelloPoint`