Commit ef9aea75d0
Changed files (2)
src
link
src/link/MachO/Atom.zig
@@ -173,6 +173,7 @@ pub fn initOutputSection(sect: macho.section_64, macho_file: *MachO) !u8 {
pub fn scanRelocs(self: Atom, macho_file: *MachO) !void {
const tracy = trace(@src());
defer tracy.end();
+ assert(self.flags.alive);
const object = self.getFile(macho_file).object;
const relocs = self.getRelocs(macho_file);
src/link/MachO/dead_strip.zig
@@ -91,7 +91,12 @@ fn mark(roots: []*Atom, objects: []const File.Index, macho_file: *MachO) void {
for (macho_file.getFile(index).?.getAtoms()) |atom_index| {
const atom = macho_file.getAtom(atom_index).?;
const isec = atom.getInputSection(macho_file);
- if (isec.isDontDeadStripIfReferencesLive() and !atom.flags.alive and refersLive(atom, macho_file)) {
+ if (isec.isDontDeadStripIfReferencesLive() and
+ !(mem.eql(u8, isec.sectName(), "__eh_frame") or
+ mem.eql(u8, isec.sectName(), "__compact_unwind") or
+ isec.attrs() & macho.S_ATTR_DEBUG != 0) and
+ !atom.flags.alive and refersLive(atom, macho_file))
+ {
markLive(atom, macho_file);
loop = true;
}