reverse
Command
The reverse
command performs static reverse engineering on compiled Solana eBPF bytecode (.so
files).
It supports disassembly, control flow graph (CFG) generation, and immediate data inspection.
Usage
cargo run -- reverse \
--mode both \
--out-dir ./out/ \
--bytecodes-file ./bytecodes/program.so \
--labeling \
--reduced \
--only-entrypoint
Arguments:
-
--mode
: Output mode. One of:disass
: Disassemble the bytecodecfg
: Export control flow graphboth
: Disassemble and export CFG
-
--out-dir
: Output directory for result files. -
--bytecodes-file
: Path to the compiled.so
file. -
--labeling
: Enables use of symbol and section labels when available. -
--reduced
: (Optional) Excludes functions defined before the entrypoint (often library or startup code). -
--only-entrypoint
: (Optional) Only generates the CFG for the entrypoint function, allowing custom extension via dotting.
Modes
Mode | Description | Output Files |
---|---|---|
disass | Disassembles bytecode and extracts immediates | disassembly.out , immediate_data_table.out |
cfg | Builds a .dot graph from instruction flow | cfg.dot |
both | Performs both operations | All of the above |
Output Files
Depending on the selected mode and options, the following files may be generated in --out-dir
:
disassembly.out
: Human-readable disassembly of eBPF instructionsimmediate_data_table.out
: Table of.rodata
strings and constantscfg.dot
: Full control flow graph
You can visualize .dot
files using tools like:
dot -Tpng cfg.dot -o cfg.png
xdot cfg.dot
⚠️ For very large programs, even the
--reduced
version of the CFG can take significant time to generate due to the size and complexity of the bytecode being analyzed and rendered bydot
.
Example
cargo run -- reverse \
--mode both \
--out-dir test_cases/base_sbf_addition_checker/out1/ \
--bytecodes-file test_cases/base_sbf_addition_checker/bytecodes/addition_checker.so \
--labeling \
--reduced
This command will disassemble the program and generate reduced CFG.
Advanced Use Case
If using --only-entrypoint
, sol-azy will generate a minimal CFG with only the entrypoint's subgraph.
You can later extend this graph manually using dotting
with a JSON list of function clusters to add.