]> granicus.if.org Git - llvm/commitdiff
[PDB] Don't write uninitialized bytes to a PDB file.
authorZachary Turner <zturner@google.com>
Tue, 20 Jun 2017 18:50:55 +0000 (18:50 +0000)
committerZachary Turner <zturner@google.com>
Tue, 20 Jun 2017 18:50:55 +0000 (18:50 +0000)
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

lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp
lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp

index 59ecbb50143815ee00c6131b7dc622c83221bdd1..745dd742aadc346def8e741672034cdaabba520f 100644 (file)
@@ -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 <typename T> struct Foo {
 template <typename T> Foo<T> makeFoo(T &&t) { return Foo<T>(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;
index 0ad461546d728ee0518ed5f48de87e0e04e3172a..aad247ea185f28bbedcfe42e981632a28b19d9c2 100644 (file)
@@ -237,6 +237,7 @@ Error DbiStreamBuilder::finalize() {
     return EC;
 
   DbiStreamHeader *H = Allocator.Allocate<DbiStreamHeader>();
+  ::memset(H, 0, sizeof(DbiStreamHeader));
   H->VersionHeader = *VerHeader;
   H->VersionSignature = -1;
   H->Age = Age;