| ... | @@ -174,14 +174,14 @@ fn relocationValue(atom: Atom, relocation: types.Relocation, wasm_bin: *const Wa | ... | @@ -174,14 +174,14 @@ fn relocationValue(atom: Atom, relocation: types.Relocation, wasm_bin: *const Wa |
| 174 | return 0; | 174 | return 0; |
| 175 | } | 175 | } |
| 176 | const va = @as(i64, @intCast(symbol.virtual_address)); | 176 | const va = @as(i64, @intCast(symbol.virtual_address)); |
| 177 | return @as(u32, @intCast(va + relocation.addend)); | 177 | return @intCast(va + relocation.addend); |
| 178 | }, | 178 | }, |
| 179 | .R_WASM_EVENT_INDEX_LEB => return symbol.index, | 179 | .R_WASM_EVENT_INDEX_LEB => return symbol.index, |
| 180 | .R_WASM_SECTION_OFFSET_I32 => { | 180 | .R_WASM_SECTION_OFFSET_I32 => { |
| 181 | const target_atom_index = wasm_bin.symbol_atom.get(target_loc).?; | 181 | const target_atom_index = wasm_bin.symbol_atom.get(target_loc).?; |
| 182 | const target_atom = wasm_bin.getAtom(target_atom_index); | 182 | const target_atom = wasm_bin.getAtom(target_atom_index); |
| 183 | const rel_value = @as(i32, @intCast(target_atom.offset)) + relocation.addend; | 183 | const rel_value: i32 = @intCast(target_atom.offset); |
| 184 | return @as(u32, @intCast(rel_value)); | 184 | return @intCast(rel_value + relocation.addend); |
| 185 | }, | 185 | }, |
| 186 | .R_WASM_FUNCTION_OFFSET_I32 => { | 186 | .R_WASM_FUNCTION_OFFSET_I32 => { |
| 187 | const target_atom_index = wasm_bin.symbol_atom.get(target_loc) orelse { | 187 | const target_atom_index = wasm_bin.symbol_atom.get(target_loc) orelse { |
| ... | @@ -189,13 +189,14 @@ fn relocationValue(atom: Atom, relocation: types.Relocation, wasm_bin: *const Wa | ... | @@ -189,13 +189,14 @@ fn relocationValue(atom: Atom, relocation: types.Relocation, wasm_bin: *const Wa |
| 189 | }; | 189 | }; |
| 190 | const target_atom = wasm_bin.getAtom(target_atom_index); | 190 | const target_atom = wasm_bin.getAtom(target_atom_index); |
| 191 | const offset: u32 = 11 + Wasm.getULEB128Size(target_atom.size); // Header (11 bytes fixed-size) + body size (leb-encoded) | 191 | const offset: u32 = 11 + Wasm.getULEB128Size(target_atom.size); // Header (11 bytes fixed-size) + body size (leb-encoded) |
| 192 | const rel_value = @as(i32, @intCast(target_atom.offset + offset)) + relocation.addend; | 192 | const rel_value: i32 = @intCast(target_atom.offset + offset); |
| 193 | return @as(u32, @intCast(rel_value)); | 193 | return @intCast(rel_value + relocation.addend); |
| 194 | }, | 194 | }, |
| 195 | .R_WASM_MEMORY_ADDR_TLS_SLEB, | 195 | .R_WASM_MEMORY_ADDR_TLS_SLEB, |
| 196 | .R_WASM_MEMORY_ADDR_TLS_SLEB64, | 196 | .R_WASM_MEMORY_ADDR_TLS_SLEB64, |
| 197 | => { | 197 | => { |
| 198 | @panic("TODO: Implement TLS relocations"); | 198 | const va: i32 = @intCast(symbol.virtual_address); |
| | 199 | return @intCast(va + relocation.addend); |
| 199 | }, | 200 | }, |
| 200 | } | 201 | } |
| 201 | } | 202 | } |