Index: COFF/PDB.h =================================================================== --- COFF/PDB.h +++ COFF/PDB.h @@ -13,12 +13,19 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" +namespace llvm { +namespace codeview { +union DebugInfo; +} +} + namespace lld { namespace coff { class SymbolTable; void createPDB(llvm::StringRef Path, SymbolTable *Symtab, - llvm::ArrayRef SectionTable); + llvm::ArrayRef SectionTable, + const llvm::codeview::DebugInfo *DI); } } Index: COFF/PDB.cpp =================================================================== --- COFF/PDB.cpp +++ COFF/PDB.cpp @@ -13,6 +13,7 @@ #include "Error.h" #include "SymbolTable.h" #include "Symbols.h" +#include "llvm/DebugInfo/CodeView/CVDebugRecord.h" #include "llvm/DebugInfo/CodeView/SymbolDumper.h" #include "llvm/DebugInfo/CodeView/TypeDumper.h" #include "llvm/DebugInfo/MSF/ByteStream.h" @@ -131,7 +132,8 @@ // Creates a PDB file. void coff::createPDB(StringRef Path, SymbolTable *Symtab, - ArrayRef SectionTable) { + ArrayRef SectionTable, + const llvm::codeview::DebugInfo *DI) { if (Config->DumpPdb) dumpCodeView(Symtab); @@ -146,11 +148,11 @@ // Add an Info stream. auto &InfoBuilder = Builder.getInfoBuilder(); - InfoBuilder.setAge(1); - - // Should be a random number, 0 for now. - InfoBuilder.setGuid({}); - + assert(DI->Signature.CVSignature == OMF::Signature::PDB70 && + "only PDB 7.0 is supported"); + InfoBuilder.setAge(DI->PDB70.Age); + InfoBuilder.setGuid( + *reinterpret_cast(&DI->PDB70.Signature)); // Should be the current time, but set 0 for reproducibilty. InfoBuilder.setSignature(0); InfoBuilder.setVersion(pdb::PdbRaw_ImplVer::PdbImplVC70); Index: COFF/Writer.cpp =================================================================== --- COFF/Writer.cpp +++ COFF/Writer.cpp @@ -304,7 +304,7 @@ writeBuildId(); if (!Config->PDBPath.empty()) - createPDB(Config->PDBPath, Symtab, SectionTable); + createPDB(Config->PDBPath, Symtab, SectionTable, BuildId->DI); if (auto EC = Buffer->commit()) fatal(EC, "failed to write the output file"); Index: test/COFF/pdb.test =================================================================== --- test/COFF/pdb.test +++ test/COFF/pdb.test @@ -28,8 +28,12 @@ # CHECK-NEXT: - Stream: [ 8 ] # CHECK-NEXT: - Stream: [ 4 ] # CHECK-NEXT: PdbStream: +# Ensure that the Guid matches the RSDS record: +# PDBSignature: 0x53445352 +# PDBGUID (38 9A CC F2 14 A4 7F A2 6C F0 08 04 47 CF 5C 48) +# PDBAge: 1 # CHECK-NEXT: Age: 1 -# CHECK-NEXT: Guid: '{00000000-0000-0000-0000-000000000000}' +# CHECK-NEXT: Guid: '{389ACCF2-14A4-7FA2-6CF0-080447CF5C48}' # CHECK-NEXT: Signature: 0 # CHECK-NEXT: Version: VC70 # CHECK-NEXT: NamedStreams: