| author | |
| committer | |
| log | d136d06a77baeef8680b6a8f334922a8f70da2bf |
| tree | 0dc163399061de672322af731a7a886217982158 |
| parent | e2bfd6fc691a92f9dc36597a8febb03293b0f5ad |
2 files changed, 18 insertions(+), 3 deletions(-)
src/link/MachO/dyld_info/Rebase.zig+14-1| ... | @@ -25,9 +25,10 @@ pub fn updateSize(rebase: *Rebase, macho_file: *MachO) !void { | ... | @@ -25,9 +25,10 @@ pub fn updateSize(rebase: *Rebase, macho_file: *MachO) !void { |
| 25 | 25 | ||
| 26 | const gpa = macho_file.base.comp.gpa; | 26 | const gpa = macho_file.base.comp.gpa; |
| 27 | 27 | ||
| 28 | var objects = try std.ArrayList(File.Index).initCapacity(gpa, macho_file.objects.items.len + 1); | 28 | var objects = try std.ArrayList(File.Index).initCapacity(gpa, macho_file.objects.items.len + 2); |
| 29 | defer objects.deinit(); | 29 | defer objects.deinit(); |
| 30 | objects.appendSliceAssumeCapacity(macho_file.objects.items); | 30 | objects.appendSliceAssumeCapacity(macho_file.objects.items); |
| 31 | if (macho_file.getZigObject()) |obj| objects.appendAssumeCapacity(obj.index); | ||
| 31 | if (macho_file.getInternalObject()) |obj| objects.appendAssumeCapacity(obj.index); | 32 | if (macho_file.getInternalObject()) |obj| objects.appendAssumeCapacity(obj.index); |
| 32 | 33 | ||
| 33 | for (objects.items) |index| { | 34 | for (objects.items) |index| { |
| ... | @@ -55,6 +56,18 @@ pub fn updateSize(rebase: *Rebase, macho_file: *MachO) !void { | ... | @@ -55,6 +56,18 @@ pub fn updateSize(rebase: *Rebase, macho_file: *MachO) !void { |
| 55 | } | 56 | } |
| 56 | } | 57 | } |
| 57 | 58 | ||
| 59 | if (macho_file.zig_got_sect_index) |sid| { | ||
| 60 | const seg_id = macho_file.sections.items(.segment_id)[sid]; | ||
| 61 | const seg = macho_file.segments.items[seg_id]; | ||
| 62 | for (0..macho_file.zig_got.entries.items.len) |idx| { | ||
| 63 | const addr = macho_file.zig_got.entryAddress(@intCast(idx), macho_file); | ||
| 64 | try rebase.entries.append(gpa, .{ | ||
| 65 | .offset = addr - seg.vmaddr, | ||
| 66 | .segment_id = seg_id, | ||
| 67 | }); | ||
| 68 | } | ||
| 69 | } | ||
| 70 | |||
| 58 | if (macho_file.got_sect_index) |sid| { | 71 | if (macho_file.got_sect_index) |sid| { |
| 59 | const seg_id = macho_file.sections.items(.segment_id)[sid]; | 72 | const seg_id = macho_file.sections.items(.segment_id)[sid]; |
| 60 | const seg = macho_file.segments.items[seg_id]; | 73 | const seg = macho_file.segments.items[seg_id]; |
src/link/MachO/dyld_info/bind.zig+4-2| ... | @@ -35,9 +35,10 @@ pub const Bind = struct { | ... | @@ -35,9 +35,10 @@ pub const Bind = struct { |
| 35 | const gpa = macho_file.base.comp.gpa; | 35 | const gpa = macho_file.base.comp.gpa; |
| 36 | const cpu_arch = macho_file.getTarget().cpu.arch; | 36 | const cpu_arch = macho_file.getTarget().cpu.arch; |
| 37 | 37 | ||
| 38 | var objects = try std.ArrayList(File.Index).initCapacity(gpa, macho_file.objects.items.len + 1); | 38 | var objects = try std.ArrayList(File.Index).initCapacity(gpa, macho_file.objects.items.len + 2); |
| 39 | defer objects.deinit(); | 39 | defer objects.deinit(); |
| 40 | objects.appendSliceAssumeCapacity(macho_file.objects.items); | 40 | objects.appendSliceAssumeCapacity(macho_file.objects.items); |
| 41 | if (macho_file.getZigObject()) |obj| objects.appendAssumeCapacity(obj.index); | ||
| 41 | if (macho_file.getInternalObject()) |obj| objects.appendAssumeCapacity(obj.index); | 42 | if (macho_file.getInternalObject()) |obj| objects.appendAssumeCapacity(obj.index); |
| 42 | 43 | ||
| 43 | for (objects.items) |index| { | 44 | for (objects.items) |index| { |
| ... | @@ -286,9 +287,10 @@ pub const WeakBind = struct { | ... | @@ -286,9 +287,10 @@ pub const WeakBind = struct { |
| 286 | const gpa = macho_file.base.comp.gpa; | 287 | const gpa = macho_file.base.comp.gpa; |
| 287 | const cpu_arch = macho_file.getTarget().cpu.arch; | 288 | const cpu_arch = macho_file.getTarget().cpu.arch; |
| 288 | 289 | ||
| 289 | var objects = try std.ArrayList(File.Index).initCapacity(gpa, macho_file.objects.items.len + 1); | 290 | var objects = try std.ArrayList(File.Index).initCapacity(gpa, macho_file.objects.items.len + 2); |
| 290 | defer objects.deinit(); | 291 | defer objects.deinit(); |
| 291 | objects.appendSliceAssumeCapacity(macho_file.objects.items); | 292 | objects.appendSliceAssumeCapacity(macho_file.objects.items); |
| 293 | if (macho_file.getZigObject()) |obj| objects.appendAssumeCapacity(obj.index); | ||
| 292 | if (macho_file.getInternalObject()) |obj| objects.appendAssumeCapacity(obj.index); | 294 | if (macho_file.getInternalObject()) |obj| objects.appendAssumeCapacity(obj.index); |
| 293 | 295 | ||
| 294 | for (objects.items) |index| { | 296 | for (objects.items) |index| { |