mirror of
https://github.com/ziglang/zig.git
synced 2026-01-19 13:55:20 +00:00
macho: mark imports and exports
This commit is contained in:
parent
b0327ff233
commit
b28ff75f5d
@ -505,6 +505,8 @@ pub fn flushModule(self: *MachO, arena: Allocator, prog_node: *std.Progress.Node
|
||||
try dead_strip.gcAtoms(self);
|
||||
}
|
||||
|
||||
self.markImportsAndExports();
|
||||
|
||||
state_log.debug("{}", .{self.dumpState()});
|
||||
|
||||
@panic("TODO");
|
||||
@ -1345,6 +1347,44 @@ fn claimUnresolved(self: *MachO) error{OutOfMemory}!void {
|
||||
}
|
||||
}
|
||||
|
||||
fn markImportsAndExports(self: *MachO) void {
|
||||
for (self.objects.items) |index| {
|
||||
for (self.getFile(index).?.getSymbols()) |sym_index| {
|
||||
const sym = self.getSymbol(sym_index);
|
||||
const file = sym.getFile(self) orelse continue;
|
||||
if (sym.visibility != .global) continue;
|
||||
if (file == .dylib and !sym.flags.abs) {
|
||||
sym.flags.import = true;
|
||||
continue;
|
||||
}
|
||||
if (file.getIndex() == index) {
|
||||
sym.flags.@"export" = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (self.undefined_symbols.items) |index| {
|
||||
const sym = self.getSymbol(index);
|
||||
if (sym.getFile(self)) |file| {
|
||||
if (sym.visibility != .global) continue;
|
||||
if (file == .dylib and !sym.flags.abs) sym.flags.import = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (&[_]?Symbol.Index{
|
||||
self.entry_index,
|
||||
self.dyld_stub_binder_index,
|
||||
self.objc_msg_send_index,
|
||||
}) |index| {
|
||||
if (index) |idx| {
|
||||
const sym = self.getSymbol(idx);
|
||||
if (sym.getFile(self)) |file| {
|
||||
if (file == .dylib) sym.flags.import = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn shrinkAtom(self: *MachO, atom_index: Atom.Index, new_block_size: u64) void {
|
||||
_ = self;
|
||||
_ = atom_index;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user