[lld] r290975 - COFF: tie the execute and the PDB together
Saleem Abdulrasool via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 4 09:56:54 PST 2017
Author: compnerd
Date: Wed Jan 4 11:56:54 2017
New Revision: 290975
URL: http://llvm.org/viewvc/llvm-project?rev=290975&view=rev
Log:
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.
Modified:
lld/trunk/COFF/PDB.cpp
lld/trunk/COFF/PDB.h
lld/trunk/COFF/Writer.cpp
lld/trunk/test/COFF/pdb.test
Modified: lld/trunk/COFF/PDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/PDB.cpp?rev=290975&r1=290974&r2=290975&view=diff
==============================================================================
--- lld/trunk/COFF/PDB.cpp (original)
+++ lld/trunk/COFF/PDB.cpp Wed Jan 4 11:56:54 2017
@@ -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 *Sym
// 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, Sym
// 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);
Modified: lld/trunk/COFF/PDB.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/PDB.h?rev=290975&r1=290974&r2=290975&view=diff
==============================================================================
--- lld/trunk/COFF/PDB.h (original)
+++ lld/trunk/COFF/PDB.h Wed Jan 4 11:56:54 2017
@@ -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);
}
}
Modified: lld/trunk/COFF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Writer.cpp?rev=290975&r1=290974&r2=290975&view=diff
==============================================================================
--- lld/trunk/COFF/Writer.cpp (original)
+++ lld/trunk/COFF/Writer.cpp Wed Jan 4 11:56:54 2017
@@ -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");
Modified: lld/trunk/test/COFF/pdb.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/pdb.test?rev=290975&r1=290974&r2=290975&view=diff
==============================================================================
--- lld/trunk/test/COFF/pdb.test (original)
+++ lld/trunk/test/COFF/pdb.test Wed Jan 4 11:56:54 2017
@@ -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:
More information about the llvm-commits
mailing list