diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-07-22 18:25:24 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-22 18:25:24 -0700 |
| commit | 8a8a7ba35bd1d580f60a44e1a2803457595df30e (patch) | |
| tree | f78967075d7c438656f1cda7596dc1ab1e566df5 | |
| parent | 05a8c4796f633bfebad7ec403560ce442cae11ba (diff) | |
| parent | 8ffc41f74705246e61f3c02c253d40b1464ea2bf (diff) | |
| download | zig-8a8a7ba35bd1d580f60a44e1a2803457595df30e.tar.gz zig-8a8a7ba35bd1d580f60a44e1a2803457595df30e.zip | |
Merge pull request #20733 from alexrp/start-porting
`start`: Add startup code for loongarch64, m68k, and s390x
| -rw-r--r-- | lib/std/start.zig | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/lib/std/start.zig b/lib/std/start.zig index e0f99b4762..caca4c7be3 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 @@ -307,6 +313,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 @@ -340,8 +354,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 @@ -349,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 @@ -359,7 +382,8 @@ fn _start() callconv(.Naked) noreturn { else => @compileError("unsupported arch"), } : - : [posixCallMainAndExit] "X" (&posixCallMainAndExit), + : [_start] "X" (_start), + [posixCallMainAndExit] "X" (&posixCallMainAndExit), ); } |
