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...@@ -4001,7 +4001,10 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier
4001 const atom_index = try elf_file.getOrCreateAtomForDecl(func.owner_decl);4001 const atom_index = try elf_file.getOrCreateAtomForDecl(func.owner_decl);
4002 const atom = elf_file.getAtom(atom_index);4002 const atom = elf_file.getAtom(atom_index);
4003 const got_addr = atom.getOffsetTableAddress(elf_file);4003 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 }));
4005 } else if (self.bin_file.cast(link.File.Coff)) |coff_file| {4008 } else if (self.bin_file.cast(link.File.Coff)) |coff_file| {
4006 const atom_index = try coff_file.getOrCreateAtomForDecl(func.owner_decl);4009 const atom_index = try coff_file.getOrCreateAtomForDecl(func.owner_decl);
4007 const sym_index = coff_file.getAtom(atom_index).getSymbolIndex().?;4010 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...@@ -4030,7 +4033,10 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier
4030 const got_addr = p9.bases.data;4033 const got_addr = p9.bases.data;
4031 const got_index = decl_block.got_index.?;4034 const got_index = decl_block.got_index.?;
4032 const fn_got_addr = got_addr + got_index * ptr_bytes;4035 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 }));
4034 } else unreachable;4040 } else unreachable;
4035 } else if (func_value.castTag(.extern_fn)) |func_payload| {4041 } else if (func_value.castTag(.extern_fn)) |func_payload| {
4036 const extern_fn = func_payload.data;4042 const extern_fn = func_payload.data;