From ee1983a985c013905f23a95adbac77cbd6e578f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Sat, 8 Aug 2026 19:13:18 +0200 Subject: [PATCH] std.pie: fix sparc assembly to actually load &_DYNAMIC It was loading &_GLOBAL_OFFSET_TABLE_[0] rather than &_DYNAMIC. I suspect that I committed this before actually finishing writing it. --- lib/std/pie.zig | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/std/pie.zig b/lib/std/pie.zig index a1bcc5c3dcbb3e9ab672a9236a1fb301da038ab9..84f8d35e8c082063fba23846978bb6f6c6d12eaf 100644 --- a/lib/std/pie.zig +++ b/lib/std/pie.zig @@ -271,17 +271,17 @@ inline fn getDynamicSymbol() [*]const elf.Dyn { : [ret] "=r" (-> [*]const elf.Dyn), : : .{ .r0 = true }), - // The compiler does not necessarily have any obligation to load the `l7` register (pointing - // to the GOT), so do it ourselves just in case. .sparc, .sparc64 => asm volatile ( - \\ sethi %%hi(_GLOBAL_OFFSET_TABLE_ - 4), %%l7 + \\ .weak _DYNAMIC + \\ .hidden _DYNAMIC + \\ sethi %%pc22(_DYNAMIC - 4), %[ret] \\ call 1f - \\ add %%l7, %%lo(_GLOBAL_OFFSET_TABLE_ + 4), %%l7 + \\ add %[ret], %%pc10(_DYNAMIC + 4), %[ret] \\1: - \\ add %%l7, %%o7, %[ret] + \\ add %[ret], %%o7, %[ret] : [ret] "=r" (-> [*]const elf.Dyn), : - : .{ .l7 = true }), + : .{ .o7 = true }), .xtensa, .xtensaeb => asm volatile ( \\ .weak _DYNAMIC \\ .hidden _DYNAMIC -- 2.54.0