[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
Mon Nov 26 11:59:06 PST 2018
mstorsjo updated this revision to Diff 175309.
mstorsjo added a comment.
Added a comment explaining why the added code is there, renamed the variable to `GenerateSyntheticBuildId` to differentiate it a bit further from the normal build id generated in a PDB file.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D54828/new/
https://reviews.llvm.org/D54828
Files:
COFF/Writer.cpp
test/COFF/rsds.test
Index: test/COFF/rsds.test
===================================================================
--- test/COFF/rsds.test
+++ 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: COFF/Writer.cpp
===================================================================
--- COFF/Writer.cpp
+++ COFF/Writer.cpp
@@ -1561,8 +1561,25 @@
Buffer->getBufferSize());
uint32_t Timestamp = Config->Timestamp;
+ uint64_t Hash = 0;
+ bool GenerateSyntheticBuildId =
+ Config->MinGW && Config->Debug && Config->PDBPath.empty();
+
+ if (Config->Repro || GenerateBuildId)
+ 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.175309.patch
Type: text/x-patch
Size: 2490 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181126/28bb3a4e/attachment.bin>
More information about the llvm-commits
mailing list