aboutsummaryrefslogtreecommitdiff
path: root/src/link/Wasm.zig
diff options
context:
space:
mode:
authorLuuk de Gram <luuk@degram.dev>2024-02-05 17:17:07 +0100
committerLuuk de Gram <luuk@degram.dev>2024-02-29 15:23:05 +0100
commit5aec88fa4102e87295bf60971209d114c6ae6733 (patch)
treeaa4a533cf831d6bb93f7b647b5d253059e20a29e /src/link/Wasm.zig
parent5a0f2af7e4aa01f861d86bfe9fb457ffde3d335e (diff)
downloadzig-5aec88fa4102e87295bf60971209d114c6ae6733.tar.gz
zig-5aec88fa4102e87295bf60971209d114c6ae6733.zip
wasm: correctly generate relocations for type index
Previously we could directly write the type index because we used the index that was known in the final binary. However, as we now process the Zig module as its own relocatable object file, we must ensure to generate a relocation for type indexes. This also ensures that we can later link the relocatable object file as a standalone also. This also fixes generating indirect function table entries for ZigObject as it now correctly points to the relocation symbol index rather than the symbol index that owns the relocation.
Diffstat (limited to 'src/link/Wasm.zig')
-rw-r--r--src/link/Wasm.zig4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig
index 26dd8b47b6..5f4277dfdd 100644
--- a/src/link/Wasm.zig
+++ b/src/link/Wasm.zig
@@ -3057,7 +3057,9 @@ fn writeToFile(
try leb.writeULEB128(binary_writer, @as(u32, @intCast(wasm.function_table.count())));
var symbol_it = wasm.function_table.keyIterator();
while (symbol_it.next()) |symbol_loc_ptr| {
- const sym = symbol_loc_ptr.*.getSymbol(wasm);
+ const sym = symbol_loc_ptr.getSymbol(wasm);
+ std.debug.assert(sym.isAlive());
+ std.debug.assert(sym.index < wasm.functions.count() + wasm.imported_functions_count);
try leb.writeULEB128(binary_writer, sym.index);
}