aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2021-01-08 22:40:09 +0100
committerJakub Konka <kubkon@jakubkonka.com>2021-01-13 23:54:56 +0100
commit21c7217e09b48bf3bf9656fb1e8e69b85422b02e (patch)
tree8e6b417311640513a6154a9063cd79705a865d83 /src
parent44a052a65f5c59b02383178f36fcc231df28b49f (diff)
downloadzig-21c7217e09b48bf3bf9656fb1e8e69b85422b02e.tar.gz
zig-21c7217e09b48bf3bf9656fb1e8e69b85422b02e.zip
macho: memorize start of stubs in helper
Diffstat (limited to 'src')
-rw-r--r--src/link/MachO.zig12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/link/MachO.zig b/src/link/MachO.zig
index 3c876bf59d..04941c4b68 100644
--- a/src/link/MachO.zig
+++ b/src/link/MachO.zig
@@ -115,7 +115,7 @@ global_symbol_free_list: std.ArrayListUnmanaged(u32) = .{},
offset_table_free_list: std.ArrayListUnmanaged(u32) = .{},
dyld_stub_binder_index: ?u16 = null,
-next_stub_helper_off: ?u64 = null,
+stub_helper_stubs_start_off: ?u64 = null,
/// Table of symbol names aka the string table.
string_table: std.ArrayListUnmanaged(u8) = .{},
@@ -1274,7 +1274,8 @@ pub fn updateDecl(self: *MachO, module: *Module, decl: *Module.Decl) !void {
mem.writeIntSliceLittle(u32, placeholder, aarch64.Instruction.bl(@intCast(i28, displacement)).toU32());
if (!fixup.exists) {
- const end = stub_h.addr + self.next_stub_helper_off.? - stub_h.offset;
+ const stub_off = self.stub_helper_stubs_start_off.? + fixup.symbol * 3 * @sizeOf(u32);
+ const end = stub_h.addr + stub_off - stub_h.offset;
var buf: [@sizeOf(u64)]u8 = undefined;
mem.writeIntLittle(u64, &buf, end);
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 {
}).toU32());
mem.writeIntLittle(u32, cccode[4..8], aarch64.Instruction.b(@intCast(i28, displacement3)).toU32());
mem.writeIntLittle(u32, cccode[8..12], fixup.symbol * 0xd);
- try self.base.file.?.pwriteAll(&cccode, self.next_stub_helper_off.?);
- self.next_stub_helper_off = self.next_stub_helper_off.? + 3 * @sizeOf(u32);
+ try self.base.file.?.pwriteAll(&cccode, stub_off);
try self.rebase_info_table.symbols.append(self.base.allocator, .{
.segment = 3,
@@ -2102,7 +2102,7 @@ pub fn populateMissingMetadata(self: *MachO) !void {
});
self.binding_info_dirty = true;
}
- if (self.next_stub_helper_off == null) {
+ if (self.stub_helper_stubs_start_off == null) {
const text = &self.load_commands.items[self.text_segment_cmd_index.?].Segment;
const sh = &text.sections.items[self.stub_helper_section_index.?];
const data = &self.load_commands.items[self.data_segment_cmd_index.?].Segment;
@@ -2123,7 +2123,7 @@ pub fn populateMissingMetadata(self: *MachO) !void {
.literal = @intCast(u19, displacement2 / 4),
}).toU32());
mem.writeIntLittle(u32, code[12..16], aarch64.Instruction.br(.x16).toU32());
- self.next_stub_helper_off = sh.offset + 4 * @sizeOf(u32);
+ self.stub_helper_stubs_start_off = sh.offset + 4 * @sizeOf(u32);
try self.base.file.?.pwriteAll(&code, sh.offset);
}
}