diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2022-02-11 12:16:32 +0100 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2022-02-11 12:16:32 +0100 |
| commit | 066758b1a296aa6f01d505f7b90d5aee2f387d30 (patch) | |
| tree | 50c15027ca05182f8f47e55d2891d9b9d318db66 /src/arch/aarch64/CodeGen.zig | |
| parent | b9b1ab024063105a9adfe3828692867c91015dc6 (diff) | |
| download | zig-066758b1a296aa6f01d505f7b90d5aee2f387d30.tar.gz zig-066758b1a296aa6f01d505f7b90d5aee2f387d30.zip | |
macho: correctly lower slices incl reloc and rebase tracking
Match changes required to `Elf` linker, which enable lowering
of const slices on `MachO` targets.
Expand `Mir` instructions requiring the knowledge of the containing
atom - pass the symbol index into the linker's table from codegen
via mir to emitter, to then utilise it in the linker.
Diffstat (limited to 'src/arch/aarch64/CodeGen.zig')
| -rw-r--r-- | src/arch/aarch64/CodeGen.zig | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/arch/aarch64/CodeGen.zig b/src/arch/aarch64/CodeGen.zig index 42f2c66df1..79fa38e275 100644 --- a/src/arch/aarch64/CodeGen.zig +++ b/src/arch/aarch64/CodeGen.zig @@ -1617,7 +1617,12 @@ fn airCall(self: *Self, inst: Air.Inst.Index) !void { _ = try self.addInst(.{ .tag = .call_extern, - .data = .{ .extern_fn = n_strx }, + .data = .{ + .extern_fn = .{ + .atom_index = self.mod_fn.owner_decl.link.macho.local_sym_index, + .sym_name = n_strx, + }, + }, }); } else { return self.fail("TODO implement calling bitcasted functions", .{}); @@ -2485,9 +2490,18 @@ fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void }); }, .memory => |addr| { + const owner_decl = self.mod_fn.owner_decl; + // TODO when refactoring LinkBlock, make this into a generic function. + const atom_index = switch (self.bin_file.tag) { + .macho => owner_decl.link.macho.local_sym_index, + .elf => owner_decl.link.elf.local_sym_index, + .plan9 => @intCast(u32, owner_decl.link.plan9.sym_index orelse 0), + else => return self.fail("TODO handle aarch64 load memory in {}", .{self.bin_file.tag}), + }; _ = try self.addInst(.{ .tag = .load_memory, .data = .{ .payload = try self.addExtra(Mir.LoadMemory{ + .atom_index = atom_index, .register = @enumToInt(reg), .addr = @intCast(u32, addr), }) }, |
