1/* @ajax/wasm-decode: a WebAssembly binary into a wasm_module.
2 *
3 * Checks what the binary format requires: the header, section order and sizes, every vector and
4 * LEB, names' UTF-8, limits flags, segment kinds, the function/code and data-count agreements, and
5 * that constant expressions are well-formed instruction sequences. Function bodies are kept as
6 * byte ranges for @ajax/wasm-validate. Hostile input never reads out of bounds, and counts are
7 * checked against the bytes left before anything is allocated. */
8#ifndef WASM_DECODE_H
9#define WASM_DECODE_H
1011#include "wasm/module.h"
1213#include <stdbool.h>
14#include <stddef.h>
15#include <stdint.h>
1617/* Locals a function may declare (wasmparser's MAX_WASM_FUNCTION_LOCALS). */
18#define WASM_MAX_LOCALS 50000u
1920/* Decodes bytes[0..len) into *out (which then borrows bytes). false: *out is freed and err holds
21 * "<what> (at offset 0x<n>)". */
22bool wasm_decode(const uint8_t *bytes, size_t len, wasm_module *out, char *err, size_t errlen);
2324#endif