WebAssembly / WebAssembly/wabt

Custom sections wasm2wat / wat2wasm

Open
#1,376 16 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
8.1k
Forks
827
Avg merge
4d 6h
Merged PRs (30d)
18

Description

We are researching ways to support custom sections in the text file format (wat) so we can transform it easily to wasm and viceversa.

One of the ideas we came up with is to automatically base64 encode the custom section when decoding from a wasm file, and automatically base64 decode when passing from wat to wasm.

Here's the proposal:

wasm2wat

When doing wasm2wat, we can base64 encode the contents of each of the binary sections.

Proposal for wat:

(module
  (section sectionName "base64:aGVsbG8=") ;; this is the base64 encoding of "hello"
  (func (export "addTwo") (param i32 i32) (result i32)
    local.get 0
    local.get 1
    i32.add))
wat2wasm

When encoding the text format to wasm, we could just read the section value, see if it's using an encoding we support, and if that's the case we can just transform it into its binary format and append the section binary content to the wasm.

Are there other ways we could accomplish it?

Thoughts on this proposal?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the wasm2wat and wat2wasm entry points mentioned in the proposal and read how sections are currently parsed and emitted. Compare the base64 custom-section idea with other possible representations, then define the accepted syntax, encoding behavior, and tests needed to show custom sections survive both conversion directions.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, wasm
Domain
compilers, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.