authorgravatar for luuk@degram.devLuuk de Gram <luuk@degram.dev> 2022-12-15 20:28:30+01:00
committergravatar for luuk@degram.devLuuk de Gram <luuk@degram.dev> 2022-12-15 20:28:30+01:00
logae106db8897ce3afd38dbfc1c2c811cd2f2de357
treed0aec126cfe1569b2899bbf3fc173c4ee7258244
parentf95549ddc71f75f3bf15f54f8d03a1a367d0db37
signature Commit is signed but in an unrecognized format.

wasm-linker: Fix debug info relocations


1 files changed, 4 insertions(+), 12 deletions(-)

src/link/Wasm/Atom.zig+4-12
...@@ -204,18 +204,10 @@ fn relocationValue(atom: Atom, relocation: types.Relocation, wasm_bin: *const Wa...@@ -204,18 +204,10 @@ fn relocationValue(atom: Atom, relocation: types.Relocation, wasm_bin: *const Wa
204 return @intCast(u32, rel_value);204 return @intCast(u32, rel_value);
205 },205 },
206 .R_WASM_FUNCTION_OFFSET_I32 => {206 .R_WASM_FUNCTION_OFFSET_I32 => {
207 const target_atom = wasm_bin.symbol_atom.get(target_loc).?;207 const target_atom = wasm_bin.symbol_atom.get(target_loc) orelse {
208 var current_atom = target_atom.getFirst();208 return @bitCast(u32, @as(i32, -1));
209 var offset: u32 = 0;209 };
210 // TODO: Calculate this during atom allocation, rather than210 const offset: u32 = 11 + Wasm.getULEB128Size(target_atom.size); // Header (11 bytes fixed-size) + body size (leb-encoded)
211 // this linear calculation. For now it's done here as atoms
212 // are being sorted after atom allocation, as functions aren't
213 // merged until later.
214 while (true) {
215 offset += 5; // each atom uses 5 bytes to store its body's size
216 if (current_atom == target_atom) break;
217 current_atom = current_atom.next.?;
218 }
219 const rel_value = @intCast(i32, target_atom.offset + offset) + relocation.addend;211 const rel_value = @intCast(i32, target_atom.offset + offset) + relocation.addend;
220 return @intCast(u32, rel_value);212 return @intCast(u32, rel_value);
221 },213 },