Sha256: d0172fb92fd6c987f2635d96b02959f5221ec7aa4bc2a21c735fb72f67e194e8
Contents?: true
Size: 1.4 KB
Versions: 1
Compression:
Stored size: 1.4 KB
Contents
//! Small helper utility to disassemble `*.cwasm` files produced by Wasmtime. //! //! Run with: //! //! cargo run --example objdump -F disas -p pulley-interpreter foo.cwasm use anyhow::{bail, Result}; use object::{File, Object as _, ObjectSection, ObjectSymbol, SymbolKind}; use pulley_interpreter::decode::Decoder; use pulley_interpreter::disas::Disassembler; fn main() -> Result<()> { let cwasm = std::fs::read(std::env::args().nth(1).unwrap())?; let image = File::parse(&cwasm[..])?; let text = match image.sections().find(|s| s.name().ok() == Some(".text")) { Some(section) => section.data()?, None => bail!("no text section"), }; for sym in image.symbols() { if !sym.is_definition() { continue; } if sym.kind() != SymbolKind::Text { continue; } let address = sym.address(); let size = sym.size(); if size == 0 { continue; } let name = sym.name()?; let code = &text[address as usize..][..size as usize]; println!("{address:#08x}: <{name}>:"); let mut disas = Disassembler::new(code); disas.start_offset(address as usize); let result = Decoder::decode_all(&mut disas); println!("{}", disas.disas()); if let Err(e) = result { println!(" : error disassembling: {e:?}"); } } Ok(()) }
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wasmtime-29.0.0 | ./ext/cargo-vendor/pulley-interpreter-29.0.0/examples/objdump.rs |