Example Usage
use rspirv::binary::Assemble;
use rspirv::binary::Disassemble;
fn main() {
// Building
let mut b = rspirv::dr::Builder::new();
b.set_version(1, 0);
b.capability(spirv::Capability::Shader);
b.memory_model(spirv::AddressingModel::Logical, spirv::MemoryModel::GLSL450);
let void = b.type_void();
let voidf = b.type_function(void, vec![]);
let fun = b
.begin_function(
void,
None,
spirv::FunctionControl::DONT_INLINE | spirv::FunctionControl::CONST,
voidf,
)
.unwrap();
b.begin_basic_block(None).unwrap();
b.ret().unwrap();
b.end_function().unwrap();
b.entry_point(spirv::ExecutionModel::Vertex, fun, "foo", vec![]);
let module = b.module();
// Assembling
let code = module.assemble();
assert!(code.len() > 20); // Module header contains 5 words
assert_eq!(spirv::MAGIC_NUMBER, code[0]);
// Parsing
let mut loader = rspirv::dr::Loader::new();
rspirv::binary::parse_words(&code, &mut loader).unwrap();
let module = loader.module();
// Disassembling
assert_eq!(
module.disassemble(),
"; SPIR-V\n\
; Version: 1.0\n
See also
toolkit
Free
The essential toolkit for reversing, malware analysis, and cracking…
ipatool
Open Source
Command-line tool that allows searching and downloading app packages (known as ipa files) from the i…
Angr
Open Source
Python binary analysis framework supporting both static and dynamic symbolic execution (concolic exe…
pokeheartgold
Free
Decompilation of Pokemon HeartGold/SoulSilver…
BitMono
Open Source
Obfuscator for .NET and Mono, with a customizable engine for building your own obfuscators.…
NTRGhidra
Open Source
A Nintendo DS binary loader for Ghidra…