Skip to content

Commit 10d8ee6

Browse files
committed
Don't apply names in name section to globals
The name section currently only provides names for functions and locals. This fixes issue #286.
1 parent 4a139e0 commit 10d8ee6

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/apply-names.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,9 @@ static WasmResult visit_func(Context* ctx,
303303
static WasmResult visit_export(Context* ctx,
304304
uint32_t export_index,
305305
WasmExport* export) {
306-
use_name_for_func_var(ctx->allocator, ctx->module, &export->var);
306+
if (export->kind == WASM_EXTERNAL_KIND_FUNC) {
307+
use_name_for_func_var(ctx->allocator, ctx->module, &export->var);
308+
}
307309
return WASM_OK;
308310
}
309311

test/binary/no-global-names.txt

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
;;; TOOL: run-gen-wasm
2+
magic
3+
version
4+
section(TYPE) { count[1] function params[0] results[0] }
5+
section(FUNCTION) { count[1] type[0] }
6+
section(GLOBAL) {
7+
count[1]
8+
type[i32] mut[0] init_expr[i32.const 0 end]
9+
}
10+
section(EXPORT) {
11+
count[2]
12+
str("bar") func_kind func[0]
13+
str("d_glob") global_kind global[0]
14+
}
15+
section(CODE) {
16+
count[1]
17+
func {
18+
locals[0]
19+
return
20+
}
21+
}
22+
section("name") {
23+
func_count[1]
24+
str("bar")
25+
local_count[0]
26+
}

0 commit comments

Comments
 (0)