Commit e646c47f67

Alex Rønne Petersen <alex@alexrp.com>
2025-10-18 15:00:55
std.pie: add or1k support
1 parent 2d5cdfc
Changed files (1)
lib
lib/std/pie.zig
@@ -13,6 +13,7 @@ const R_HEXAGON_RELATIVE = 35;
 const R_LARCH_RELATIVE = 3;
 const R_68K_RELATIVE = 22;
 const R_MIPS_RELATIVE = 128;
+const R_OR1K_RELATIVE = 21;
 const R_PPC_RELATIVE = 22;
 const R_RISCV_RELATIVE = 3;
 const R_390_RELATIVE = 12;
@@ -29,6 +30,7 @@ const R_RELATIVE = switch (builtin.cpu.arch) {
     .loongarch32, .loongarch64 => R_LARCH_RELATIVE,
     .m68k => R_68K_RELATIVE,
     .mips, .mipsel, .mips64, .mips64el => R_MIPS_RELATIVE,
+    .or1k => R_OR1K_RELATIVE,
     .powerpc, .powerpcle, .powerpc64, .powerpc64le => R_PPC_RELATIVE,
     .riscv32, .riscv32be, .riscv64, .riscv64be => R_RISCV_RELATIVE,
     .s390x => R_390_RELATIVE,
@@ -153,6 +155,17 @@ inline fn getDynamicSymbol() [*]const elf.Dyn {
                     :
                     : .{ .lr = true }),
             },
+            .or1k => asm volatile (
+                \\ .weak _DYNAMIC
+                \\ .hidden _DYNAMIC
+                \\ l.jal 1f
+                \\ .word _DYNAMIC - .
+                \\1:
+                \\ l.lwz %[ret], 0(r9)
+                \\ l.add %[ret], %[ret], r9
+                : [ret] "=r" (-> [*]const elf.Dyn),
+                :
+                : .{ .r9 = true }),
             .powerpc, .powerpcle => asm volatile (
                 \\ .weak _DYNAMIC
                 \\ .hidden _DYNAMIC