From: Zachary Turner Date: Tue, 20 Jun 2017 18:50:55 +0000 (+0000) Subject: [PDB] Don't write uninitialized bytes to a PDB file. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6ebce80ed17745cab6920e6b6c9050129255efcf;p=llvm [PDB] Don't write uninitialized bytes to a PDB file. There were certain fields that we didn't know how to write, as well as various padding bytes that we would ignore. This leads to garbage data in the PDB. While not strictly necessary, we should initialize these bytes to something meaningful, as it makes for easier binary comparison between PDBs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305819 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp b/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp index 59ecbb50143..745dd742aad 100644 --- a/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp +++ b/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp @@ -51,6 +51,7 @@ DbiModuleDescriptorBuilder::DbiModuleDescriptorBuilder(StringRef ModuleName, uint32_t ModIndex, msf::MSFBuilder &Msf) : MSF(Msf), ModuleName(ModuleName) { + ::memset(&Layout, 0, sizeof(Layout)); Layout.Mod = ModIndex; } @@ -102,6 +103,7 @@ template struct Foo { template Foo makeFoo(T &&t) { return Foo(std::move(t)); } void DbiModuleDescriptorBuilder::finalize() { + Layout.SC.ModuleIndex = Layout.Mod; Layout.FileNameOffs = 0; // TODO: Fix this Layout.Flags = 0; // TODO: Fix this Layout.C11Bytes = 0; diff --git a/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp b/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp index 0ad461546d7..aad247ea185 100644 --- a/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp +++ b/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp @@ -237,6 +237,7 @@ Error DbiStreamBuilder::finalize() { return EC; DbiStreamHeader *H = Allocator.Allocate(); + ::memset(H, 0, sizeof(DbiStreamHeader)); H->VersionHeader = *VerHeader; H->VersionSignature = -1; H->Age = Age;