aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp
diff options
context:
space:
mode:
authorAlexandre Ganea <alexandre.ganea@ubisoft.com>2019-03-18 19:13:23 +0000
committerAlexandre Ganea <alexandre.ganea@ubisoft.com>2019-03-18 19:13:23 +0000
commit4aeea4cc42323067f0fb73fd844a66fbb295f889 (patch)
treef7a56f2bff1911b6b5a2efe147a270e6f4d8fdef /llvm/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp
parent8723a5655172dcea0e26c72c2def7deb9ad83188 (diff)
downloadllvm-4aeea4cc42323067f0fb73fd844a66fbb295f889.zip
llvm-4aeea4cc42323067f0fb73fd844a66fbb295f889.tar.gz
llvm-4aeea4cc42323067f0fb73fd844a66fbb295f889.tar.bz2
[DebugInfo][PDB] Don't write empty debug streams
Before, empty debug streams were written as 8 bytes (4 bytes signature + 4 bytes for the GlobalRefs count). With this patch, unused empty streams aren't emitted anymore. Modules now encode 65535 as an 'unused stream' value, by convention. Also fix the * Linker * contrib section which wasn't correctly emitted previously. Differential Revision: https://reviews.llvm.org/D59502 llvm-svn: 356395
Diffstat (limited to 'llvm/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp')
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp b/llvm/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp
index 649ff7c..1445f0b 100644
--- a/llvm/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp
@@ -14,6 +14,7 @@
#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
#include "llvm/DebugInfo/CodeView/SymbolRecordHelpers.h"
#include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h"
+#include "llvm/DebugInfo/PDB/Native/RawConstants.h"
#include "llvm/DebugInfo/PDB/Native/RawError.h"
#include "llvm/Support/BinaryStreamReader.h"
#include "llvm/Support/BinaryStreamRef.h"
@@ -36,6 +37,17 @@ ModuleDebugStreamRef::~ModuleDebugStreamRef() = default;
Error ModuleDebugStreamRef::reload() {
BinaryStreamReader Reader(*Stream);
+ if (Mod.getModuleStreamIndex() != llvm::pdb::kInvalidStreamIndex) {
+ if (Error E = reloadSerialize(Reader))
+ return E;
+ }
+ if (Reader.bytesRemaining() > 0)
+ return make_error<RawError>(raw_error_code::corrupt_file,
+ "Unexpected bytes in module stream.");
+ return Error::success();
+}
+
+Error ModuleDebugStreamRef::reloadSerialize(BinaryStreamReader &Reader) {
uint32_t SymbolSize = Mod.getSymbolDebugInfoByteSize();
uint32_t C11Size = Mod.getC11LineInfoByteSize();
uint32_t C13Size = Mod.getC13LineInfoByteSize();
@@ -71,10 +83,6 @@ Error ModuleDebugStreamRef::reload() {
return EC;
if (auto EC = Reader.readSubstream(GlobalRefsSubstream, GlobalRefsSize))
return EC;
- if (Reader.bytesRemaining() > 0)
- return make_error<RawError>(raw_error_code::corrupt_file,
- "Unexpected bytes in module stream.");
-
return Error::success();
}