diff --git a/src/link/MachO/dead_strip.zig b/src/link/MachO/dead_strip.zig index 7da6ec8196..b329d6e547 100644 --- a/src/link/MachO/dead_strip.zig +++ b/src/link/MachO/dead_strip.zig @@ -104,11 +104,12 @@ fn markLive( alive: *AtomTable, reverse_lookups: [][]u32, ) anyerror!void { + log.debug("mark(ATOM({d}))", .{atom_index}); + if (alive.contains(atom_index)) return; alive.putAssumeCapacityNoClobber(atom_index, {}); - log.debug("marking live", .{}); zld.logAtom(atom_index, log); const cpu_arch = zld.options.target.cpu.arch; @@ -152,11 +153,15 @@ fn markLive( const object = zld.objects.items[target.getFile().?]; const target_atom_index = object.getAtomIndexForSymbol(target.sym_index).?; + log.debug(" following ATOM({d})", .{target_atom_index}); + try markLive(zld, target_atom_index, alive, reverse_lookups); } } fn refersLive(zld: *Zld, atom_index: AtomIndex, alive: AtomTable, reverse_lookups: [][]u32) !bool { + log.debug("refersLive(ATOM({d}))", .{atom_index}); + const cpu_arch = zld.options.target.cpu.arch; const atom = zld.getAtom(atom_index); @@ -191,7 +196,10 @@ fn refersLive(zld: *Zld, atom_index: AtomIndex, alive: AtomTable, reverse_lookup log.debug("atom for symbol '{s}' not found; skipping...", .{zld.getSymbolName(target)}); continue; }; - if (alive.contains(target_atom_index)) return true; + if (alive.contains(target_atom_index)) { + log.debug(" refers live ATOM({d})", .{target_atom_index}); + return true; + } } return false; diff --git a/src/link/MachO/zld.zig b/src/link/MachO/zld.zig index 1029134c17..2c7326358a 100644 --- a/src/link/MachO/zld.zig +++ b/src/link/MachO/zld.zig @@ -444,6 +444,13 @@ pub const Zld = struct { ); }, macho.S_COALESCED => { + // TODO unwind info + if (mem.eql(u8, "__TEXT", segname) and mem.eql(u8, "__eh_frame", sectname)) { + log.debug("TODO eh frame section: type 0x{x}, name '{s},{s}'", .{ + sect.flags, segname, sectname, + }); + break :blk null; + } break :blk self.getSectionByName(segname, sectname) orelse try self.initSection( segname, sectname,