authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-10-19 18:14:38+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-10-22 07:59:23+02:00
log5b9eaf2938b6fb937e9ed6fb9d19bf4c68f3bdc8
treeb4f55d6de8eb6ec0584c97b439a1ad308482e2ec
parent33d1942f2772af525ca46fa13d5a8719be9a7fb9

macho: do not assume __la_symbol_ptr was created


2 files changed, 5 insertions(+), 10 deletions(-)

src/link/MachO/Object.zig+3-9
......@@ -287,7 +287,7 @@ pub fn splitIntoAtoms(self: *Object, zld: *Zld, object_id: u31) !void {
287287 for (sections) |sect, id| {
288288 if (sect.isDebug()) continue;
289289 const out_sect_id = (try zld.getOutputSection(sect)) orelse {
290 log.debug(" unhandled section", .{});
290 log.debug(" unhandled section '{s},{s}'", .{ sect.segName(), sect.sectName() });
291291 continue;
292292 };
293293 if (sect.size == 0) continue;
......@@ -306,10 +306,7 @@ pub fn splitIntoAtoms(self: *Object, zld: *Zld, object_id: u31) !void {
306306 if (self.in_symtab == null) {
307307 for (sections) |sect, id| {
308308 if (sect.isDebug()) continue;
309 const out_sect_id = (try zld.getOutputSection(sect)) orelse {
310 log.debug(" unhandled section", .{});
311 continue;
312 };
309 const out_sect_id = (try zld.getOutputSection(sect)) orelse continue;
313310 if (sect.size == 0) continue;
314311
315312 const sect_id = @intCast(u8, id);
......@@ -367,10 +364,7 @@ pub fn splitIntoAtoms(self: *Object, zld: *Zld, object_id: u31) !void {
367364 log.debug("splitting section '{s},{s}' into atoms", .{ sect.segName(), sect.sectName() });
368365
369366 // Get output segment/section in the final artifact.
370 const out_sect_id = (try zld.getOutputSection(sect)) orelse {
371 log.debug(" unhandled section", .{});
372 continue;
373 };
367 const out_sect_id = (try zld.getOutputSection(sect)) orelse continue;
374368
375369 log.debug(" output sect({d}, '{s},{s}')", .{
376370 out_sect_id + 1,
src/link/MachO/zld.zig+2-1
......@@ -2527,6 +2527,8 @@ pub const Zld = struct {
25272527 const gpa = self.gpa;
25282528
25292529 const stub_helper_section_index = self.getSectionByName("__TEXT", "__stub_helper") orelse return;
2530 const la_symbol_ptr_section_index = self.getSectionByName("__DATA", "__la_symbol_ptr") orelse return;
2531
25302532 if (self.stub_helper_preamble_sym_index == null) return;
25312533
25322534 const section = self.sections.get(stub_helper_section_index);
......@@ -2537,7 +2539,6 @@ pub const Zld = struct {
25372539
25382540 {
25392541 var stub_atom_index = last_atom_index;
2540 const la_symbol_ptr_section_index = self.getSectionByName("__DATA", "__la_symbol_ptr").?;
25412542 var laptr_atom_index = self.sections.items(.last_atom_index)[la_symbol_ptr_section_index];
25422543
25432544 const base_addr = blk: {