authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-03-10 19:23:01+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-03-11 20:05:49+01:00
logfe1fab4a8ee8d908ab592c63bbc35bbbaa1ed0bf
tree3a61ec90401034adb84990e87b040db3f4d4efc6
parentd0e72125396c391172758d28c21a9b901dcecc68

x86_64: fix CALL emits for ELF and Plan9


1 files changed, 8 insertions(+), 2 deletions(-)

src/arch/x86_64/CodeGen.zig+8-2
......@@ -4001,7 +4001,10 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier
40014001 const atom_index = try elf_file.getOrCreateAtomForDecl(func.owner_decl);
40024002 const atom = elf_file.getAtom(atom_index);
40034003 const got_addr = atom.getOffsetTableAddress(elf_file);
4004 try self.asmImmediate(.call, Immediate.s(@intCast(i32, got_addr)));
4004 try self.asmMemory(.call, Memory.sib(.qword, .{
4005 .base = .ds,
4006 .disp = @intCast(i32, got_addr),
4007 }));
40054008 } else if (self.bin_file.cast(link.File.Coff)) |coff_file| {
40064009 const atom_index = try coff_file.getOrCreateAtomForDecl(func.owner_decl);
40074010 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
40304033 const got_addr = p9.bases.data;
40314034 const got_index = decl_block.got_index.?;
40324035 const fn_got_addr = got_addr + got_index * ptr_bytes;
4033 try self.asmImmediate(.call, Immediate.s(@intCast(i32, fn_got_addr)));
4036 try self.asmMemory(.call, Memory.sib(.qword, .{
4037 .base = .ds,
4038 .disp = @intCast(i32, fn_got_addr),
4039 }));
40344040 } else unreachable;
40354041 } else if (func_value.castTag(.extern_fn)) |func_payload| {
40364042 const extern_fn = func_payload.data;