| ... | @@ -115,7 +115,7 @@ global_symbol_free_list: std.ArrayListUnmanaged(u32) = .{}, | ... | @@ -115,7 +115,7 @@ global_symbol_free_list: std.ArrayListUnmanaged(u32) = .{}, |
| 115 | offset_table_free_list: std.ArrayListUnmanaged(u32) = .{}, | 115 | offset_table_free_list: std.ArrayListUnmanaged(u32) = .{}, |
| 116 | | 116 | |
| 117 | dyld_stub_binder_index: ?u16 = null, | 117 | dyld_stub_binder_index: ?u16 = null, |
| 118 | next_stub_helper_off: ?u64 = null, | 118 | stub_helper_stubs_start_off: ?u64 = null, |
| 119 | | 119 | |
| 120 | /// Table of symbol names aka the string table. | 120 | /// Table of symbol names aka the string table. |
| 121 | string_table: std.ArrayListUnmanaged(u8) = .{}, | 121 | string_table: std.ArrayListUnmanaged(u8) = .{}, |
| ... | @@ -1274,7 +1274,8 @@ pub fn updateDecl(self: *MachO, module: *Module, decl: *Module.Decl) !void { | ... | @@ -1274,7 +1274,8 @@ pub fn updateDecl(self: *MachO, module: *Module, decl: *Module.Decl) !void { |
| 1274 | mem.writeIntSliceLittle(u32, placeholder, aarch64.Instruction.bl(@intCast(i28, displacement)).toU32()); | 1274 | mem.writeIntSliceLittle(u32, placeholder, aarch64.Instruction.bl(@intCast(i28, displacement)).toU32()); |
| 1275 | | 1275 | |
| 1276 | if (!fixup.exists) { | 1276 | if (!fixup.exists) { |
| 1277 | const end = stub_h.addr + self.next_stub_helper_off.? - stub_h.offset; | 1277 | const stub_off = self.stub_helper_stubs_start_off.? + fixup.symbol * 3 * @sizeOf(u32); |
| | 1278 | const end = stub_h.addr + stub_off - stub_h.offset; |
| 1278 | var buf: [@sizeOf(u64)]u8 = undefined; | 1279 | var buf: [@sizeOf(u64)]u8 = undefined; |
| 1279 | mem.writeIntLittle(u64, &buf, end); | 1280 | mem.writeIntLittle(u64, &buf, end); |
| 1280 | try self.base.file.?.pwriteAll(&buf, la_ptr.offset + fixup.symbol * @sizeOf(u64)); | 1281 | try self.base.file.?.pwriteAll(&buf, la_ptr.offset + fixup.symbol * @sizeOf(u64)); |
| ... | @@ -1295,8 +1296,7 @@ pub fn updateDecl(self: *MachO, module: *Module, decl: *Module.Decl) !void { | ... | @@ -1295,8 +1296,7 @@ pub fn updateDecl(self: *MachO, module: *Module, decl: *Module.Decl) !void { |
| 1295 | }).toU32()); | 1296 | }).toU32()); |
| 1296 | mem.writeIntLittle(u32, cccode[4..8], aarch64.Instruction.b(@intCast(i28, displacement3)).toU32()); | 1297 | mem.writeIntLittle(u32, cccode[4..8], aarch64.Instruction.b(@intCast(i28, displacement3)).toU32()); |
| 1297 | mem.writeIntLittle(u32, cccode[8..12], fixup.symbol * 0xd); | 1298 | mem.writeIntLittle(u32, cccode[8..12], fixup.symbol * 0xd); |
| 1298 | try self.base.file.?.pwriteAll(&cccode, self.next_stub_helper_off.?); | 1299 | try self.base.file.?.pwriteAll(&cccode, stub_off); |
| 1299 | self.next_stub_helper_off = self.next_stub_helper_off.? + 3 * @sizeOf(u32); | | |
| 1300 | | 1300 | |
| 1301 | try self.rebase_info_table.symbols.append(self.base.allocator, .{ | 1301 | try self.rebase_info_table.symbols.append(self.base.allocator, .{ |
| 1302 | .segment = 3, | 1302 | .segment = 3, |
| ... | @@ -2102,7 +2102,7 @@ pub fn populateMissingMetadata(self: *MachO) !void { | ... | @@ -2102,7 +2102,7 @@ pub fn populateMissingMetadata(self: *MachO) !void { |
| 2102 | }); | 2102 | }); |
| 2103 | self.binding_info_dirty = true; | 2103 | self.binding_info_dirty = true; |
| 2104 | } | 2104 | } |
| 2105 | if (self.next_stub_helper_off == null) { | 2105 | if (self.stub_helper_stubs_start_off == null) { |
| 2106 | const text = &self.load_commands.items[self.text_segment_cmd_index.?].Segment; | 2106 | const text = &self.load_commands.items[self.text_segment_cmd_index.?].Segment; |
| 2107 | const sh = &text.sections.items[self.stub_helper_section_index.?]; | 2107 | const sh = &text.sections.items[self.stub_helper_section_index.?]; |
| 2108 | const data = &self.load_commands.items[self.data_segment_cmd_index.?].Segment; | 2108 | const data = &self.load_commands.items[self.data_segment_cmd_index.?].Segment; |
| ... | @@ -2123,7 +2123,7 @@ pub fn populateMissingMetadata(self: *MachO) !void { | ... | @@ -2123,7 +2123,7 @@ pub fn populateMissingMetadata(self: *MachO) !void { |
| 2123 | .literal = @intCast(u19, displacement2 / 4), | 2123 | .literal = @intCast(u19, displacement2 / 4), |
| 2124 | }).toU32()); | 2124 | }).toU32()); |
| 2125 | mem.writeIntLittle(u32, code[12..16], aarch64.Instruction.br(.x16).toU32()); | 2125 | mem.writeIntLittle(u32, code[12..16], aarch64.Instruction.br(.x16).toU32()); |
| 2126 | self.next_stub_helper_off = sh.offset + 4 * @sizeOf(u32); | 2126 | self.stub_helper_stubs_start_off = sh.offset + 4 * @sizeOf(u32); |
| 2127 | try self.base.file.?.pwriteAll(&code, sh.offset); | 2127 | try self.base.file.?.pwriteAll(&code, sh.offset); |
| 2128 | } | 2128 | } |
| 2129 | } | 2129 | } |