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(
104104 alive: *AtomTable,
105105 reverse_lookups: [][]u32,
106106) anyerror!void {
107 log.debug("mark(ATOM({d}))", .{atom_index});
108
107109 if (alive.contains(atom_index)) return;
108110
109111 alive.putAssumeCapacityNoClobber(atom_index, {});
110112
111 log.debug("marking live", .{});
112113 zld.logAtom(atom_index, log);
113114
114115 const cpu_arch = zld.options.target.cpu.arch;
......@@ -152,11 +153,15 @@ fn markLive(
152153
153154 const object = zld.objects.items[target.getFile().?];
154155 const target_atom_index = object.getAtomIndexForSymbol(target.sym_index).?;
156 log.debug(" following ATOM({d})", .{target_atom_index});
157
155158 try markLive(zld, target_atom_index, alive, reverse_lookups);
156159 }
157160}
158161
159162fn refersLive(zld: *Zld, atom_index: AtomIndex, alive: AtomTable, reverse_lookups: [][]u32) !bool {
163 log.debug("refersLive(ATOM({d}))", .{atom_index});
164
160165 const cpu_arch = zld.options.target.cpu.arch;
161166
162167 const atom = zld.getAtom(atom_index);
......@@ -191,7 +196,10 @@ fn refersLive(zld: *Zld, atom_index: AtomIndex, alive: AtomTable, reverse_lookup
191196 log.debug("atom for symbol '{s}' not found; skipping...", .{zld.getSymbolName(target)});
192197 continue;
193198 };
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 }
195203 }
196204
197205 return false;
src/link/MachO/zld.zig+7
......@@ -444,6 +444,13 @@ pub const Zld = struct {
444444 );
445445 },
446446 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 }
447454 break :blk self.getSectionByName(segname, sectname) orelse try self.initSection(
448455 segname,
449456 sectname,