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
- Backend: IR to Wasm.
- cfg
- Lightweight CFG analyses.
- entity
- Type-safe indices and indexed containers.
- op_
traits - Metadata on operators.
- passes
- Passes.
- pool
- Pooled list data structure.
- util
Macros§
Structs§
- Block
- Block
Def - Block
Target - Control
Tag - Control
TagData - Debug
- Debug
Map - A map from ranges of offsets in the original Wasm file to source locations.
- Export
- Frontend
Options - Options to control the Wasm-to-bytecode translation process.
- Func
- Function
Body - The body of a function, as an SSA-based intermediate representation.
- Function
Body Display - A wrapper around a
FunctionBody
together with some auxiliary information to perform a pretty-print of that function. - Global
- Global
Data - Hole
Target - Ieee32
- An IEEE binary32 immediate floating point value, represented as a u32 containing the bit pattern.
- Ieee64
- An IEEE binary64 immediate floating point value, represented as a u64 containing the bit pattern.
- Import
- Interp
Context - Context for the IR interpreter. Corresponds roughly to Wasm module state.
- Interp
Memory - The state of one interpreter memory.
- Interp
Stack Frame - One stack frame in the interpreted execution context.
- Interp
Table - The state of one interpreter table.
- Local
- Memory
- Memory
Arg - An argument to a memory load or store, specifying which memory, alignment and an optional offset.
- Memory
Data - A memory definition.
- Memory
Segment - Module
- Module
Display - Signature
- Source
File - Source
Loc - Source
LocData - A “source location”: a filename (interned to an ID), a line, and a column.
- Table
- Table
Data - Value
- Value
Record - With
Mutablility - Something, alsong with whether it can be mutated
- With
Nullable - Something, alsong with whether it can be
null
Enums§
- Const
Val - A constant concrete value during interpretation.
- Export
Kind - Frontend
Error - An error that occurs when translating Wasm to IR.
- Func
Decl 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).- Handler
- An exception’s handler
- Heap
Type - a
Type
that can be stored on the heap - Import
Kind - Interp
Result - The result of an interpreter session.
- Operator
- An operator in the IR, consuming arguments and producing results when executed.
- Signature
Data - Storage
Type - A storage type
- Terminator
- Type
- Types in waffle’s IR.
- Value
Def - A definition of an SSA value.
Constants§
- WASM_
PAGE - The size of a single Wasm page, used in memory definitions.
Traits§
Functions§
- const_
eval - Constant-evaluate the given operator with the given arguments, returning a constant result if possible to know.
- i2x
- x2i