From ee1c3c70580bc8d0259a495cf67c3090196983b5 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Mon, 16 Oct 2023 12:38:40 +0200 Subject: elf: correctly copy and write out debug sections --- src/link/Dwarf.zig | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/link/Dwarf.zig') diff --git a/src/link/Dwarf.zig b/src/link/Dwarf.zig index ffe078f831..a8f4125644 100644 --- a/src/link/Dwarf.zig +++ b/src/link/Dwarf.zig @@ -1851,8 +1851,7 @@ pub fn writeDbgInfoHeader(self: *Dwarf, module: *Module, low_pc: u64, high_pc: u // not including the initial length itself. // We have to come back and write it later after we know the size. const after_init_len = di_buf.items.len + init_len_size; - // +1 for the final 0 that ends the compilation unit children. - const dbg_info_end = self.getDebugInfoEnd().? + 1; + const dbg_info_end = self.getDebugInfoEnd().?; const init_len = dbg_info_end - after_init_len; if (self.bin_file.tag == .macho) { mem.writeIntLittle(u32, di_buf.addManyAsArrayAssumeCapacity(4), @as(u32, @intCast(init_len))); @@ -2501,7 +2500,7 @@ fn getDebugInfoOff(self: Dwarf) ?u32 { fn getDebugInfoEnd(self: Dwarf) ?u32 { const last_index = self.di_atom_last_index orelse return null; const last = self.getAtom(.di_atom, last_index); - return last.off + last.len; + return last.off + last.len + 1; } fn getDebugLineProgramOff(self: Dwarf) ?u32 { -- cgit v1.2.3