diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2023-03-10 19:23:01 +0100 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2023-03-11 20:05:49 +0100 |
| commit | fe1fab4a8ee8d908ab592c63bbc35bbbaa1ed0bf (patch) | |
| tree | 3a61ec90401034adb84990e87b040db3f4d4efc6 /src | |
| parent | d0e72125396c391172758d28c21a9b901dcecc68 (diff) | |
| download | zig-fe1fab4a8ee8d908ab592c63bbc35bbbaa1ed0bf.tar.gz zig-fe1fab4a8ee8d908ab592c63bbc35bbbaa1ed0bf.zip | |
x86_64: fix CALL emits for ELF and Plan9
Diffstat (limited to 'src')
| -rw-r--r-- | src/arch/x86_64/CodeGen.zig | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/arch/x86_64/CodeGen.zig b/src/arch/x86_64/CodeGen.zig index 9056b64dce..6ba81aecdd 100644 --- 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; |
