authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-07-20 10:07:46+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-07-20 10:07:46+02:00
log1843ecf51b240c43a4a9a9cadbcc1286b9b9f41a
treeb5668713f7ab8f7d2cd56ceff6205406a74f09bf
parent4bc72c48b76eb59e6f1eb160d3d590606e7ae090

macho: add export to the symbol resolver

in updateDeclExports so that we can track globals for symbol resolution like in the traditional linker.

1 files changed, 9 insertions(+), 1 deletions(-)

src/link/MachO.zig+9-1
......@@ -3726,7 +3726,7 @@ pub fn updateDeclExports(
37263726 const i = if (self.globals_free_list.popOrNull()) |i| i else blk: {
37273727 _ = self.globals.addOneAssumeCapacity();
37283728 self.export_info_dirty = true;
3729 break :blk self.globals.items.len - 1;
3729 break :blk @intCast(u32, self.globals.items.len - 1);
37303730 };
37313731 self.globals.items[i] = .{
37323732 .n_strx = name_str_index,
......@@ -3735,6 +3735,14 @@ pub fn updateDeclExports(
37353735 .n_desc = n_desc,
37363736 .n_value = decl_sym.n_value,
37373737 };
3738 const resolv_name = try self.base.allocator.dupe(u8, exp_name);
3739 const resolv = try self.symbol_resolver.getOrPut(self.base.allocator, resolv_name);
3740 defer if (resolv.found_existing) self.base.allocator.free(resolv_name);
3741 resolv.value_ptr.* = .{
3742 .where = .global,
3743 .where_index = i,
3744 .local_sym_index = decl.link.macho.local_sym_index,
3745 };
37383746
37393747 exp.link.macho.sym_index = @intCast(u32, i);
37403748 }