kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

wasm.h (1441B)


      1 /* Wasm object-format read/emit entry points, mirroring obj/elf/elf.h and
      2  * friends. The public ObjBuilder/Linker surface is format-neutral
      3  * (obj/obj.h); this header is the private wasm spelling of the read/emit
      4  * hooks plugged into the ObjFormatImpl table in obj/registry.c.
      5  *
      6  * Note: distinct from the core module model in src/wasm/wasm.h (the in-memory
      7  * WasmModule and binary decode/encode). This header only declares the obj-layer
      8  * glue and is always included by its full path (obj/wasm/wasm.h). */
      9 
     10 #ifndef KIT_OBJ_WASM_H
     11 #define KIT_OBJ_WASM_H
     12 
     13 #include "core/core.h"
     14 #include "obj/obj.h"
     15 
     16 /* Flush the WasmModule attached to the builder (OBJ_EXT_WASM) as a .wasm
     17  * binary, or an empty module header when none is attached. */
     18 void emit_wasm(Compiler* c, ObjBuilder* o, Writer* w);
     19 
     20 /* Parse a .wasm binary into a format-neutral ObjBuilder: one section per wasm
     21  * module section (code marked SF_EXEC so objdump -d disassembles it) plus a
     22  * function symbol per defined function. The code section's symbol values are
     23  * byte offsets, within the code-section payload, of each function body's
     24  * size-prefixed content (i.e. the first byte after the body's size LEB, where
     25  * the locals vector begins) — the wasm disassembler reports that same offset
     26  * for the body's first emitted line so the labels line up. */
     27 ObjBuilder* read_wasm(Compiler* c, const char* name, const u8* data,
     28                       size_t len);
     29 
     30 #endif