From c62aadef3740313887ebed80277d8858fdb296ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Mon, 22 Jul 2024 15:26:32 +0200 Subject: [PATCH] start: Avoid needlessly aligning the stack pointer on some architectures. For these, the relevant ABIs already guarantee that it is aligned appropriately when the kernel transfers control to _start(). Rather than potentially hiding ABI bugs, let's actually assume that the OS works properly unless/until we have evidence to the contrary. This effectively reverts 81232f7c91ca8e0969e9d3f92cc11caeedc017d0. --- lib/std/start.zig | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/lib/std/start.zig b/lib/std/start.zig index e0f99b476248..d8486de1100f 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -276,13 +276,11 @@ fn _start() callconv(.Naked) noreturn { .x86_64 => \\ xorl %%ebp, %%ebp \\ movq %%rsp, %%rdi - \\ andq $-16, %%rsp \\ callq %[posixCallMainAndExit:P] , .x86 => \\ xorl %%ebp, %%ebp \\ movl %%esp, %%eax - \\ andl $-16, %%esp \\ subl $12, %%esp \\ pushl %%eax \\ calll %[posixCallMainAndExit:P] @@ -307,26 +305,10 @@ fn _start() callconv(.Naked) noreturn { \\ andi sp, sp, -16 \\ tail %[posixCallMainAndExit]@plt , - .mips, .mipsel => + .mips, .mipsel, .mips64, .mips64el => // The lr is already zeroed on entry, as specified by the ABI. \\ addiu $fp, $zero, 0 \\ move $a0, $sp - \\ .set push - \\ .set noat - \\ addiu $1, $zero, -16 - \\ and $sp, $sp, $1 - \\ .set pop - \\ j %[posixCallMainAndExit] - , - .mips64, .mips64el => - // The lr is already zeroed on entry, as specified by the ABI. - \\ addiu $fp, $zero, 0 - \\ move $a0, $sp - \\ .set push - \\ .set noat - \\ daddiu $1, $zero, -16 - \\ and $sp, $sp, $1 - \\ .set pop \\ j %[posixCallMainAndExit] , .powerpc, .powerpcle => @@ -343,7 +325,6 @@ fn _start() callconv(.Naked) noreturn { \\ addis 2, 12, .TOC. - _start@ha \\ addi 2, 2, .TOC. - _start@l \\ mr 3, 1 - \\ clrrdi 1, 1, 4 \\ li 0, 0 \\ stdu 0, -32(1) \\ mtlr 0