x86_64: handle lea_symbol returned by genNavRef

This commit is contained in:
Jakub Konka 2024-08-12 22:04:18 +02:00
parent f968dd0cb1
commit 16abf51cee
2 changed files with 6 additions and 2 deletions

View File

@ -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 },

View File

@ -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) {