authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-01-12 11:40:07+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-01-24 12:34:39+01:00
logef9aea75d0b1a0727cbf52be9344cd4c04954f9a
treee7c0b8b7ef1bb4b7b1e2bb0cd2e7d8132043586e
parent10a5536a7c9f9545c292f8e863a7cecd89e9ee54

macho: fix dead stripping logic to exclude debug sections


2 files changed, 7 insertions(+), 1 deletions(-)

src/link/MachO/Atom.zig+1
......@@ -173,6 +173,7 @@ pub fn initOutputSection(sect: macho.section_64, macho_file: *MachO) !u8 {
173173pub fn scanRelocs(self: Atom, macho_file: *MachO) !void {
174174 const tracy = trace(@src());
175175 defer tracy.end();
176 assert(self.flags.alive);
176177
177178 const object = self.getFile(macho_file).object;
178179 const relocs = self.getRelocs(macho_file);
src/link/MachO/dead_strip.zig+6-1
......@@ -91,7 +91,12 @@ fn mark(roots: []*Atom, objects: []const File.Index, macho_file: *MachO) void {
9191 for (macho_file.getFile(index).?.getAtoms()) |atom_index| {
9292 const atom = macho_file.getAtom(atom_index).?;
9393 const isec = atom.getInputSection(macho_file);
94 if (isec.isDontDeadStripIfReferencesLive() and !atom.flags.alive and refersLive(atom, macho_file)) {
94 if (isec.isDontDeadStripIfReferencesLive() and
95 !(mem.eql(u8, isec.sectName(), "__eh_frame") or
96 mem.eql(u8, isec.sectName(), "__compact_unwind") or
97 isec.attrs() & macho.S_ATTR_DEBUG != 0) and
98 !atom.flags.alive and refersLive(atom, macho_file))
99 {
95100 markLive(atom, macho_file);
96101 loop = true;
97102 }