Handle (but skip) STAT DXIL chunk

This commit is contained in:
baldurk
2020-06-03 13:05:03 +01:00
parent 8727b2aa88
commit d28bab8c79
6 changed files with 75 additions and 20 deletions
@@ -569,6 +569,25 @@ static void dumpBlock(const LLVMBC::BlockOrRecord &block, int indent)
RDCLOG("%s", line.c_str());
}
bool Program::Valid(const byte *bytes, size_t length)
{
if(length < sizeof(ProgramHeader))
return false;
const byte *ptr = bytes;
const ProgramHeader *header = (const ProgramHeader *)ptr;
if(header->DxilMagic != MAKE_FOURCC('D', 'X', 'I', 'L'))
return false;
size_t expected = offsetof(ProgramHeader, DxilMagic) + header->BitcodeOffset + header->BitcodeSize;
if(expected != length)
return false;
return LLVMBC::BitcodeReader::Valid(
ptr + offsetof(ProgramHeader, DxilMagic) + header->BitcodeOffset, header->BitcodeSize);
}
Program::Program(const byte *bytes, size_t length)
{
const byte *ptr = bytes;