MCPcopy Create free account
hub / github.com/GANGE666/xVMP / SkipBitcodeWrapperHeader

Function SkipBitcodeWrapperHeader

src/include/llvm/Bitcode/BitcodeReader.h:240–257  ·  view source on GitHub ↗

SkipBitcodeWrapperHeader - Some systems wrap bc files with a special header for padding or other reasons. The format of this header is: struct bc_header { uint32_t Magic; // 0x0B17C0DE uint32_t Version; // Version, currently always 0. uint32_t BitcodeOffset; // Offset to traditional bitcode file. uint32_t BitcodeSize; // Size of traditional bitcode file. ... potentially other gun

Source from the content-addressed store, hash-verified

238 /// If 'VerifyBufferSize' is true, check that the buffer is large enough to
239 /// contain the whole bitcode file.
240 inline bool SkipBitcodeWrapperHeader(const unsigned char *&BufPtr,
241 const unsigned char *&BufEnd,
242 bool VerifyBufferSize) {
243 // Must contain the offset and size field!
244 if (unsigned(BufEnd - BufPtr) < BWH_SizeField + 4)
245 return true;
246
247 unsigned Offset = support::endian::read32le(&BufPtr[BWH_OffsetField]);
248 unsigned Size = support::endian::read32le(&BufPtr[BWH_SizeField]);
249 uint64_t BitcodeOffsetEnd = (uint64_t)Offset + (uint64_t)Size;
250
251 // Verify that Offset+Size fits in the file.
252 if (VerifyBufferSize && BitcodeOffsetEnd > uint64_t(BufEnd-BufPtr))
253 return true;
254 BufPtr += Offset;
255 BufEnd = BufPtr+Size;
256 return false;
257 }
258
259 const std::error_category &BitcodeErrorCategory();
260 enum class BitcodeError { CorruptedBitcode = 1 };

Callers 2

openBitcodeFileFunction · 0.85
initStreamFunction · 0.85

Calls 1

read32leFunction · 0.85

Tested by

no test coverage detected