From 7026af7138fccfb256456b04b375d39b025bdb7c Mon Sep 17 00:00:00 2001 From: Karl Schimpf Date: Thu, 21 Nov 2013 10:34:00 -0800 Subject: Clean up handling of PNaCl bitcode headers. Write out all of PNaCl bitcode headers using a single interface function. BUG= https://code.google.com/p/nativeclient/issues/detail?id=3720 R=jvoung@chromium.org Review URL: https://codereview.chromium.org/61753017 --- lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'lib/Bitcode') diff --git a/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp b/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp index eb22910c8d..968be249ed 100644 --- a/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp +++ b/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp @@ -1183,9 +1183,14 @@ static void WriteModule(const Module *M, NaClBitstreamWriter &Stream) { static const size_t kMaxVariableFieldSize = 256; // Write out the given Header to the bitstream. -static void WriteHeader( - const NaClBitcodeHeader &Header, - NaClBitstreamWriter& Stream) { +void llvm::NaClWriteHeader(const NaClBitcodeHeader &Header, + NaClBitstreamWriter &Stream) { + // Emit the file magic number; + Stream.Emit((unsigned)'P', 8); + Stream.Emit((unsigned)'E', 8); + Stream.Emit((unsigned)'X', 8); + Stream.Emit((unsigned)'E', 8); + // Emit placeholder for number of bytes used to hold header fields. // This value is necessary so that the streamable reader can preallocate // a buffer to read the fields. @@ -1228,12 +1233,6 @@ void llvm::NaClWriteBitcodeToFile(const Module *M, raw_ostream &Out, { NaClBitstreamWriter Stream(Buffer); - // Emit the file header. - Stream.Emit((unsigned)'P', 8); - Stream.Emit((unsigned)'E', 8); - Stream.Emit((unsigned)'X', 8); - Stream.Emit((unsigned)'E', 8); - // Define header and install into stream. { NaClBitcodeHeader Header; @@ -1245,7 +1244,7 @@ void llvm::NaClWriteBitcodeToFile(const Module *M, raw_ostream &Out, (!AcceptSupportedOnly && Header.IsReadable()))) { report_fatal_error(Header.Unsupported()); } - WriteHeader(Header, Stream); + NaClWriteHeader(Header, Stream); } // Emit the module. -- cgit v1.2.3-18-g5258