authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-10-21 05:07:14+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-10-23 09:27:17+02:00
logfc48f8aa553e3d0c03393d976e36f217099cab25
treeb5e8a8de91af013da453e0dbb59405367baa887e
parent4193ea8239264c7ee6891e9ef5ee756e13833fb2
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.pie: add alpha support


1 files changed, 11 insertions(+), 0 deletions(-)

lib/std/pie.zig+11
......@@ -3,6 +3,7 @@ const builtin = @import("builtin");
33const elf = std.elf;
44const assert = std.debug.assert;
55
6const R_ALPHA_RELATIVE = 27;
67const R_AMD64_RELATIVE = 8;
78const R_386_RELATIVE = 8;
89const R_ARC_RELATIVE = 56;
......@@ -25,6 +26,7 @@ const R_RELATIVE = switch (builtin.cpu.arch) {
2526 .arc, .arceb => R_ARC_RELATIVE,
2627 .arm, .armeb, .thumb, .thumbeb => R_ARM_RELATIVE,
2728 .aarch64, .aarch64_be => R_AARCH64_RELATIVE,
29 .alpha => R_ALPHA_RELATIVE,
2830 .csky => R_CSKY_RELATIVE,
2931 .hexagon => R_HEXAGON_RELATIVE,
3032 .loongarch32, .loongarch64 => R_LARCH_RELATIVE,
......@@ -83,6 +85,15 @@ inline fn getDynamicSymbol() [*]const elf.Dyn {
8385 \\ add %[ret], %[ret], #:lo12:_DYNAMIC
8486 : [ret] "=r" (-> [*]const elf.Dyn),
8587 ),
88 // The compiler is not required to load the GP register, so do it ourselves.
89 .alpha => asm volatile (
90 \\ br $29, 1f
91 \\1:
92 \\ ldgp $29, 0($29)
93 \\ ldq %[ret], -0x8000($29)
94 : [ret] "=r" (-> [*]const elf.Dyn),
95 :
96 : .{ .r26 = true }),
8697 // The CSKY ABI requires the gb register to point to the GOT. Additionally, the first
8798 // entry in the GOT is defined to hold the address of _DYNAMIC.
8899 .csky => asm volatile (