diff options
| author | Luuk de Gram <luuk@degram.dev> | 2022-12-16 18:31:24 +0100 |
|---|---|---|
| committer | Luuk de Gram <luuk@degram.dev> | 2022-12-16 18:31:24 +0100 |
| commit | 476202eec03a2196daab7f9998c556796cc42eca (patch) | |
| tree | 9a637647a15920ea59a6e07ea49494f96b33eeb0 /src/link/Wasm.zig | |
| parent | ae106db8897ce3afd38dbfc1c2c811cd2f2de357 (diff) | |
| download | zig-476202eec03a2196daab7f9998c556796cc42eca.tar.gz zig-476202eec03a2196daab7f9998c556796cc42eca.zip | |
wasm-linker: Fix archive symbols parsing
When parsing the table of contents containing the symbols and their
positions we initially used the index within the map to retrieve
the offset. However, during resizing of the underlaying array this
would invalidate those indexes which meant incorrect offsets were
being stored for symbols. We now use the current symbol index
to also get the index into the symbol position instead.
Diffstat (limited to 'src/link/Wasm.zig')
| -rw-r--r-- | src/link/Wasm.zig | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig index e89422d0ae..d8aab58ef1 100644 --- a/src/link/Wasm.zig +++ b/src/link/Wasm.zig @@ -625,7 +625,7 @@ fn resolveSymbolsInObject(wasm: *Wasm, object_index: u16) !void { try wasm.resolved_symbols.put(wasm.base.allocator, location, {}); assert(wasm.resolved_symbols.swapRemove(existing_loc)); if (existing_sym.isUndefined()) { - assert(wasm.undefs.swapRemove(sym_name)); + _ = wasm.undefs.swapRemove(sym_name); } } } @@ -636,8 +636,7 @@ fn resolveSymbolsInArchives(wasm: *Wasm) !void { log.debug("Resolving symbols in archives", .{}); var index: u32 = 0; undef_loop: while (index < wasm.undefs.count()) { - const undef_sym_loc = wasm.undefs.values()[index]; - const sym_name = undef_sym_loc.getName(wasm); + const sym_name = wasm.undefs.keys()[index]; for (wasm.archives.items) |archive| { const offset = archive.toc.get(sym_name) orelse { |
