wadec 0.0.0

A library for decoding WebAssembly modules.
Documentation

wadec

wadec is a decoder for WebAssembly modules, focusing on developer experience, informative errors and other helpful diagnostics.

It can be used as a library or a command-line tool.

Rationale

wadec aims to serve as an educational tool for those looking to understand the Wasm binary format, or for developers debugging Wasm modules.

wadec does not aim to be a highly-efficient decoder for performance-critical tasks. For such use-cases, consider using a streaming decoder.

Status

This project is currently in early development stage of development. It passes 100% of the official suite for version 2 of the specification. (Support for version 3 is planned.)

The API is still unstable and subject to change.

Usage

# a module that encodes an invalid Value Type marker byte (0xAA) in its
# Type section
$ hexdump -C type_section_invalid_valtype_marker.wasm
00000000  00 61 73 6d 01 00 00 00  01 05 01 60 01 aa 00     |.asm.......`...|
0000000f

$ wadec --verbose type_section_invalid_valtype_marker.wasm
ERROR: failed decoding Type section

Caused by:
    0: failed parsing vector element at position 0
    1: failed decoding Parameters
    2: failed parsing vector element at position 0
    3: invalid ValType marker byte - expected one of 0x7F (Num(Int32)), 0x7E (Num(Int64)), 0x7D (Num(Float32)), 0x7C (Num(Float64)), 0x7B (Vec(V128)), 0x70 (Ref(Func)), 0x6F (Ref(Extern)); got 0xAA

DEBUG OUTPUT:
DecodeTypeSection(
    DecodeVector(
        ParseElement {
            position: 0,
            source: DecodeFuncTypeError::DecodeParameterTypes(
                DecodeVector(
                    ParseElement {
                        position: 0,
                        source: DecodeValTypeError::InvalidMarkerByte(
                            InvalidValTypeMarkerError(
                                0xAA,
                            ),
                        ),
                    },
                ),
            ),
        },
    ),
)

Roadmap

License

wadec is licensed under the Apache 2.0 license.