| ... | ... | @@ -1989,6 +1989,42 @@ fn allocateAtomStage1(self: *MachO, atom: *TextBlock, match: MatchingSection) !v |
| 1989 | 1989 | } |
| 1990 | 1990 | } |
| 1991 | 1991 | |
| 1992 | fn createGotAtom(self: *MachO, key: GotIndirectionKey) !*TextBlock { |
| 1993 | const local_sym_index = @intCast(u32, self.locals.items.len); |
| 1994 | try self.locals.append(self.base.allocator, .{ |
| 1995 | .n_strx = try self.makeString("got_entry"), |
| 1996 | .n_type = macho.N_SECT, |
| 1997 | .n_sect = 0, |
| 1998 | .n_desc = 0, |
| 1999 | .n_value = 0, |
| 2000 | }); |
| 2001 | const atom = try self.createEmptyAtom(local_sym_index, @sizeOf(u64), 3); |
| 2002 | switch (key.where) { |
| 2003 | .local => { |
| 2004 | try atom.relocs.append(self.base.allocator, .{ |
| 2005 | .offset = 0, |
| 2006 | .where = .local, |
| 2007 | .where_index = key.where_index, |
| 2008 | .payload = .{ |
| 2009 | .unsigned = .{ |
| 2010 | .subtractor = null, |
| 2011 | .addend = 0, |
| 2012 | .is_64bit = true, |
| 2013 | }, |
| 2014 | }, |
| 2015 | }); |
| 2016 | try atom.rebases.append(self.base.allocator, 0); |
| 2017 | }, |
| 2018 | .undef => { |
| 2019 | try atom.bindings.append(self.base.allocator, .{ |
| 2020 | .local_sym_index = key.where_index, |
| 2021 | .offset = 0, |
| 2022 | }); |
| 2023 | }, |
| 2024 | } |
| 2025 | return atom; |
| 2026 | } |
| 2027 | |
| 1992 | 2028 | fn createDyldPrivateAtom(self: *MachO) !*TextBlock { |
| 1993 | 2029 | const local_sym_index = @intCast(u32, self.locals.items.len); |
| 1994 | 2030 | try self.locals.append(self.base.allocator, .{ |
| ... | ... | @@ -2777,13 +2813,19 @@ fn resolveDyldStubBinder(self: *MachO) !void { |
| 2777 | 2813 | try self.got_entries.append(self.base.allocator, got_entry); |
| 2778 | 2814 | try self.got_entries_map.putNoClobber(self.base.allocator, got_entry, got_index); |
| 2779 | 2815 | |
| 2780 | | self.binding_info_dirty = true; |
| 2781 | | self.got_entries_count_dirty = true; |
| 2782 | | |
| 2816 | const atom = try self.createGotAtom(got_entry); |
| 2817 | const match = MatchingSection{ |
| 2818 | .seg = self.data_const_segment_cmd_index.?, |
| 2819 | .sect = self.got_section_index.?, |
| 2820 | }; |
| 2821 | // TODO remove once we can incrementally update in stage1 too. |
| 2783 | 2822 | if (!(build_options.is_stage1 and self.base.options.use_stage1)) { |
| 2784 | | // TODO remove once we can incrementally update in stage1 too. |
| 2785 | | try self.writeGotEntry(got_index); |
| 2823 | _ = try self.allocateAtom(atom, match); |
| 2824 | try self.writeAtom(atom, match); |
| 2825 | } else { |
| 2826 | try self.allocateAtomStage1(atom, match); |
| 2786 | 2827 | } |
| 2828 | self.binding_info_dirty = true; |
| 2787 | 2829 | } |
| 2788 | 2830 | |
| 2789 | 2831 | fn parseTextBlocks(self: *MachO) !void { |