From 3ac973c7068f540fa46c0939d3c4bb712b407d37 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Mon, 6 Dec 2021 00:00:50 +0100 Subject: [PATCH] macho: fix incremental codepath for linking objects --- src/link/MachO.zig | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/link/MachO.zig b/src/link/MachO.zig index 74a1d44f078e3f2f7a3675f978e5bac767252677..1f967a9e1995a9012a9c6d7afb32ed09b1fbf1dd 100644 --- a/src/link/MachO.zig +++ b/src/link/MachO.zig @@ -2551,8 +2551,6 @@ fn createDsoHandleAtom(self: *MachO) !void { const vaddr = try self.allocateAtom(atom, 0, 1, match); sym.n_value = vaddr; } else try self.addAtomAndBumpSectionSize(atom, match); - - atom.dirty = false; // We don't really want to write it to file. } } @@ -2898,7 +2896,6 @@ fn createMhExecuteHeaderAtom(self: *MachO) !void { sym.n_value = vaddr; } else try self.addAtomAndBumpSectionSize(atom, match); - atom.dirty = false; self.mh_execute_header_index = local_sym_index; } @@ -2963,6 +2960,8 @@ fn resolveDyldStubBinder(self: *MachO) !void { } fn parseObjectsIntoAtoms(self: *MachO) !void { + // TODO I need to see if I can simplify this logic, or perhaps split it into two functions: + // one for non-prealloc traditional path, and one for incremental prealloc path. const tracy = trace(@src()); defer tracy.end(); @@ -3078,20 +3077,21 @@ fn parseObjectsIntoAtoms(self: *MachO) !void { }; if (!section_metadata.contains(match)) continue; - if (self.atoms.getPtr(match)) |last| { - const first_atom = first_atoms.get(match).?; - last.*.next = first_atom; - first_atom.prev = last.*; - last.* = first_atom; - } - _ = try self.atoms.put(self.base.allocator, match, parsed_atoms.get(match).?); - - if (!self.needs_prealloc) continue; - var base_vaddr = if (self.atoms.get(match)) |last| blk: { const last_atom_sym = self.locals.items[last.local_sym_index]; break :blk last_atom_sym.n_value + last.size; } else sect.addr; + + if (self.atoms.getPtr(match)) |last| { + const first_atom = first_atoms.get(match).?; + last.*.next = first_atom; + first_atom.prev = last.*; + last.* = first_atom; + } + _ = try self.atoms.put(self.base.allocator, match, parsed_atoms.get(match).?); + + if (!self.needs_prealloc) continue; + const n_sect = @intCast(u8, self.section_ordinals.getIndex(match).? + 1); var atom = first_atoms.get(match).?; -- 2.54.0