Index: lib/Bitcode/NaCl/Analysis/NaClCompress.cpp |
diff --git a/lib/Bitcode/NaCl/Analysis/NaClCompress.cpp b/lib/Bitcode/NaCl/Analysis/NaClCompress.cpp |
index d4c327f6b189c8951c6ca8234b12165ca9b6a0f4..6e02eaf7e8edffa891b09e8192a31b185a753f84 100644 |
--- a/lib/Bitcode/NaCl/Analysis/NaClCompress.cpp |
+++ b/lib/Bitcode/NaCl/Analysis/NaClCompress.cpp |
@@ -1161,11 +1161,16 @@ static bool analyzeBitcode( |
// First read header and verify it is good. |
NaClBitcodeHeader Header; |
- if (Header.Read(BufPtr, EndBufPtr) || !Header.IsSupported()) |
+ if (Header.Read(BufPtr, EndBufPtr)) |
return Error("Invalid PNaCl bitcode header"); |
+ if (!Header.IsSupported()) { |
+ errs() << Header.Unsupported(); |
+ if (!Header.IsReadable()) |
+ return Error("Invalid PNaCl bitcode header"); |
+ } |
// Create a bitstream reader to read the bitcode file. |
- NaClBitstreamReader StreamFile(BufPtr, EndBufPtr); |
+ NaClBitstreamReader StreamFile(BufPtr, EndBufPtr, Header); |
NaClBitstreamCursor Stream(StreamFile); |
// Parse the the bitcode file. |
@@ -1389,7 +1394,7 @@ static bool chooseAbbrevs(MemoryBuffer *MemBuf, BlockAbbrevsMapType &AbbrevsMap, |
return Error("Invalid PNaCl bitcode header"); |
// Create the bitcode reader. |
- NaClBitstreamReader StreamFile(BufPtr, EndBufPtr); |
+ NaClBitstreamReader StreamFile(BufPtr, EndBufPtr, Header); |
NaClBitstreamCursor Stream(StreamFile); |
// Set up the parser. |
@@ -1587,7 +1592,7 @@ static bool copyBitcode(const NaClBitcodeCompressor::CompressFlags &Flags, |
return Error("Invalid PNaCl bitcode header"); |
// Create the bitcode reader. |
- NaClBitstreamReader StreamFile(BufPtr, EndBufPtr); |
+ NaClBitstreamReader StreamFile(BufPtr, EndBufPtr, Header); |
NaClBitstreamCursor Stream(StreamFile); |
// Create the bitcode writer. |