mirror of
https://github.com/ziglang/zig.git
synced 2026-01-19 13:55:20 +00:00
macho: handle dead stripping of atoms
This commit is contained in:
parent
21e3bb38af
commit
b0327ff233
@ -501,6 +501,10 @@ pub fn flushModule(self: *MachO, arena: Allocator, prog_node: *std.Progress.Node
|
||||
try self.createObjcSections();
|
||||
try self.claimUnresolved();
|
||||
|
||||
if (self.base.gc_sections) {
|
||||
try dead_strip.gcAtoms(self);
|
||||
}
|
||||
|
||||
state_log.debug("{}", .{self.dumpState()});
|
||||
|
||||
@panic("TODO");
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
pub fn gcAtoms(macho_file: *MachO) !void {
|
||||
const gpa = macho_file.base.allocator;
|
||||
const gpa = macho_file.base.comp.gpa;
|
||||
|
||||
var objects = try std.ArrayList(File.Index).initCapacity(gpa, macho_file.objects.items.len + 1);
|
||||
defer objects.deinit();
|
||||
for (macho_file.objects.items) |index| objects.appendAssumeCapacity(index);
|
||||
if (macho_file.internal_object_index) |index| objects.appendAssumeCapacity(index);
|
||||
if (macho_file.internal_object) |index| objects.appendAssumeCapacity(index);
|
||||
|
||||
var roots = std.ArrayList(*Atom).init(gpa);
|
||||
defer roots.deinit();
|
||||
@ -21,7 +21,7 @@ fn collectRoots(roots: *std.ArrayList(*Atom), objects: []const File.Index, macho
|
||||
const sym = macho_file.getSymbol(sym_index);
|
||||
const file = sym.getFile(macho_file) orelse continue;
|
||||
if (file.getIndex() != index) continue;
|
||||
if (sym.flags.no_dead_strip or (macho_file.options.dylib and sym.visibility == .global))
|
||||
if (sym.flags.no_dead_strip or (macho_file.base.isDynLib() and sym.visibility == .global))
|
||||
try markSymbol(sym, roots, macho_file);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user