Crate disassemble [−] [src]
Disassemble
This crate provides basic functionality for working with disassembled code. It provides (or will provide) functionality for performing:
- Working with code that has already been compiled to machine
code for any CPU, bytecode, compiler IR or JIT compiler
output like that of V8 or the JVM. You provide an adapter
to teach
Instruction
how to report the correct information for your generated code. - Reconstructing the control flow graph from a body of compiled code.
- (Future) Reconstructing loops and higher level control flow constructs.
- (Future) Performing data flow analysis.
- (Future) Generating HTML and other rich output formats to assist in visualizing structure and higher level presentations of the data derived from the generated code.
- (Future) Writing decompilers that generate C or other languages from lower level generated code.
- (Future) Writing tools for reverse engineering. Many tools for reverse engineering require extracting and inferring higher level structure from the low level generated code. This crate provides those capabilities for re-use by anyone.
- (Future) Writing views that display disassembled code for debuggers, profilers and other systems level tools.
The actual disassembly with the implementation of Instruction
and other elements of the system will be provided by other
crates that integrate with other systems, such as the Capstone
Engine. This crate is written such that it should work with
nearly any machine code, VM bytecode or JIT compiler output,
given an appropriate implementation of Instruction
.
It is possible (likely?) that some functionality from within
this crate may move in the future to a separate crate for broader
re-use. This might impact Symbol
among other things.
Installation
This crate works with Cargo and is on
crates.io.
Add it to your Cargo.toml
like so:
[dependencies]
disassemble = "0.0.1"
Then, let rustc
know that you're going to use this crate at the
top of your own crate:
extern crate disassemble;
Future Directions
In the future, we want to extend this library to support a number of additional features:
- Implement DOT output for the
ControlFlowGraph
. This can probably be done with the help ofpetgraph
. - HTML output modes?
- Implement loop finding. (Havlak)
- Implement the Capstone Engine backend as a separate crate.
- Make
Instruction
aware of operands, registers - Data flow support. Memory SSA?
- Should we deal with mangled symbols at this level?
- So much more!
Contributions
Contributions are welcome.
Structs
Address |
The location of something in an address space. |
BasicBlock |
A basic block is a sequence of instructions with no inward-bound branches except to the entry point and no outward-bound branches except at the exit. |
BasicBlockEdge |
Information about an edge between 2 basic blocks. |
CallSite |
Information about a call site. |
ControlFlowGraph | |
Function |
A function within a program. |
LoopStructureGraph |
Maintain loop structure for a given |
Memory | |
Module |
A shared library or other component of a target. |
SimpleLoop | |
Symbol |
A symbol within an executable or library. This is a named address. |
Target |
An executable. |
Enums
CallSiteTarget |
Information about the target of a |
EdgeType |
When is this edge taken? Conditionally or unconditionally? |
Error |
Traits
CallGraphAnalysis |
Assist in performing call graph analysis. |
Instruction |
An assembly instruction, bytecode operation, VM operation, etc. |
Segment |
Functions
find_loops |
Find loops and build loop forest using Havlak's algorithm, which is derived from Tarjan. |