aboutsummaryrefslogtreecommitdiff
path: root/src/link/Wasm
diff options
context:
space:
mode:
authorLuuk de Gram <luuk@degram.dev>2021-11-28 12:49:04 +0100
committerLuuk de Gram <luuk@degram.dev>2021-11-28 12:49:04 +0100
commit7226ad2670f267b4d90b84d0e104fbb1fa41fe49 (patch)
tree2f690511466db3bc73e13b994fd3844079e321b6 /src/link/Wasm
parent9b5d61430fc7297b24d870adf42392ad113fa21b (diff)
downloadzig-7226ad2670f267b4d90b84d0e104fbb1fa41fe49.tar.gz
zig-7226ad2670f267b4d90b84d0e104fbb1fa41fe49.zip
wasm-link: Implement indirect function table
The function table contains all function pointers that are called by using call_indirect. During codegen, we create a relocation where the linker will resolve the correct index into the table and stores this value within the data section at the location of the pointer.
Diffstat (limited to 'src/link/Wasm')
-rw-r--r--src/link/Wasm/Atom.zig2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/link/Wasm/Atom.zig b/src/link/Wasm/Atom.zig
index ec336718cc..7f49e069b1 100644
--- a/src/link/Wasm/Atom.zig
+++ b/src/link/Wasm/Atom.zig
@@ -129,7 +129,7 @@ fn relocationValue(relocation: types.Relocation, wasm_bin: *const Wasm) !u64 {
.R_WASM_TABLE_INDEX_I64,
.R_WASM_TABLE_INDEX_SLEB,
.R_WASM_TABLE_INDEX_SLEB64,
- => return error.TodoImplementTableIndex, // find table index from a function symbol
+ => return wasm_bin.function_table.get(relocation.index) orelse 0,
.R_WASM_TYPE_INDEX_LEB => wasm_bin.functions.items[symbol.index].type_index,
.R_WASM_GLOBAL_INDEX_I32,
.R_WASM_GLOBAL_INDEX_LEB,