authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-08-04 10:36:34+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-08-07 01:09:06-07:00
log8cbf091a9a5dd1996453dfce08e7e3a109b6c30f
tree1713b23089660fd72edc95c765affe522032cd06
parentb071b10ce83609199577ff077fb117ed62c98fe7

std.os.linux.start_pie: Add sparc/sparc64 support.


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

lib/std/os/linux/start_pie.zig+11
......@@ -32,6 +32,7 @@ const R_RELATIVE = switch (builtin.cpu.arch) {
3232 .powerpc, .powerpcle, .powerpc64, .powerpc64le => R_PPC_RELATIVE,
3333 .riscv32, .riscv64 => R_RISCV_RELATIVE,
3434 .s390x => R_390_RELATIVE,
35 .sparc, .sparc64 => R_SPARC_RELATIVE,
3536 else => @compileError("Missing R_RELATIVE definition for this target"),
3637};
3738
......@@ -182,6 +183,16 @@ inline fn getDynamicSymbol() [*]elf.Dyn {
182183 \\ 2:
183184 : [ret] "=r" (-> [*]elf.Dyn),
184185 ),
186 // The compiler does not necessarily have any obligation to load the `l7` register (pointing
187 // to the GOT), so do it ourselves just in case.
188 .sparc, .sparc64 => asm volatile (
189 \\ sethi %%hi(_GLOBAL_OFFSET_TABLE_ - 4), %%l7
190 \\ call 1f
191 \\ add %%l7, %%lo(_GLOBAL_OFFSET_TABLE_ + 4), %%l7
192 \\ 1:
193 \\ add %%l7, %%o7, %[ret]
194 : [ret] "=r" (-> [*]elf.Dyn),
195 ),
185196 else => {
186197 @compileError("PIE startup is not yet supported for this target!");
187198 },