commit fe1fab4a8ee8d908ab592c63bbc35bbbaa1ed0bf (tree)
parent d0e72125396c391172758d28c21a9b901dcecc68
Author: Jakub Konka <kubkon@jakubkonka.com>
Date: Fri, 10 Mar 2023 19:23:01 +0100
x86_64: fix CALL emits for ELF and Plan9
Diffstat:
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/arch/x86_64/CodeGen.zig b/src/arch/x86_64/CodeGen.zig
@@ -4001,7 +4001,10 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier
const atom_index = try elf_file.getOrCreateAtomForDecl(func.owner_decl);
const atom = elf_file.getAtom(atom_index);
const got_addr = atom.getOffsetTableAddress(elf_file);
- try self.asmImmediate(.call, Immediate.s(@intCast(i32, got_addr)));
+ try self.asmMemory(.call, Memory.sib(.qword, .{
+ .base = .ds,
+ .disp = @intCast(i32, got_addr),
+ }));
} else if (self.bin_file.cast(link.File.Coff)) |coff_file| {
const atom_index = try coff_file.getOrCreateAtomForDecl(func.owner_decl);
const sym_index = coff_file.getAtom(atom_index).getSymbolIndex().?;
@@ -4030,7 +4033,10 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier
const got_addr = p9.bases.data;
const got_index = decl_block.got_index.?;
const fn_got_addr = got_addr + got_index * ptr_bytes;
- try self.asmImmediate(.call, Immediate.s(@intCast(i32, fn_got_addr)));
+ try self.asmMemory(.call, Memory.sib(.qword, .{
+ .base = .ds,
+ .disp = @intCast(i32, fn_got_addr),
+ }));
} else unreachable;
} else if (func_value.castTag(.extern_fn)) |func_payload| {
const extern_fn = func_payload.data;