| ... | @@ -143,6 +143,7 @@ unresolved: std.AutoArrayHashMapUnmanaged(u32, void) = .{}, | ... | @@ -143,6 +143,7 @@ unresolved: std.AutoArrayHashMapUnmanaged(u32, void) = .{}, |
| 143 | locals_free_list: std.ArrayListUnmanaged(u32) = .{}, | 143 | locals_free_list: std.ArrayListUnmanaged(u32) = .{}, |
| 144 | globals_free_list: std.ArrayListUnmanaged(u32) = .{}, | 144 | globals_free_list: std.ArrayListUnmanaged(u32) = .{}, |
| 145 | | 145 | |
| | 146 | dyld_private_sym_index: ?u32 = null, |
| 146 | dyld_stub_binder_index: ?u32 = null, | 147 | dyld_stub_binder_index: ?u32 = null, |
| 147 | | 148 | |
| 148 | stub_helper_stubs_start_off: ?u64 = null, | 149 | stub_helper_stubs_start_off: ?u64 = null, |
| ... | @@ -758,6 +759,7 @@ pub fn flush(self: *MachO, comp: *Compilation) !void { | ... | @@ -758,6 +759,7 @@ pub fn flush(self: *MachO, comp: *Compilation) !void { |
| 758 | try self.parseLibs(libs.items, self.base.options.sysroot); | 759 | try self.parseLibs(libs.items, self.base.options.sysroot); |
| 759 | try self.resolveSymbols(); | 760 | try self.resolveSymbols(); |
| 760 | try self.resolveDyldStubBinder(); | 761 | try self.resolveDyldStubBinder(); |
| | 762 | try self.createDyldPrivateAtom(); |
| 761 | | 763 | |
| 762 | if (!use_stage1) { | 764 | if (!use_stage1) { |
| 763 | // TODO this should be made common when I figure out how to prealloc space for traditional linker path. | 765 | // TODO this should be made common when I figure out how to prealloc space for traditional linker path. |
| ... | @@ -1963,7 +1965,31 @@ fn createEmptyAtom( | ... | @@ -1963,7 +1965,31 @@ fn createEmptyAtom( |
| 1963 | return block; | 1965 | return block; |
| 1964 | } | 1966 | } |
| 1965 | | 1967 | |
| | 1968 | fn createDyldPrivateAtom(self: *MachO) !void { |
| | 1969 | if (self.dyld_private_sym_index != null) return; |
| | 1970 | |
| | 1971 | const match = MatchingSection{ |
| | 1972 | .seg = self.data_segment_cmd_index.?, |
| | 1973 | .sect = self.data_section_index.?, |
| | 1974 | }; |
| | 1975 | const local_sym_index = @intCast(u32, self.locals.items.len); |
| | 1976 | try self.locals.append(self.base.allocator, .{ |
| | 1977 | .n_strx = try self.makeString("dyld_private"), |
| | 1978 | .n_type = macho.N_SECT, |
| | 1979 | .n_sect = 0, |
| | 1980 | .n_desc = 0, |
| | 1981 | .n_value = 0, |
| | 1982 | }); |
| | 1983 | _ = try self.createEmptyAtom(match, local_sym_index, @sizeOf(u64), 3); |
| | 1984 | |
| | 1985 | self.dyld_private_sym_index = local_sym_index; |
| | 1986 | } |
| | 1987 | |
| 1966 | // fn createStubHelperPreambleAtom(self: *MachO) !void { | 1988 | // fn createStubHelperPreambleAtom(self: *MachO) !void { |
| | 1989 | // const match = MatchingSection{ |
| | 1990 | // .seg = self.text_segment_cmd_index.?, |
| | 1991 | // .sect = self.stub_helper_section_index.?, |
| | 1992 | // }; |
| 1967 | // switch (self.base.options.target.cpu.arch) { | 1993 | // switch (self.base.options.target.cpu.arch) { |
| 1968 | // .x86_64 => { | 1994 | // .x86_64 => { |
| 1969 | // const code_size = 15; | 1995 | // const code_size = 15; |