Expand description
WAFFLE Wasm analysis framework.
waffle is a decompiler and compiler library for WebAssembly: it defines an SSA-based IR (intermediate representation), with a frontend that translates Wasm to this IR, and a backend that compiles this IR back to Wasm. It can be used by programs that need to transform/modify or add new code to Wasm modules.
A good starting point is the Module
: it can be constructed from
Wasm bytecode in memory with Module::from_wasm_bytes()
and
recompiled to Wasm with Module::to_wasm_bytes()
, after
modifications are performed or new code is added. A new module can
also be built from scratch with Module::empty()
.
Re-exports§
pub use op_traits::SideEffect;
pub use passes::basic_opt::OptOptions;
pub use wasmparser;
pub use wasm_encoder;
Modules§
- Backend: IR to Wasm.
- Lightweight CFG analyses.
- Type-safe indices and indexed containers.
- Metadata on operators.
- Passes.
- Pooled list data structure.
Macros§
Structs§
- A map from ranges of offsets in the original Wasm file to source locations.
- Options to control the Wasm-to-bytecode translation process.
- The body of a function, as an SSA-based intermediate representation.
- A wrapper around a
FunctionBody
together with some auxiliary information to perform a pretty-print of that function. - An IEEE binary32 immediate floating point value, represented as a u32 containing the bit pattern.
- An IEEE binary64 immediate floating point value, represented as a u64 containing the bit pattern.
- Context for the IR interpreter. Corresponds roughly to Wasm module state.
- The state of one interpreter memory.
- One stack frame in the interpreted execution context.
- The state of one interpreter table.
- An argument to a memory load or store, specifying which memory, alignment and an optional offset.
- A memory definition.
- A “source location”: a filename (interned to an ID), a line, and a column.
Enums§
- A constant concrete value during interpretation.
- An error that occurs when translating Wasm to IR.
FuncDecl
represents the various forms in which we can hold a function body: not yet parsed, parsed into full IR, recompiled into new bytecode, or an import (none of the above).- The result of an interpreter session.
- An operator in the IR, consuming arguments and producing results when executed.
- Types in waffle’s IR.
- A definition of an SSA value.
Constants§
- The size of a single Wasm page, used in memory definitions.
Functions§
- Constant-evaluate the given operator with the given arguments, returning a constant result if possible to know.