Crate waffle

Source
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 passes::basic_opt::OptOptions;
pub use wasmparser;
pub use wasm_encoder;

Modules§

cfg
Lightweight CFG analyses.
entity
Type-safe indices and indexed containers.
passes
Passes.
pool
Pooled list data structure.

Macros§

declare_entity

Structs§

Block
BlockDef
BlockTarget
Debug
DebugMap
A map from ranges of offsets in the original Wasm file to source locations.
Export
A module export definition.
FrontendOptions
Options to control the Wasm-to-bytecode translation process.
Func
FunctionBody
The body of a function, as an SSA-based intermediate representation.
FunctionBodyDisplay
A wrapper around a FunctionBody together with some auxiliary information to perform a pretty-print of that function.
Global
GlobalData
A global-variable definition.
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
A module import definition.
InterpContext
Context for the IR interpreter. Corresponds roughly to Wasm module state.
InterpMemory
The state of one interpreter memory.
InterpStackFrame
One stack frame in the interpreted execution context.
InterpTable
The state of one interpreter table.
Local
Memory
MemoryArg
An argument to a memory load or store, specifying which memory, alignment and an optional offset.
MemoryData
A memory definition.
MemorySegment
A segment of data in a memory’s initial state.
Module
A Wasm module, represented as a collection of IR entities.
ModuleDisplay
Signature
SignatureData
A function signature definition.
SourceFile
SourceLoc
SourceLocData
A “source location”: a filename (interned to an ID), a line, and a column.
Table
TableData
A table definition.
Value

Enums§

ConstVal
A constant concrete value during interpretation.
ExportKind
The kind of a Wasm export, including the specific entity index that this export directive exports.
FrontendError
An error that occurs when translating Wasm to IR.
FuncDecl
A declaration of a function: there is one FuncDecl per Func index.
ImportKind
The kind of of a Wasm import, including the specific entity index that the import corresponds to.
InterpResult
The result of an interpreter session.
Operator
An operator in the IR, consuming arguments and producing results when executed.
SideEffect
Side-effects that an operator may have.
Terminator
Type
Types in waffle’s IR.
ValueDef
A definition of an SSA value.

Constants§

WASM_PAGE
The size of a single Wasm page, used in memory definitions.

Functions§

const_eval
Constant-evaluate the given operator with the given arguments, returning a constant result if possible to know.