From 7c98a65ae4fcebf9ebc918fe3e7af9d062805d36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Wed, 24 Jul 2024 22:18:29 +0200 Subject: [PATCH 1/3] start: Add POSIX hexagon support. --- lib/std/start.zig | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/std/start.zig b/lib/std/start.zig index 326857d9c0..d97381ef0d 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -307,6 +307,15 @@ fn _start() callconv(.Naked) noreturn { \\ and sp, #-16 \\ b %[posixCallMainAndExit] , + .hexagon => + // r29 = SP, r30 = FP + \\ r30 = #0 + \\ r0 = r29 + \\ r29 = and(r29, #-16) + \\ memw(r29 + #-8) = r29 + \\ r29 = add(r29, #-8) + \\ call %[posixCallMainAndExit] + , .loongarch32, .loongarch64 => \\ move $fp, $zero \\ move $a0, $sp From 389ce984b5fc601b1b4e28e4ba47d051750afd83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Wed, 24 Jul 2024 22:37:26 +0200 Subject: [PATCH 2/3] start: Add POSIX arc support. --- lib/std/start.zig | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/std/start.zig b/lib/std/start.zig index d97381ef0d..74e177ce0b 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -300,6 +300,15 @@ fn _start() callconv(.Naked) noreturn { \\ and sp, x0, #-16 \\ b %[posixCallMainAndExit] , + .arc => + // The `arc` tag currently means ARCv2, which has an unusually low stack alignment + // requirement. ARCv3 increases it from 4 to 16, but we don't support ARCv3 yet. + \\ mov fp, 0 + \\ mov blink, 0 + \\ mov r0, sp + \\ and sp, sp, -4 + \\ b %[posixCallMainAndExit] + , .arm, .armeb, .thumb, .thumbeb => \\ mov fp, #0 \\ mov lr, #0 From 108c682df0ec6908695e55d3c3f50fe158a5d502 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Wed, 24 Jul 2024 23:25:19 +0200 Subject: [PATCH 3/3] start: Add POSIX csky support. --- lib/std/start.zig | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/std/start.zig b/lib/std/start.zig index 74e177ce0b..76789bc5fc 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -316,6 +316,24 @@ fn _start() callconv(.Naked) noreturn { \\ and sp, #-16 \\ b %[posixCallMainAndExit] , + // zig fmt: off + .csky => + if (builtin.position_independent_code) + // The CSKY ABI assumes that `gb` is set to the address of the GOT in order for + // position-independent code to work. We depend on this in `std.os.linux.start_pie` + // to locate `_DYNAMIC` as well. + \\ grs t0, 1f + \\ 1: + \\ lrw gb, 1b@GOTPC + \\ addu gb, t0 + else "" + ++ + \\ movi lr, 0 + \\ mov a0, sp + \\ andi sp, sp, -8 + \\ jmpi %[posixCallMainAndExit] + , + // zig fmt: on .hexagon => // r29 = SP, r30 = FP \\ r30 = #0