zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit bc054a713e3316843dcf3089c6a4b09e52c19b02 (tree)
parent 2dabb7ec778dcf7eb59162ced4d3ceacecba187a
Author: Alex Rønne Petersen <alex@alexrp.com>
Date:   Wed, 24 Jul 2024 09:24:33 +0200

std.os.linux.start_pie: Add csky support.

Diffstat:
Mlib/std/os/linux/start_pie.zig | 9+++++++++
1 file changed, 9 insertions(+), 0 deletions(-)

diff --git a/lib/std/os/linux/start_pie.zig b/lib/std/os/linux/start_pie.zig @@ -7,6 +7,7 @@ const R_AMD64_RELATIVE = 8; const R_386_RELATIVE = 8; const R_ARM_RELATIVE = 23; const R_AARCH64_RELATIVE = 1027; +const R_CSKY_RELATIVE = 9; const R_LARCH_RELATIVE = 3; const R_68K_RELATIVE = 22; const R_RISCV_RELATIVE = 3; @@ -18,6 +19,7 @@ const R_RELATIVE = switch (builtin.cpu.arch) { .x86_64 => R_AMD64_RELATIVE, .arm, .armeb, .thumb, .thumbeb => R_ARM_RELATIVE, .aarch64, .aarch64_be => R_AARCH64_RELATIVE, + .csky => R_CSKY_RELATIVE, .loongarch32, .loongarch64 => R_LARCH_RELATIVE, .m68k => R_68K_RELATIVE, .riscv64 => R_RISCV_RELATIVE, @@ -63,6 +65,13 @@ fn getDynamicSymbol() [*]elf.Dyn { \\ add %[ret], %[ret], #:lo12:_DYNAMIC : [ret] "=r" (-> [*]elf.Dyn), ), + // The CSKY ABI requires the gb register to point to the GOT. Additionally, the first + // entry in the GOT is defined to hold the address of _DYNAMIC. + .csky => asm volatile ( + \\ mov %[ret], gb + \\ ldw %[ret], %[ret] + : [ret] "=r" (-> [*]elf.Dyn), + ), .loongarch32, .loongarch64 => asm volatile ( \\ .weak _DYNAMIC \\ .hidden _DYNAMIC