diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2022-08-11 10:13:16 +0200 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2022-08-12 11:50:39 +0200 |
| commit | f2f1bb7cb675fc14dc7754f06329b5780091baaf (patch) | |
| tree | 319899cc33bff973b32b8f6c170f240f07b10f9c /src | |
| parent | 92568a0097a6aeb0cd59f1f3dae43d0ecd7a18d0 (diff) | |
| download | zig-f2f1bb7cb675fc14dc7754f06329b5780091baaf.tar.gz zig-f2f1bb7cb675fc14dc7754f06329b5780091baaf.zip | |
macho: update __DWARF sections before and after writing out __LINKEDIT
Diffstat (limited to 'src')
| -rw-r--r-- | src/link/Dwarf.zig | 2 | ||||
| -rw-r--r-- | src/link/MachO/DebugSymbols.zig | 16 |
2 files changed, 9 insertions, 9 deletions
diff --git a/src/link/Dwarf.zig b/src/link/Dwarf.zig index 2cd00f5a87..73891a81f5 100644 --- a/src/link/Dwarf.zig +++ b/src/link/Dwarf.zig @@ -1259,7 +1259,7 @@ fn writeDeclDebugInfo(self: *Dwarf, file: *File, atom: *Atom, dbg_info_buf: []co debug_info_sect.addr = dwarf_segment.vmaddr + new_offset - dwarf_segment.fileoff; } debug_info_sect.size = needed_size; - d_sym.debug_line_header_dirty = true; + d_sym.debug_info_header_dirty = true; } const file_pos = debug_info_sect.offset + atom.off; try pwriteDbgInfoNops( diff --git a/src/link/MachO/DebugSymbols.zig b/src/link/MachO/DebugSymbols.zig index 3bfe334302..c2aa562db5 100644 --- a/src/link/MachO/DebugSymbols.zig +++ b/src/link/MachO/DebugSymbols.zig @@ -63,17 +63,16 @@ pub const Reloc = struct { pub fn populateMissingMetadata(self: *DebugSymbols, allocator: Allocator) !void { if (self.linkedit_segment_cmd_index == null) { self.linkedit_segment_cmd_index = @intCast(u8, self.segments.items.len); - log.debug("found __LINKEDIT segment free space 0x{x} to 0x{x}", .{ - self.base.page_size, - self.base.page_size * 2, - }); + const fileoff = @intCast(u64, self.base.page_size); + const needed_size = @intCast(u64, self.base.page_size) * 2; + log.debug("found __LINKEDIT segment free space 0x{x} to 0x{x}", .{ fileoff, needed_size }); // TODO this needs reworking try self.segments.append(allocator, .{ .segname = makeStaticString("__LINKEDIT"), - .vmaddr = self.base.page_size, - .vmsize = self.base.page_size, - .fileoff = self.base.page_size, - .filesize = self.base.page_size, + .vmaddr = fileoff, + .vmsize = needed_size, + .fileoff = fileoff, + .filesize = needed_size, .maxprot = macho.PROT.READ, .initprot = macho.PROT.READ, .cmdsize = @sizeOf(macho.segment_command_64), @@ -284,6 +283,7 @@ pub fn flushModule(self: *DebugSymbols, allocator: Allocator, options: link.Opti const lc_writer = lc_buffer.writer(); var ncmds: u32 = 0; + self.updateDwarfSegment(); try self.writeLinkeditSegmentData(&ncmds, lc_writer); self.updateDwarfSegment(); |
