From 142209444a52c5c44b19a984f25376173027da7e Mon Sep 17 00:00:00 2001 From: Alex Rønne Petersen Date: Mon, 22 Jul 2024 11:55:30 +0200 Subject: start: Pass _start() into its own inline asm as an operand. --- lib/std/start.zig | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib/std') diff --git a/lib/std/start.zig b/lib/std/start.zig index e0f99b4762..d927f74517 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -340,8 +340,8 @@ fn _start() callconv(.Naked) noreturn { , .powerpc64, .powerpc64le => // Setup the initial stack frame and clear the back chain pointer. - \\ addis 2, 12, .TOC. - _start@ha - \\ addi 2, 2, .TOC. - _start@l + \\ addis 2, 12, .TOC. - %[_start]@ha + \\ addi 2, 2, .TOC. - %[_start]@l \\ mr 3, 1 \\ clrrdi 1, 1, 4 \\ li 0, 0 @@ -359,7 +359,8 @@ fn _start() callconv(.Naked) noreturn { else => @compileError("unsupported arch"), } : - : [posixCallMainAndExit] "X" (&posixCallMainAndExit), + : [_start] "X" (_start), + [posixCallMainAndExit] "X" (&posixCallMainAndExit), ); } -- cgit v1.2.3 From 1fa5ca24feb7b931fdc5f4ff826048a87922ad10 Mon Sep 17 00:00:00 2001 From: Alex Rønne Petersen Date: Mon, 22 Jul 2024 12:55:08 +0200 Subject: start: Add POSIX m68k startup code. --- lib/std/start.zig | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/std') diff --git a/lib/std/start.zig b/lib/std/start.zig index d927f74517..081e9d44f0 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -307,6 +307,14 @@ fn _start() callconv(.Naked) noreturn { \\ andi sp, sp, -16 \\ tail %[posixCallMainAndExit]@plt , + .m68k => + // Note that the - 8 is needed because pc in the jsr instruction points into the middle + // of the jsr instruction. (The lea is 6 bytes, the jsr is 4 bytes.) + \\ suba.l %%fp, %%fp + \\ move.l %%sp, -(%%sp) + \\ lea %[posixCallMainAndExit] - . - 8, %%a0 + \\ jsr (%%pc, %%a0) + , .mips, .mipsel => // The lr is already zeroed on entry, as specified by the ABI. \\ addiu $fp, $zero, 0 -- cgit v1.2.3 From c53673276be9de837add3a3c4e948b10cdd7e1a6 Mon Sep 17 00:00:00 2001 From: Alex Rønne Petersen Date: Mon, 22 Jul 2024 12:58:07 +0200 Subject: start: Add POSIX loongarch64 startup code. --- lib/std/start.zig | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/std') diff --git a/lib/std/start.zig b/lib/std/start.zig index 081e9d44f0..ff524d5d64 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -300,6 +300,12 @@ fn _start() callconv(.Naked) noreturn { \\ and sp, #-16 \\ b %[posixCallMainAndExit] , + .loongarch64 => + \\ move $fp, $zero + \\ move $a0, $sp + \\ bstrins.d $sp, $zero, 3, 0 + \\ b %[posixCallMainAndExit] + , .riscv64 => \\ li s0, 0 \\ li ra, 0 -- cgit v1.2.3 From 8ffc41f74705246e61f3c02c253d40b1464ea2bf Mon Sep 17 00:00:00 2001 From: Alex Rønne Petersen Date: Mon, 22 Jul 2024 13:22:42 +0200 Subject: start: Add POSIX s390x startup code. --- lib/std/start.zig | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib/std') diff --git a/lib/std/start.zig b/lib/std/start.zig index ff524d5d64..caca4c7be3 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -363,6 +363,15 @@ fn _start() callconv(.Naked) noreturn { \\ mtlr 0 \\ b %[posixCallMainAndExit] , + .s390x => + // Set up the stack frame (register save area and cleared back-chain slot). + // Note: Stack pointer is guaranteed by ABI to be 8-byte aligned as required. + \\ lgr %r2, %r15 + \\ aghi %r15, -160 + \\ lghi %r0, 0 + \\ stg %r0, 0(%r15) + \\ jg %[posixCallMainAndExit] + , .sparc64 => // argc is stored after a register window (16 registers) plus stack bias \\ mov %%g0, %%i6 -- cgit v1.2.3