authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-10-19 16:15:28+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-10-22 07:59:23+02:00
loge70adc7f1ae2160e9adf418c66a5f5b9e219810c
tree6fa5edb44672a8d1147e7e2bf1790b859a0ed617
parentbaceaf65f258d2da422ddd0abdf2452937bd7b6d

macho: skip parsing __eh_frame until we know how to handle it


2 files changed, 17 insertions(+), 2 deletions(-)

src/link/MachO/dead_strip.zig+10-2
...@@ -104,11 +104,12 @@ fn markLive(...@@ -104,11 +104,12 @@ fn markLive(
104 alive: *AtomTable,104 alive: *AtomTable,
105 reverse_lookups: [][]u32,105 reverse_lookups: [][]u32,
106) anyerror!void {106) anyerror!void {
107 log.debug("mark(ATOM({d}))", .{atom_index});
108
107 if (alive.contains(atom_index)) return;109 if (alive.contains(atom_index)) return;
108110
109 alive.putAssumeCapacityNoClobber(atom_index, {});111 alive.putAssumeCapacityNoClobber(atom_index, {});
110112
111 log.debug("marking live", .{});
112 zld.logAtom(atom_index, log);113 zld.logAtom(atom_index, log);
113114
114 const cpu_arch = zld.options.target.cpu.arch;115 const cpu_arch = zld.options.target.cpu.arch;
...@@ -152,11 +153,15 @@ fn markLive(...@@ -152,11 +153,15 @@ fn markLive(
152153
153 const object = zld.objects.items[target.getFile().?];154 const object = zld.objects.items[target.getFile().?];
154 const target_atom_index = object.getAtomIndexForSymbol(target.sym_index).?;155 const target_atom_index = object.getAtomIndexForSymbol(target.sym_index).?;
156 log.debug(" following ATOM({d})", .{target_atom_index});
157
155 try markLive(zld, target_atom_index, alive, reverse_lookups);158 try markLive(zld, target_atom_index, alive, reverse_lookups);
156 }159 }
157}160}
158161
159fn refersLive(zld: *Zld, atom_index: AtomIndex, alive: AtomTable, reverse_lookups: [][]u32) !bool {162fn refersLive(zld: *Zld, atom_index: AtomIndex, alive: AtomTable, reverse_lookups: [][]u32) !bool {
163 log.debug("refersLive(ATOM({d}))", .{atom_index});
164
160 const cpu_arch = zld.options.target.cpu.arch;165 const cpu_arch = zld.options.target.cpu.arch;
161166
162 const atom = zld.getAtom(atom_index);167 const atom = zld.getAtom(atom_index);
...@@ -191,7 +196,10 @@ fn refersLive(zld: *Zld, atom_index: AtomIndex, alive: AtomTable, reverse_lookup...@@ -191,7 +196,10 @@ fn refersLive(zld: *Zld, atom_index: AtomIndex, alive: AtomTable, reverse_lookup
191 log.debug("atom for symbol '{s}' not found; skipping...", .{zld.getSymbolName(target)});196 log.debug("atom for symbol '{s}' not found; skipping...", .{zld.getSymbolName(target)});
192 continue;197 continue;
193 };198 };
194 if (alive.contains(target_atom_index)) return true;199 if (alive.contains(target_atom_index)) {
200 log.debug(" refers live ATOM({d})", .{target_atom_index});
201 return true;
202 }
195 }203 }
196204
197 return false;205 return false;
src/link/MachO/zld.zig+7
...@@ -444,6 +444,13 @@ pub const Zld = struct {...@@ -444,6 +444,13 @@ pub const Zld = struct {
444 );444 );
445 },445 },
446 macho.S_COALESCED => {446 macho.S_COALESCED => {
447 // TODO unwind info
448 if (mem.eql(u8, "__TEXT", segname) and mem.eql(u8, "__eh_frame", sectname)) {
449 log.debug("TODO eh frame section: type 0x{x}, name '{s},{s}'", .{
450 sect.flags, segname, sectname,
451 });
452 break :blk null;
453 }
447 break :blk self.getSectionByName(segname, sectname) orelse try self.initSection(454 break :blk self.getSectionByName(segname, sectname) orelse try self.initSection(
448 segname,455 segname,
449 sectname,456 sectname,