diff options
| author | Luuk de Gram <luuk@degram.dev> | 2023-01-09 21:20:16 +0100 |
|---|---|---|
| committer | Luuk de Gram <luuk@degram.dev> | 2023-01-12 20:50:18 +0100 |
| commit | 1072f82acbe976222851bdd357f52dd9659d73d3 (patch) | |
| tree | a87970f53b2a9267b35d664d1251655d19c184fa /src | |
| parent | 2339b25fd42ccd136660b9e4575aab2bb85b1163 (diff) | |
| download | zig-1072f82acbe976222851bdd357f52dd9659d73d3.tar.gz zig-1072f82acbe976222851bdd357f52dd9659d73d3.zip | |
wasm-linker: Fix symbol name on undefined symbol
When emitting errors for undefined symbols, rather than
unconditionally always using the name from an import, we must verify
it's a symbol type that could have such an import. e.g. undefined
data symbols do not have a corresponding import. For this reason we
must use the regular name.
Diffstat (limited to 'src')
| -rw-r--r-- | src/link/Wasm.zig | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig index 377d526249..12bb90ea64 100644 --- a/src/link/Wasm.zig +++ b/src/link/Wasm.zig @@ -824,7 +824,9 @@ fn checkUndefinedSymbols(wasm: *const Wasm) !void { } else wasm.name; const import_name = if (undef.file) |file_index| name: { const obj = wasm.objects.items[file_index]; - const name_index = obj.findImport(symbol.tag.externalType(), symbol.index).name; + const name_index = if (symbol.tag == .function) name_index: { + break :name_index obj.findImport(symbol.tag.externalType(), symbol.index).name; + } else symbol.name; break :name obj.string_table.get(name_index); } else wasm.string_table.get(wasm.imports.get(undef).?.name); log.err("could not resolve undefined symbol '{s}'", .{import_name}); |
