diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2022-09-11 01:18:17 +0200 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2022-09-18 10:00:04 +0200 |
| commit | 53bd7bd044fccc70699b04d9ae37151423f70165 (patch) | |
| tree | 944ab4ac3c715b1ada6e4e804d5fefead89305df /src/arch/aarch64/Emit.zig | |
| parent | 34f9360ea20228b895df10b3950c72f40efb6843 (diff) | |
| download | zig-53bd7bd044fccc70699b04d9ae37151423f70165.tar.gz zig-53bd7bd044fccc70699b04d9ae37151423f70165.zip | |
macho: move to incremental writes and global relocs for incremental
Diffstat (limited to 'src/arch/aarch64/Emit.zig')
| -rw-r--r-- | src/arch/aarch64/Emit.zig | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/src/arch/aarch64/Emit.zig b/src/arch/aarch64/Emit.zig index 9e243a3f86..a868b74edc 100644 --- a/src/arch/aarch64/Emit.zig +++ b/src/arch/aarch64/Emit.zig @@ -680,16 +680,15 @@ fn mirCallExtern(emit: *Emit, inst: Mir.Inst.Index) !void { break :blk offset; }; // Add relocation to the decl. - const atom = macho_file.atom_by_index_table.get(relocation.atom_index).?; + const atom = macho_file.getAtomForSymbol(.{ .sym_index = relocation.atom_index, .file = null }).?; const target = macho_file.getGlobalByIndex(relocation.sym_index); - try atom.relocs.append(emit.bin_file.allocator, .{ - .offset = offset, + try atom.addRelocation(macho_file, .{ + .@"type" = @enumToInt(std.macho.reloc_type_arm64.ARM64_RELOC_BRANCH26), .target = target, + .offset = offset, .addend = 0, - .subtractor = null, .pcrel = true, .length = 2, - .@"type" = @enumToInt(std.macho.reloc_type_arm64.ARM64_RELOC_BRANCH26), }); } else { return emit.fail("Implement call_extern for linking backends != MachO", .{}); @@ -882,13 +881,13 @@ fn mirLoadMemoryPie(emit: *Emit, inst: Mir.Inst.Index) !void { } if (emit.bin_file.cast(link.File.MachO)) |macho_file| { - const atom = macho_file.atom_by_index_table.get(data.atom_index).?; - // Page reloc for adrp instruction. - try atom.relocs.append(emit.bin_file.allocator, .{ - .offset = offset, + const atom = macho_file.getAtomForSymbol(.{ .sym_index = data.atom_index, .file = null }).?; + // TODO this causes segfault in stage1 + // try atom.addRelocations(macho_file, 2, .{ + try atom.addRelocation(macho_file, .{ .target = .{ .sym_index = data.sym_index, .file = null }, + .offset = offset, .addend = 0, - .subtractor = null, .pcrel = true, .length = 2, .@"type" = switch (tag) { @@ -901,12 +900,10 @@ fn mirLoadMemoryPie(emit: *Emit, inst: Mir.Inst.Index) !void { else => unreachable, }, }); - // Pageoff reloc for adrp instruction. - try atom.relocs.append(emit.bin_file.allocator, .{ - .offset = offset + 4, + try atom.addRelocation(macho_file, .{ .target = .{ .sym_index = data.sym_index, .file = null }, + .offset = offset + 4, .addend = 0, - .subtractor = null, .pcrel = false, .length = 2, .@"type" = switch (tag) { |
