WebAssembly / WebAssembly/wabt

wasm-decompile doesn't mark standard exported globals as exported

Open
#1,397 1 comment 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

I've compiled a simple example with Clang 8.0.1:

int f() {
	return 42;
}

With latest wabt release (1.0.13), wasm2wat dump for this file is:

(module
  (type (;0;) (func))
  (func $__wasm_call_ctors (type 0))
  (table (;0;) 1 1 funcref)
  (memory (;0;) 2)
  (global (;0;) (mut i32) (i32.const 66560))
  (global (;1;) i32 (i32.const 66560))
  (global (;2;) i32 (i32.const 1024))
  (export "memory" (memory 0))
  (export "__heap_base" (global 1))
  (export "__data_end" (global 2)))

while wasm-decompile prints:

export memory memory(initial: 2, max: 0);

global g_a:int = 66560;
global heap_base:int = 66560;
global data_end:int = 1024;

table T_a:funcref(min: 1, max: 1);

function wasm_call_ctors() {
}

Note how globals are not marked as exported, even though they are as shown by wasm2wat.

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 with the wasm-decompile output path and compare it with the wasm2wat output shown in the issue. Trace how exported globals are represented, then ensure standard exported globals are marked as exported in decompiled output and verify the example no longer omits those export markers.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, wasm
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.