authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-08-26 13:45:28+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-08-26 13:45:28+02:00
log432fb7054d3214f992af5a2ef652b72d531d660b
tree2129dc226cf0a8292c62f32554a92abcbb858a2a
parentd19d3342c29cc0f5d78cd91b61e5949a86811680

macho: fix stub writing in self-hosted setting


1 files changed, 6 insertions(+), 3 deletions(-)

src/link/MachO.zig+6-3
...@@ -2626,11 +2626,12 @@ fn resolveSymbols(self: *MachO) !void {...@@ -2626,11 +2626,12 @@ fn resolveSymbols(self: *MachO) !void {
2626 undef.n_type |= macho.N_EXT;2626 undef.n_type |= macho.N_EXT;
2627 undef.n_desc = @intCast(u16, ordinal + 1) * macho.N_SYMBOL_RESOLVER;2627 undef.n_desc = @intCast(u16, ordinal + 1) * macho.N_SYMBOL_RESOLVER;
26282628
2629 if (self.unresolved.fetchSwapRemove(resolv.where_index)) |entry| {2629 if (self.unresolved.fetchSwapRemove(resolv.where_index)) |entry| outer_blk: {
2630 switch (entry.value) {2630 switch (entry.value) {
2631 .none => {},2631 .none => {},
2632 .got => return error.TODOGotHint,2632 .got => return error.TODOGotHint,
2633 .stub => {2633 .stub => {
2634 if (self.stubs_map.contains(resolv.where_index)) break :outer_blk;
2634 const stub_helper_atom = blk: {2635 const stub_helper_atom = blk: {
2635 const atom = try self.createStubHelperAtom();2636 const atom = try self.createStubHelperAtom();
2636 const match = MatchingSection{2637 const match = MatchingSection{
...@@ -2654,7 +2655,7 @@ fn resolveSymbols(self: *MachO) !void {...@@ -2654,7 +2655,7 @@ fn resolveSymbols(self: *MachO) !void {
2654 try self.writeAtom(atom, match);2655 try self.writeAtom(atom, match);
2655 break :blk atom;2656 break :blk atom;
2656 };2657 };
2657 {2658 const stub_atom = blk: {
2658 const atom = try self.createStubAtom(laptr_atom.local_sym_index);2659 const atom = try self.createStubAtom(laptr_atom.local_sym_index);
2659 const match = MatchingSection{2660 const match = MatchingSection{
2660 .seg = self.text_segment_cmd_index.?,2661 .seg = self.text_segment_cmd_index.?,
...@@ -2662,7 +2663,9 @@ fn resolveSymbols(self: *MachO) !void {...@@ -2662,7 +2663,9 @@ fn resolveSymbols(self: *MachO) !void {
2662 };2663 };
2663 _ = try self.allocateAtom(atom, match);2664 _ = try self.allocateAtom(atom, match);
2664 try self.writeAtom(atom, match);2665 try self.writeAtom(atom, match);
2665 }2666 break :blk atom;
2667 };
2668 try self.stubs_map.putNoClobber(self.base.allocator, resolv.where_index, stub_atom);
2666 },2669 },
2667 }2670 }
2668 }2671 }