[PATCH] D54828: [LLD] [COFF] Generate a codeview build id signature for MinGW even when not creating a PDB

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 27 01:24:21 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL347645: [COFF] Generate a codeview build id signature for MinGW even when not creating… (authored by mstorsjo, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D54828?vs=175312&id=175414#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54828/new/

https://reviews.llvm.org/D54828

Files:
  lld/trunk/COFF/Writer.cpp
  lld/trunk/test/COFF/rsds.test


Index: lld/trunk/test/COFF/rsds.test
===================================================================
--- lld/trunk/test/COFF/rsds.test
+++ lld/trunk/test/COFF/rsds.test
@@ -22,6 +22,10 @@
 # RUN: lld-link /Brepro /debug /dll /out:%t.dll /entry:DllMain %t.obj
 # RUN: llvm-readobj -coff-debug-directory %t.dll | FileCheck --check-prefix REPRODEBUG %s
 
+# RUN: rm -f %t.dll %t.pdb
+# RUN: lld-link /lldmingw /debug:dwarf /dll /out:%t.dll /entry:DllMain %t.obj
+# RUN: llvm-readobj -coff-debug-directory %t.dll | FileCheck --check-prefix MINGW %s
+
 # CHECK: File: [[FILE:.*]].dll
 # CHECK: DebugDirectory [
 # CHECK:   DebugEntry {
@@ -143,6 +147,26 @@
 # REPRODEBUG:     PointerToRawData: 0x0
 # REPRODEBUG:   }
 # REPRODEBUG: ]
+
+# MINGW: File: {{.*}}.dll
+# MINGW: DebugDirectory [
+# MINGW:   DebugEntry {
+# MINGW:     Characteristics: 0x0
+# MINGW:     TimeDateStamp:
+# MINGW:     MajorVersion: 0x0
+# MINGW:     MinorVersion: 0x0
+# MINGW:     Type: CodeView (0x2)
+# MINGW:     SizeOfData: 0x{{[^0]}}
+# MINGW:     AddressOfRawData: 0x{{[^0]}}
+# MINGW:     PointerToRawData: 0x{{[^0]}}
+# MINGW:     PDBInfo {
+# MINGW:       PDBSignature: 0x53445352
+# MINGW:       PDBGUID: [[GUID:\(([A-Za-z0-9]{2} ?){16}\)]]
+# MINGW:       PDBAge: 1
+# MINGW:       PDBFileName:
+# MINGW:     }
+# MINGW:   }
+# MINGW: ]
 --- !COFF
 header:
   Machine:         IMAGE_FILE_MACHINE_I386
Index: lld/trunk/COFF/Writer.cpp
===================================================================
--- lld/trunk/COFF/Writer.cpp
+++ lld/trunk/COFF/Writer.cpp
@@ -1557,8 +1557,25 @@
       Buffer->getBufferSize());
 
   uint32_t Timestamp = Config->Timestamp;
+  uint64_t Hash = 0;
+  bool GenerateSyntheticBuildId =
+      Config->MinGW && Config->Debug && Config->PDBPath.empty();
+
+  if (Config->Repro || GenerateSyntheticBuildId)
+    Hash = xxHash64(OutputFileData);
+
   if (Config->Repro)
-    Timestamp = static_cast<uint32_t>(xxHash64(OutputFileData));
+    Timestamp = static_cast<uint32_t>(Hash);
+
+  if (GenerateSyntheticBuildId) {
+    // For MinGW builds without a PDB file, we still generate a build id
+    // to allow associating a crash dump to the executable.
+    BuildId->BuildId->PDB70.CVSignature = OMF::Signature::PDB70;
+    BuildId->BuildId->PDB70.Age = 1;
+    memcpy(BuildId->BuildId->PDB70.Signature, &Hash, 8);
+    // xxhash only gives us 8 bytes, so put some fixed data in the other half.
+    memcpy(&BuildId->BuildId->PDB70.Signature[8], "LLD PDB.", 8);
+  }
 
   if (DebugDirectory)
     DebugDirectory->setTimeDateStamp(Timestamp);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54828.175414.patch
Type: text/x-patch
Size: 2559 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181127/94fc441f/attachment.bin>


More information about the llvm-commits mailing list