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");...@@ -3,6 +3,7 @@ const builtin = @import("builtin");
3const elf = std.elf;3const elf = std.elf;
4const assert = std.debug.assert;4const assert = std.debug.assert;
55
6const R_ALPHA_RELATIVE = 27;
6const R_AMD64_RELATIVE = 8;7const R_AMD64_RELATIVE = 8;
7const R_386_RELATIVE = 8;8const R_386_RELATIVE = 8;
8const R_ARC_RELATIVE = 56;9const R_ARC_RELATIVE = 56;
...@@ -25,6 +26,7 @@ const R_RELATIVE = switch (builtin.cpu.arch) {...@@ -25,6 +26,7 @@ const R_RELATIVE = switch (builtin.cpu.arch) {
25 .arc, .arceb => R_ARC_RELATIVE,26 .arc, .arceb => R_ARC_RELATIVE,
26 .arm, .armeb, .thumb, .thumbeb => R_ARM_RELATIVE,27 .arm, .armeb, .thumb, .thumbeb => R_ARM_RELATIVE,
27 .aarch64, .aarch64_be => R_AARCH64_RELATIVE,28 .aarch64, .aarch64_be => R_AARCH64_RELATIVE,
29 .alpha => R_ALPHA_RELATIVE,
28 .csky => R_CSKY_RELATIVE,30 .csky => R_CSKY_RELATIVE,
29 .hexagon => R_HEXAGON_RELATIVE,31 .hexagon => R_HEXAGON_RELATIVE,
30 .loongarch32, .loongarch64 => R_LARCH_RELATIVE,32 .loongarch32, .loongarch64 => R_LARCH_RELATIVE,
...@@ -83,6 +85,15 @@ inline fn getDynamicSymbol() [*]const elf.Dyn {...@@ -83,6 +85,15 @@ inline fn getDynamicSymbol() [*]const elf.Dyn {
83 \\ add %[ret], %[ret], #:lo12:_DYNAMIC85 \\ add %[ret], %[ret], #:lo12:_DYNAMIC
84 : [ret] "=r" (-> [*]const elf.Dyn),86 : [ret] "=r" (-> [*]const elf.Dyn),
85 ),87 ),
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 }),
86 // The CSKY ABI requires the gb register to point to the GOT. Additionally, the first97 // The CSKY ABI requires the gb register to point to the GOT. Additionally, the first
87 // entry in the GOT is defined to hold the address of _DYNAMIC.98 // entry in the GOT is defined to hold the address of _DYNAMIC.
88 .csky => asm volatile (99 .csky => asm volatile (