Leaf is a Rust-oriented framework for dynamic analysis built around MIR instrumentation. It wraps the Rust compiler through leafc, instruments a program at compile time, and routes runtime events to pluggable backends for tracing, symbolic execution, and related analyses.
compiler/: theleafcdriver and instrumentation pipelineruntime/lib: the shared abstraction library for implementing runtime backendsruntime/backends/: concrete backend implementationscommon/: shared facilities and definitions used across the project
- Rustup and cargo to install nightly toolchains,
rustclibraries and building the project. - Python for helper scripts (e.g., toolchain builder) in the repository
-
Clone the repository and build the compiler:
$ git clone https://github.com/sfu-rsl/leaf.git $ cd leaf $ cargo install --path ./compiler
-
Build a runtime backend, for example the control-flow tracer:
$ cargo build -p runtime_cf_tracer -
Make the shared library discoverable to the generated program:
$ mkdir -p target/debug/runtime_cf_tracer $ ln -sf target/debug/runtime_cf_tracer.so target/debug/runtime_cf_tracer/libleafrt.so $ export LD_LIBRARY_PATH="$PWD/target/debug/runtime_cf_tracer:$LD_LIBRARY_PATH"
-
Compile a sample program with
leafc:$ leafc samples/hello_world.rs -
Run the instrumented binary with logging enabled:
$ export LEAF_LOG="info" $ ./hello_world
The generated program will emit runtime events through the active backend, which can be inspected through the logging output or any backend-specific artifacts.
Further information, tutorials, and technical details are collected in Leaf Book hosted at: sfu-rsl.github.io/leaf.
Leaf is licensed under the MIT or Apache-2.0 licenses.
- Apache License, Version 2.0: LICENSE-APACHE
- MIT License: LICENSE-MIT