diff options
author | Zachary Turner <zturner@google.com> | 2017-06-20 18:50:55 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2017-06-20 18:50:55 +0000 |
commit | 297b6eb20df59d7c5d593b6f04fd4ea9d0e77e29 (patch) | |
tree | 63025d0d5dcc4f31ad5541fb4f03691bbf14026f | |
parent | ed130b6ac0e2aa3bfa9ba3d99fe9e2cbf171a789 (diff) | |
download | llvm-297b6eb20df59d7c5d593b6f04fd4ea9d0e77e29.zip llvm-297b6eb20df59d7c5d593b6f04fd4ea9d0e77e29.tar.gz llvm-297b6eb20df59d7c5d593b6f04fd4ea9d0e77e29.tar.bz2 |
[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.
llvm-svn: 305819
-rw-r--r-- | llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp | 1 |
2 files changed, 3 insertions, 0 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp index 59ecbb5..745dd74 100644 --- a/llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp +++ b/llvm/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 <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; diff --git a/llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp index 0ad4615..aad247e 100644 --- a/llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp +++ b/llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp @@ -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; |