Skip to content

Commit

Permalink
macho: forgot to commit relocatable.zig
Browse files Browse the repository at this point in the history
  • Loading branch information
kubkon committed Dec 28, 2023
1 parent 31ba576 commit 97cc9e1
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/MachO/relocatable.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
pub fn flush(macho_file: *MachO) !void {
claimUnresolved(macho_file);

state_log.debug("{}", .{macho_file.dumpState()});

macho_file.base.fatal("-r mode unimplemented", .{});
return error.Unimplemented;
}

fn claimUnresolved(macho_file: *MachO) void {
for (macho_file.objects.items) |index| {
const object = macho_file.getFile(index).?.object;

for (object.symbols.items, 0..) |sym_index, i| {
const nlist_idx = @as(Symbol.Index, @intCast(i));
const nlist = object.symtab.items(.nlist)[nlist_idx];
if (!nlist.ext()) continue;
if (!nlist.undf()) continue;

const sym = macho_file.getSymbol(sym_index);
if (sym.getFile(macho_file) != null) continue;

sym.value = 0;
sym.atom = 0;
sym.nlist_idx = nlist_idx;
sym.file = index;
sym.flags.weak_ref = nlist.weakRef();
sym.flags.import = true;
}
}
}

const state_log = std.log.scoped(.state);
const std = @import("std");

const MachO = @import("../MachO.zig");
const Symbol = @import("Symbol.zig");

0 comments on commit 97cc9e1

Please sign in to comment.