authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-05-25 06:41:30+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-05-26 06:48:53+01:00
log71e1d7cb8bfe52ccf82f5ba64d1c5d6c5b5077fc
tree84a298159194551dfa253db59e27b4edf6b7f423
parent30f4b05b5f733b57e5e821de9e0ecdc53711a57c
signaturelock-open Commit is signed but in an unrecognized format.

codegen.x86_64: fix Elf2 relocations under PIC


1 files changed, 6 insertions(+), 2 deletions(-)

src/codegen/x86_64/Emit.zig+6-2
...@@ -850,8 +850,12 @@ fn encodeInst(emit: *Emit, lowered_inst: Instruction, reloc_info: []const RelocI...@@ -850,8 +850,12 @@ fn encodeInst(emit: *Emit, lowered_inst: Instruction, reloc_info: []const RelocI
850 emit.atom_id,850 emit.atom_id,
851 end_offset - 4,851 end_offset - 4,
852 target.symbol,852 target.symbol,
853 reloc.off,853 if (emit.pic) reloc.off - 4 else reloc.off,
854 .{ .X86_64 = .@"32S" },854 .{ .X86_64 = rt: {
855 if (!emit.pic) break :rt .@"32S";
856 if (target.is_extern and !target.force_pcrel_direct) break :rt .GOTPCREL;
857 break :rt .PC32;
858 } },
855 ) else if (emit.bin_file.cast(.coff2)) |coff| try coff.addReloc(859 ) else if (emit.bin_file.cast(.coff2)) |coff| try coff.addReloc(
856 @enumFromInt(@intFromEnum(emit.atom_id)),860 @enumFromInt(@intFromEnum(emit.atom_id)),
857 end_offset - 4,861 end_offset - 4,