aboutsummaryrefslogtreecommitdiff
path: root/src/link/Wasm/Object.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/link/Wasm/Object.zig')
-rw-r--r--src/link/Wasm/Object.zig28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/link/Wasm/Object.zig b/src/link/Wasm/Object.zig
index c2243bdf10..363648971a 100644
--- a/src/link/Wasm/Object.zig
+++ b/src/link/Wasm/Object.zig
@@ -930,11 +930,29 @@ pub fn parseIntoAtoms(object: *Object, gpa: Allocator, object_index: u16, wasm_b
reloc.offset -= relocatable_data.offset;
try atom.relocs.append(gpa, reloc);
- if (relocation.isTableIndex()) {
- try wasm_bin.function_table.put(gpa, .{
- .file = object_index,
- .index = relocation.index,
- }, 0);
+ switch (relocation.relocation_type) {
+ .R_WASM_TABLE_INDEX_I32,
+ .R_WASM_TABLE_INDEX_I64,
+ .R_WASM_TABLE_INDEX_SLEB,
+ .R_WASM_TABLE_INDEX_SLEB64,
+ => {
+ try wasm_bin.function_table.put(gpa, .{
+ .file = object_index,
+ .index = relocation.index,
+ }, 0);
+ },
+ .R_WASM_GLOBAL_INDEX_I32,
+ .R_WASM_GLOBAL_INDEX_LEB,
+ => {
+ const sym = object.symtable[relocation.index];
+ if (sym.tag != .global) {
+ try wasm_bin.got_symbols.append(
+ wasm_bin.base.allocator,
+ .{ .file = object_index, .index = relocation.index },
+ );
+ }
+ },
+ else => {},
}
}
}