diff options
| author | Saleem Abdulrasool <compnerd@compnerd.org> | 2017-01-04 17:56:54 +0000 |
|---|---|---|
| committer | Saleem Abdulrasool <compnerd@compnerd.org> | 2017-01-04 17:56:54 +0000 |
| commit | df8a13b25763b7192579c74049322e5e6dd3da54 (patch) | |
| tree | 01290ba828d66f190f3618178db440ae24090fd5 | |
| parent | 8ab80ba3a2ad60dd5812b680760cc404a183f76b (diff) | |
| download | bcm5719-llvm-df8a13b25763b7192579c74049322e5e6dd3da54.tar.gz bcm5719-llvm-df8a13b25763b7192579c74049322e5e6dd3da54.zip | |
COFF: tie the execute and the PDB together
The PDB GUID, Age, and version are tied together by the RSDS record in
the binary. Pass along the BuildId information into the createPDB to
allow us to tie the binary and the PDB together.
llvm-svn: 290975
| -rw-r--r-- | lld/COFF/PDB.cpp | 12 | ||||
| -rw-r--r-- | lld/COFF/PDB.h | 9 | ||||
| -rw-r--r-- | lld/COFF/Writer.cpp | 2 | ||||
| -rw-r--r-- | lld/test/COFF/pdb.test | 6 |
4 files changed, 20 insertions, 9 deletions
diff --git a/lld/COFF/PDB.cpp b/lld/COFF/PDB.cpp index 56d5a365114..d5c52a69be6 100644 --- a/lld/COFF/PDB.cpp +++ b/lld/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 @@ static void addTypeInfo(SymbolTable *Symtab, // Creates a PDB file. void coff::createPDB(StringRef Path, SymbolTable *Symtab, - ArrayRef<uint8_t> SectionTable) { + ArrayRef<uint8_t> SectionTable, + const llvm::codeview::DebugInfo *DI) { if (Config->DumpPdb) dumpCodeView(Symtab); @@ -146,11 +148,9 @@ void coff::createPDB(StringRef Path, SymbolTable *Symtab, // Add an Info stream. auto &InfoBuilder = Builder.getInfoBuilder(); - InfoBuilder.setAge(1); - - // Should be a random number, 0 for now. - InfoBuilder.setGuid({}); - + InfoBuilder.setAge(DI->PDB70.Age); + InfoBuilder.setGuid( + *reinterpret_cast<const pdb::PDB_UniqueId *>(&DI->PDB70.Signature)); // Should be the current time, but set 0 for reproducibilty. InfoBuilder.setSignature(0); InfoBuilder.setVersion(pdb::PdbRaw_ImplVer::PdbImplVC70); diff --git a/lld/COFF/PDB.h b/lld/COFF/PDB.h index 091e90fa1ef..c9c37914299 100644 --- a/lld/COFF/PDB.h +++ b/lld/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<uint8_t> SectionTable); + llvm::ArrayRef<uint8_t> SectionTable, + const llvm::codeview::DebugInfo *DI); } } diff --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp index 3e69aebbb42..71217ebeb60 100644 --- a/lld/COFF/Writer.cpp +++ b/lld/COFF/Writer.cpp @@ -304,7 +304,7 @@ void Writer::run() { 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"); diff --git a/lld/test/COFF/pdb.test b/lld/test/COFF/pdb.test index af174b7a203..037895e0766 100644 --- a/lld/test/COFF/pdb.test +++ b/lld/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: |

