From 16abf51ceef2ba2ebb38f27270af676387435f05 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Mon, 12 Aug 2024 22:04:18 +0200 Subject: [PATCH] x86_64: handle lea_symbol returned by genNavRef --- src/arch/x86_64/CodeGen.zig | 3 ++- src/codegen.zig | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/arch/x86_64/CodeGen.zig b/src/arch/x86_64/CodeGen.zig index cfeca4c390..dede09fc71 100644 --- a/src/arch/x86_64/CodeGen.zig +++ b/src/arch/x86_64/CodeGen.zig @@ -14104,7 +14104,7 @@ fn airAsm(self: *Self, inst: Air.Inst.Index) !void { .{ .reg = try self.copyToTmpRegister(Type.usize, .{ .lea_got = sym_index }) } else return self.fail("invalid modifier: '{s}'", .{modifier}), - .load_symbol => |sym_off| if (mem.eql(u8, modifier, "P")) + .lea_symbol => |sym_off| if (mem.eql(u8, modifier, "P")) .{ .reg = try self.copyToTmpRegister(Type.usize, .{ .lea_symbol = sym_off }) } else return self.fail("invalid modifier: '{s}'", .{modifier}), @@ -18798,6 +18798,7 @@ fn genTypedValue(self: *Self, val: Value) InnerError!MCValue { .immediate => |imm| .{ .immediate = imm }, .memory => |addr| .{ .memory = addr }, .load_symbol => |sym_index| .{ .load_symbol = .{ .sym = sym_index } }, + .lea_symbol => |sym_index| .{ .lea_symbol = .{ .sym = sym_index } }, .load_direct => |sym_index| .{ .load_direct = sym_index }, .load_got => |sym_index| .{ .lea_got = sym_index }, .load_tlv => |sym_index| .{ .lea_tlv = sym_index }, diff --git a/src/codegen.zig b/src/codegen.zig index f2fa60fdf8..679ee03c27 100644 --- a/src/codegen.zig +++ b/src/codegen.zig @@ -828,6 +828,9 @@ pub const GenResult = union(enum) { /// Reference to memory location but deferred until linker allocated the Decl in memory. /// Traditionally, this corresponds to emitting a relocation in a relocatable object file. load_symbol: u32, + /// Reference to memory location but deferred until linker allocated the Decl in memory. + /// Traditionally, this corresponds to emitting a relocation in a relocatable object file. + lea_symbol: u32, }; fn mcv(val: MCValue) GenResult { @@ -904,7 +907,7 @@ fn genNavRef( if (!single_threaded and is_threadlocal) { return GenResult.mcv(.{ .load_tlv = sym_index }); } - return GenResult.mcv(.{ .load_symbol = sym_index }); + return GenResult.mcv(.{ .lea_symbol = sym_index }); } else if (lf.cast(.macho)) |macho_file| { const zo = macho_file.getZigObject().?; if (is_extern) {