authorgravatar for jacoblevgw@gmail.comJacob G-W <jacoblevgw@gmail.com> 2021-12-17 18:20:34-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-12-18 17:54:20-08:00
log9a8fdbe0a07ed9ece1d44634c6fe82c23b6209eb
treef4d482b7d494c50033dae5805f06488d3a4e3a41
parent6adecdc58ab34656aee2c6bcf7928507c0ed265f

plan9 linker: fix off by 1 error


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

src/link/Plan9.zig+3-4
...@@ -406,14 +406,14 @@ pub fn flushModule(self: *Plan9, comp: *Compilation) !void {...@@ -406,14 +406,14 @@ pub fn flushModule(self: *Plan9, comp: *Compilation) !void {
406 defer linecountinfo.deinit();406 defer linecountinfo.deinit();
407 // text407 // text
408 {408 {
409 var linecount: u32 = 0;409 var linecount: i64 = -1;
410 var it_file = self.fn_decl_table.iterator();410 var it_file = self.fn_decl_table.iterator();
411 while (it_file.next()) |fentry| {411 while (it_file.next()) |fentry| {
412 var it = fentry.value_ptr.functions.iterator();412 var it = fentry.value_ptr.functions.iterator();
413 while (it.next()) |entry| {413 while (it.next()) |entry| {
414 const decl = entry.key_ptr.*;414 const decl = entry.key_ptr.*;
415 const out = entry.value_ptr.*;415 const out = entry.value_ptr.*;
416 log.debug("write text decl {*} ({s}), lines {d} to {d}", .{ decl, decl.name, out.start_line, out.end_line });416 log.debug("write text decl {*} ({s}), lines {d} to {d}", .{ decl, decl.name, out.start_line + 1, out.end_line });
417 {417 {
418 // connect the previous decl to the next418 // connect the previous decl to the next
419 const delta_line = @intCast(i32, out.start_line) - @intCast(i32, linecount);419 const delta_line = @intCast(i32, out.start_line) - @intCast(i32, linecount);
...@@ -660,8 +660,7 @@ pub fn openPath(allocator: Allocator, sub_path: []const u8, options: link.Option...@@ -660,8 +660,7 @@ pub fn openPath(allocator: Allocator, sub_path: []const u8, options: link.Option
660}660}
661661
662pub fn writeSym(self: *Plan9, w: anytype, sym: aout.Sym) !void {662pub fn writeSym(self: *Plan9, w: anytype, sym: aout.Sym) !void {
663 log.debug("write sym.name: {s}", .{sym.name});663 log.debug("write sym{{name: {s}, value: {x}}}", .{ sym.name, sym.value });
664 log.debug("write sym.value: {x}", .{sym.value});
665 if (sym.type == .bad) return; // we don't want to write free'd symbols664 if (sym.type == .bad) return; // we don't want to write free'd symbols
666 if (!self.sixtyfour_bit) {665 if (!self.sixtyfour_bit) {
667 try w.writeIntBig(u32, @intCast(u32, sym.value));666 try w.writeIntBig(u32, @intCast(u32, sym.value));