mirror of
https://github.com/ziglang/zig.git
synced 2024-11-30 08:10:13 +00:00
x86_64: deref GOT pointer when requesting var value
This commit is contained in:
parent
79418fa0ab
commit
4d5bf0f09a
@ -402,7 +402,21 @@ fn emit(lower: *Lower, prefix: Prefix, mnemonic: Mnemonic, ops: []const Operand)
|
||||
if (elf_sym.flags.is_extern_ptr) emit_mnemonic = .mov;
|
||||
break :op .{ .mem = Memory.rip(mem_op.sib.ptr_size, 0) };
|
||||
},
|
||||
.mov => break :op .{ .mem = Memory.rip(mem_op.sib.ptr_size, 0) },
|
||||
.mov => {
|
||||
if (elf_sym.flags.is_extern_ptr) {
|
||||
const reg = ops[0].reg;
|
||||
lower.result_insts[lower.result_insts_len] =
|
||||
try Instruction.new(.none, .mov, &[_]Operand{
|
||||
.{ .reg = reg.to64() },
|
||||
.{ .mem = Memory.rip(.qword, 0) },
|
||||
});
|
||||
lower.result_insts_len += 1;
|
||||
break :op .{ .mem = Memory.sib(mem_op.sib.ptr_size, .{ .base = .{
|
||||
.reg = reg.to64(),
|
||||
} }) };
|
||||
}
|
||||
break :op .{ .mem = Memory.rip(mem_op.sib.ptr_size, 0) };
|
||||
},
|
||||
else => unreachable,
|
||||
} else switch (mnemonic) {
|
||||
.call => break :op .{ .mem = Memory.sib(mem_op.sib.ptr_size, .{
|
||||
|
Loading…
Reference in New Issue
Block a user