Skip to content

Commit

Permalink
macho: apply rebase reloc to dyld_private pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
kubkon committed Jan 23, 2024
1 parent 706065e commit daa38cc
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/MachO.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2043,6 +2043,16 @@ fn initDyldInfoSections(self: *MachO) !void {

const gpa = self.base.allocator;

if (self.dyld_private_index) |index| {
// Turns out this rebase opcode is only required for <= 11.0 macOS.
const sym = self.getSymbol(index);
const seg_id = self.sections.items(.segment_id)[self.data_sect_index.?];
const seg = self.segments.items[seg_id];
try self.rebase.entries.append(gpa, .{
.offset = sym.getAddress(.{}, self) - seg.vmaddr,
.segment_id = seg_id,
});
}
if (self.got_sect_index != null) try self.got.addDyldRelocs(self);
if (self.tlv_ptr_sect_index != null) try self.tlv_ptr.addDyldRelocs(self);
if (self.la_symbol_ptr_sect_index != null) try self.la_symbol_ptr.addDyldRelocs(self);
Expand Down

0 comments on commit daa38cc

Please sign in to comment.