motiejus/zig

fork of https://codeberg.org/ziglang/zig
git clone https://git.jakstys.lt/motiejus/zig.git
Log | Tree | Refs | README | LICENSE

commit 5b9eaf2938b6fb937e9ed6fb9d19bf4c68f3bdc8 (tree)
parent 33d1942f2772af525ca46fa13d5a8719be9a7fb9
Author: Jakub Konka <kubkon@jakubkonka.com>
Date:   Wed, 19 Oct 2022 18:14:38 +0200

macho: do not assume __la_symbol_ptr was created

Diffstat:
Msrc/link/MachO/Object.zig | 12+++---------
Msrc/link/MachO/zld.zig | 3++-
2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/src/link/MachO/Object.zig b/src/link/MachO/Object.zig @@ -287,7 +287,7 @@ pub fn splitIntoAtoms(self: *Object, zld: *Zld, object_id: u31) !void { for (sections) |sect, id| { if (sect.isDebug()) continue; const out_sect_id = (try zld.getOutputSection(sect)) orelse { - log.debug(" unhandled section", .{}); + log.debug(" unhandled section '{s},{s}'", .{ sect.segName(), sect.sectName() }); continue; }; if (sect.size == 0) continue; @@ -306,10 +306,7 @@ pub fn splitIntoAtoms(self: *Object, zld: *Zld, object_id: u31) !void { if (self.in_symtab == null) { for (sections) |sect, id| { if (sect.isDebug()) continue; - const out_sect_id = (try zld.getOutputSection(sect)) orelse { - log.debug(" unhandled section", .{}); - continue; - }; + const out_sect_id = (try zld.getOutputSection(sect)) orelse continue; if (sect.size == 0) continue; const sect_id = @intCast(u8, id); @@ -367,10 +364,7 @@ pub fn splitIntoAtoms(self: *Object, zld: *Zld, object_id: u31) !void { log.debug("splitting section '{s},{s}' into atoms", .{ sect.segName(), sect.sectName() }); // Get output segment/section in the final artifact. - const out_sect_id = (try zld.getOutputSection(sect)) orelse { - log.debug(" unhandled section", .{}); - continue; - }; + const out_sect_id = (try zld.getOutputSection(sect)) orelse continue; log.debug(" output sect({d}, '{s},{s}')", .{ out_sect_id + 1, diff --git a/src/link/MachO/zld.zig b/src/link/MachO/zld.zig @@ -2527,6 +2527,8 @@ pub const Zld = struct { const gpa = self.gpa; const stub_helper_section_index = self.getSectionByName("__TEXT", "__stub_helper") orelse return; + const la_symbol_ptr_section_index = self.getSectionByName("__DATA", "__la_symbol_ptr") orelse return; + if (self.stub_helper_preamble_sym_index == null) return; const section = self.sections.get(stub_helper_section_index); @@ -2537,7 +2539,6 @@ pub const Zld = struct { { var stub_atom_index = last_atom_index; - const la_symbol_ptr_section_index = self.getSectionByName("__DATA", "__la_symbol_ptr").?; var laptr_atom_index = self.sections.items(.last_atom_index)[la_symbol_ptr_section_index]; const base_addr = blk: {