| ... | @@ -145,7 +145,7 @@ pub fn resolveRelocs(self: *Atom, wasm_bin: *const Wasm) void { | ... | @@ -145,7 +145,7 @@ pub fn resolveRelocs(self: *Atom, wasm_bin: *const Wasm) void { |
| 145 | /// All values will be represented as a `u64` as all values can fit within it. | 145 | /// All values will be represented as a `u64` as all values can fit within it. |
| 146 | /// The final value must be casted to the correct size. | 146 | /// The final value must be casted to the correct size. |
| 147 | fn relocationValue(self: Atom, relocation: types.Relocation, wasm_bin: *const Wasm) u64 { | 147 | fn relocationValue(self: Atom, relocation: types.Relocation, wasm_bin: *const Wasm) u64 { |
| 148 | const target_loc: Wasm.SymbolLoc = .{ .file = self.file, .index = relocation.index }; | 148 | const target_loc = (Wasm.SymbolLoc{ .file = self.file, .index = relocation.index }).finalLoc(wasm_bin); |
| 149 | const symbol = target_loc.getSymbol(wasm_bin).*; | 149 | const symbol = target_loc.getSymbol(wasm_bin).*; |
| 150 | switch (relocation.relocation_type) { | 150 | switch (relocation.relocation_type) { |
| 151 | .R_WASM_FUNCTION_INDEX_LEB => return symbol.index, | 151 | .R_WASM_FUNCTION_INDEX_LEB => return symbol.index, |
| ... | @@ -174,8 +174,7 @@ fn relocationValue(self: Atom, relocation: types.Relocation, wasm_bin: *const Wa | ... | @@ -174,8 +174,7 @@ fn relocationValue(self: Atom, relocation: types.Relocation, wasm_bin: *const Wa |
| 174 | => { | 174 | => { |
| 175 | std.debug.assert(symbol.tag == .data and !symbol.isUndefined()); | 175 | std.debug.assert(symbol.tag == .data and !symbol.isUndefined()); |
| 176 | const merge_segment = wasm_bin.base.options.output_mode != .Obj; | 176 | const merge_segment = wasm_bin.base.options.output_mode != .Obj; |
| 177 | const target_atom_loc = wasm_bin.discarded.get(target_loc) orelse target_loc; | 177 | const target_atom = wasm_bin.symbol_atom.get(target_loc).?; |
| 178 | const target_atom = wasm_bin.symbol_atom.get(target_atom_loc).?; | | |
| 179 | const segment_info = if (target_atom.file) |object_index| blk: { | 178 | const segment_info = if (target_atom.file) |object_index| blk: { |
| 180 | break :blk wasm_bin.objects.items[object_index].segment_info; | 179 | break :blk wasm_bin.objects.items[object_index].segment_info; |
| 181 | } else wasm_bin.segment_info.items; | 180 | } else wasm_bin.segment_info.items; |
| ... | @@ -187,6 +186,6 @@ fn relocationValue(self: Atom, relocation: types.Relocation, wasm_bin: *const Wa | ... | @@ -187,6 +186,6 @@ fn relocationValue(self: Atom, relocation: types.Relocation, wasm_bin: *const Wa |
| 187 | .R_WASM_EVENT_INDEX_LEB => return symbol.index, | 186 | .R_WASM_EVENT_INDEX_LEB => return symbol.index, |
| 188 | .R_WASM_SECTION_OFFSET_I32, | 187 | .R_WASM_SECTION_OFFSET_I32, |
| 189 | .R_WASM_FUNCTION_OFFSET_I32, | 188 | .R_WASM_FUNCTION_OFFSET_I32, |
| 190 | => return relocation.offset, | 189 | => return relocation.addend orelse 0, |
| 191 | } | 190 | } |
| 192 | } | 191 | } |