authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-07-24 09:24:33+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-07-24 20:12:38+02:00
logbc054a713e3316843dcf3089c6a4b09e52c19b02
tree8a3d72f08485c9734fe05ab1e3aaf3050db7ad3e
parent2dabb7ec778dcf7eb59162ced4d3ceacecba187a
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

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


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

lib/std/os/linux/start_pie.zig+9
......@@ -7,6 +7,7 @@ const R_AMD64_RELATIVE = 8;
77const R_386_RELATIVE = 8;
88const R_ARM_RELATIVE = 23;
99const R_AARCH64_RELATIVE = 1027;
10const R_CSKY_RELATIVE = 9;
1011const R_LARCH_RELATIVE = 3;
1112const R_68K_RELATIVE = 22;
1213const R_RISCV_RELATIVE = 3;
......@@ -18,6 +19,7 @@ const R_RELATIVE = switch (builtin.cpu.arch) {
1819 .x86_64 => R_AMD64_RELATIVE,
1920 .arm, .armeb, .thumb, .thumbeb => R_ARM_RELATIVE,
2021 .aarch64, .aarch64_be => R_AARCH64_RELATIVE,
22 .csky => R_CSKY_RELATIVE,
2123 .loongarch32, .loongarch64 => R_LARCH_RELATIVE,
2224 .m68k => R_68K_RELATIVE,
2325 .riscv64 => R_RISCV_RELATIVE,
......@@ -63,6 +65,13 @@ fn getDynamicSymbol() [*]elf.Dyn {
6365 \\ add %[ret], %[ret], #:lo12:_DYNAMIC
6466 : [ret] "=r" (-> [*]elf.Dyn),
6567 ),
68 // The CSKY ABI requires the gb register to point to the GOT. Additionally, the first
69 // entry in the GOT is defined to hold the address of _DYNAMIC.
70 .csky => asm volatile (
71 \\ mov %[ret], gb
72 \\ ldw %[ret], %[ret]
73 : [ret] "=r" (-> [*]elf.Dyn),
74 ),
6675 .loongarch32, .loongarch64 => asm volatile (
6776 \\ .weak _DYNAMIC
6877 \\ .hidden _DYNAMIC