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 {...@@ -287,7 +287,7 @@ pub fn splitIntoAtoms(self: *Object, zld: *Zld, object_id: u31) !void {
287 for (sections) |sect, id| {287 for (sections) |sect, id| {
288 if (sect.isDebug()) continue;288 if (sect.isDebug()) continue;
289 const out_sect_id = (try zld.getOutputSection(sect)) orelse {289 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() });
291 continue;291 continue;
292 };292 };
293 if (sect.size == 0) continue;293 if (sect.size == 0) continue;
...@@ -306,10 +306,7 @@ pub fn splitIntoAtoms(self: *Object, zld: *Zld, object_id: u31) !void {...@@ -306,10 +306,7 @@ pub fn splitIntoAtoms(self: *Object, zld: *Zld, object_id: u31) !void {
306 if (self.in_symtab == null) {306 if (self.in_symtab == null) {
307 for (sections) |sect, id| {307 for (sections) |sect, id| {
308 if (sect.isDebug()) continue;308 if (sect.isDebug()) continue;
309 const out_sect_id = (try zld.getOutputSection(sect)) orelse {309 const out_sect_id = (try zld.getOutputSection(sect)) orelse continue;
310 log.debug(" unhandled section", .{});
311 continue;
312 };
313 if (sect.size == 0) continue;310 if (sect.size == 0) continue;
314311
315 const sect_id = @intCast(u8, id);312 const sect_id = @intCast(u8, id);
...@@ -367,10 +364,7 @@ pub fn splitIntoAtoms(self: *Object, zld: *Zld, object_id: u31) !void {...@@ -367,10 +364,7 @@ pub fn splitIntoAtoms(self: *Object, zld: *Zld, object_id: u31) !void {
367 log.debug("splitting section '{s},{s}' into atoms", .{ sect.segName(), sect.sectName() });364 log.debug("splitting section '{s},{s}' into atoms", .{ sect.segName(), sect.sectName() });
368365
369 // Get output segment/section in the final artifact.366 // Get output segment/section in the final artifact.
370 const out_sect_id = (try zld.getOutputSection(sect)) orelse {367 const out_sect_id = (try zld.getOutputSection(sect)) orelse continue;
371 log.debug(" unhandled section", .{});
372 continue;
373 };
374368
375 log.debug(" output sect({d}, '{s},{s}')", .{369 log.debug(" output sect({d}, '{s},{s}')", .{
376 out_sect_id + 1,370 out_sect_id + 1,
src/link/MachO/zld.zig+2-1
...@@ -2527,6 +2527,8 @@ pub const Zld = struct {...@@ -2527,6 +2527,8 @@ pub const Zld = struct {
2527 const gpa = self.gpa;2527 const gpa = self.gpa;
25282528
2529 const stub_helper_section_index = self.getSectionByName("__TEXT", "__stub_helper") orelse return;2529 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
2530 if (self.stub_helper_preamble_sym_index == null) return;2532 if (self.stub_helper_preamble_sym_index == null) return;
25312533
2532 const section = self.sections.get(stub_helper_section_index);2534 const section = self.sections.get(stub_helper_section_index);
...@@ -2537,7 +2539,6 @@ pub const Zld = struct {...@@ -2537,7 +2539,6 @@ pub const Zld = struct {
25372539
2538 {2540 {
2539 var stub_atom_index = last_atom_index;2541 var stub_atom_index = last_atom_index;
2540 const la_symbol_ptr_section_index = self.getSectionByName("__DATA", "__la_symbol_ptr").?;
2541 var laptr_atom_index = self.sections.items(.last_atom_index)[la_symbol_ptr_section_index];2542 var laptr_atom_index = self.sections.items(.last_atom_index)[la_symbol_ptr_section_index];
25422543
2543 const base_addr = blk: {2544 const base_addr = blk: {