mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 21:08:36 +00:00
wasm linker: fix missed addend for uav and nav fixups
This commit is contained in:
parent
dd9a647210
commit
cde84c8795
@ -677,6 +677,7 @@ fn lowerUavRef(
|
||||
wasm.uav_fixups.appendAssumeCapacity(.{
|
||||
.uavs_exe_index = try wasm.refUavExe(uav.val),
|
||||
.offset = @intCast(code.items.len),
|
||||
.addend = @intCast(offset),
|
||||
});
|
||||
}
|
||||
code.appendNTimesAssumeCapacity(0, ptr_width_bytes);
|
||||
@ -761,6 +762,7 @@ fn lowerNavRef(
|
||||
wasm.nav_fixups.appendAssumeCapacity(.{
|
||||
.navs_exe_index = try wasm.refNavExe(nav_index),
|
||||
.offset = @intCast(code.items.len),
|
||||
.addend = @intCast(offset),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -312,12 +312,14 @@ pub const UavFixup = extern struct {
|
||||
uavs_exe_index: UavsExeIndex,
|
||||
/// Index into `string_bytes`.
|
||||
offset: u32,
|
||||
addend: u32,
|
||||
};
|
||||
|
||||
pub const NavFixup = extern struct {
|
||||
navs_exe_index: NavsExeIndex,
|
||||
/// Index into `string_bytes`.
|
||||
offset: u32,
|
||||
addend: u32,
|
||||
};
|
||||
|
||||
pub const FuncTableFixup = extern struct {
|
||||
|
||||
@ -796,7 +796,7 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void {
|
||||
if (!is_obj) {
|
||||
for (wasm.uav_fixups.items) |uav_fixup| {
|
||||
const ds_id: Wasm.DataSegmentId = .pack(wasm, .{ .uav_exe = uav_fixup.uavs_exe_index });
|
||||
const vaddr = f.data_segments.get(ds_id).?;
|
||||
const vaddr = f.data_segments.get(ds_id).? + uav_fixup.addend;
|
||||
if (!is64) {
|
||||
mem.writeInt(u32, wasm.string_bytes.items[uav_fixup.offset..][0..4], vaddr, .little);
|
||||
} else {
|
||||
@ -805,7 +805,7 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void {
|
||||
}
|
||||
for (wasm.nav_fixups.items) |nav_fixup| {
|
||||
const ds_id: Wasm.DataSegmentId = .pack(wasm, .{ .nav_exe = nav_fixup.navs_exe_index });
|
||||
const vaddr = f.data_segments.get(ds_id).?;
|
||||
const vaddr = f.data_segments.get(ds_id).? + nav_fixup.addend;
|
||||
if (!is64) {
|
||||
mem.writeInt(u32, wasm.string_bytes.items[nav_fixup.offset..][0..4], vaddr, .little);
|
||||
} else {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user