mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-30 02:36:07 +00:00
[Object][DX] Identify DXBC file magic
This adds support to llvm::identify_magic to detect DXBC and classify it as the dxcontainer format.
This commit is contained in:
parent
363b3a645a
commit
966c40aea6
@ -52,6 +52,7 @@ struct file_magic {
|
|||||||
pdb, ///< Windows PDB debug info file
|
pdb, ///< Windows PDB debug info file
|
||||||
tapi_file, ///< Text-based Dynamic Library Stub file
|
tapi_file, ///< Text-based Dynamic Library Stub file
|
||||||
cuda_fatbinary, ///< CUDA Fatbinary object file
|
cuda_fatbinary, ///< CUDA Fatbinary object file
|
||||||
|
dxcontainer_object, ///< DirectX container file
|
||||||
};
|
};
|
||||||
|
|
||||||
bool is_object() const { return V != unknown; }
|
bool is_object() const { return V != unknown; }
|
||||||
|
@ -225,6 +225,11 @@ file_magic llvm::identify_magic(StringRef Magic) {
|
|||||||
if (startswith(Magic, "--- !tapi") || startswith(Magic, "---\narchs:"))
|
if (startswith(Magic, "--- !tapi") || startswith(Magic, "---\narchs:"))
|
||||||
return file_magic::tapi_file;
|
return file_magic::tapi_file;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'D': // DirectX container file - DXBC
|
||||||
|
if (startswith(Magic, "DXBC") && Magic.size() == 4)
|
||||||
|
return file_magic::dxcontainer_object;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -21,6 +21,11 @@ template <std::size_t X> MemoryBufferRef getMemoryBuffer(uint8_t Data[X]) {
|
|||||||
return MemoryBufferRef(Obj, "");
|
return MemoryBufferRef(Obj, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(DXCFile, IdentifyMagic) {
|
||||||
|
StringRef Buffer("DXBC");
|
||||||
|
EXPECT_EQ(identify_magic(Buffer), file_magic::dxcontainer_object);
|
||||||
|
}
|
||||||
|
|
||||||
TEST(DXCFile, ParseHeaderErrors) {
|
TEST(DXCFile, ParseHeaderErrors) {
|
||||||
uint8_t Buffer[] = {0x44, 0x58, 0x42, 0x43};
|
uint8_t Buffer[] = {0x44, 0x58, 0x42, 0x43};
|
||||||
EXPECT_THAT_EXPECTED(
|
EXPECT_THAT_EXPECTED(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user