Crates.io | binutils |
lib.rs | binutils |
version | 0.1.1 |
source | src |
created_at | 2018-05-11 19:52:20.448033 |
updated_at | 2018-05-12 17:44:05.474879 |
description | A Rust library that ease interacting with the binutils disassembly engine |
homepage | |
repository | https://github.com/guedou/binutils-rs/ |
max_upload_size | |
id | 64915 |
size | 64,848 |
A Rust library that ease interacting with the binutils disassembly engine with a high-level API. Its main goal is to simplify disassembling raw buffers into instructions.
You need to add the following lines to your Cargo.toml
:
[dependencies]
binutils = "0.1.1"
and make sure that your are using it in your code:
extern crate binutils;
Note: By default, all architectures supported by binutils will be built by cargo. The resulting library will be over 60MB. When size is an issue, the
TARGETS
environment variable can be set to only build specific architectures (i.e.TARGETS=arm-linux,mep
) as defined inbfd/config.bfd
.
Here is how to disassemble a buffer containing x86 instructions while being gentle with errors:
extern crate binutils;
use binutils::utils::disassemble_buffer;
use binutils::opcodes::DisassembleInfo;
// Prepare the disassembler
let mut info = disassemble_buffer("i386", &[0xc3, 0x90, 0x66, 0x90], 0x2800)
.unwrap_or(DisassembleInfo::empty());
// Iterate over the instructions
loop {
match info.disassemble()
.ok_or(2807)
.map(|i| Some(i.unwrap()))
.unwrap_or(None)
{
Some(instruction) => println!("{}", instruction),
None => break,
}
}
Other examples are located in the examples/ directory, and be used
with cargo run --example
.
Examples in C and archived documentations are available in the resources/ directory.