From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_BLOCKED, URIBL_DBL_BLOCKED_OPENDNS autolearn=ham autolearn_force=no version=3.4.6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1693065315; bh=uOQFWUNdySX8EeZpY0WLS5LqmI/KGm+C1Y7SHtvTH3E=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=c0VkS6sWy6DJUQrn0fUHjaRasfarNGujlOjfUMAa0hDV1tG4FWC2Hw1GqttO1fhq7 ks3fYfiZyYWp+SCEgH+EQcZA4bj0dGmK9IEDDFahFTGI+NdI/PQr+7Unx4tqIJoxI+ BcKPH0IWKe1o+M5U+m1zdsEkYJM9vg4NQ61mEOoyga5xPTVJqb49LMDaqCl5XlXfIS qzHQuEOvpADvOZmOuUKQrx2p+I5S/bn1Kw9oY6ythCPF9G9WKKDHM9Dtt4fh9Gx+2E 9rGSeUr97JJWPqEM5VGShj4v6Oex/Si4jQA+JC5Vg9hkj6+cs7arOaWOvnjt8MbtFj VAdXcqkV6InfA== Received: from biznet-home.integral.gnuweeb.org (unknown [182.253.126.208]) by gnuweeb.org (Postfix) with ESMTPSA id E408624B175; Sat, 26 Aug 2023 22:55:11 +0700 (WIB) Date: Sat, 26 Aug 2023 22:55:07 +0700 From: Ammar Faizi To: Zhangjin Wu Cc: Willy Tarreau , Thomas =?iso-8859-1?Q?Wei=DFschuh?= , Ammar Faizi , Nicholas Rosenberg , GNU/Weeb Mailing List , Michael William Jonathan , Linux Kernel Mailing List Subject: Re: [PATCH v1 1/1] tools/nolibc: i386: Fix a stack misalign bug on _start Message-ID: References: <20230826141632.1488740-2-ammarfaizi2@gnuweeb.org> <20230826150704.7588-1-falcon@tinylab.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230826150704.7588-1-falcon@tinylab.org> X-Bpl: hUx9VaHkTWcLO7S8CQCslj6OzqBx2hfLChRz45nPESx5VSB/xuJQVOKOB1zSXE3yc9ntP27bV1M1 List-Id: On Sat, Aug 26, 2023 at 11:07:04PM +0800, Zhangjin Wu wrote: > > @@ -167,7 +167,8 @@ void __attribute__((weak, noreturn, optimize("Os", "omit-frame-pointer"))) __no_ > > __asm__ volatile ( > > "xor %ebp, %ebp\n" /* zero the stack frame */ > > "mov %esp, %eax\n" /* save stack pointer to %eax, as arg1 of _start_c */ > > - "and $-16, %esp\n" /* last pushed argument must be 16-byte aligned */ > > + "and $-16, %esp\n" /* align stack to 16 bytes */ > > + "sub $12, %esp\n" /* last pushed argument must be 16-byte aligned */ > > Ammar, the new call of _start_c() only requires a single push, it pushes > the argument and minus %esp by 4, so, the alignment of %esp requires to > minus 12 to reserve 16-byte alignment, is this description right? Yes, that's correct. > If so, What about further? > > "and $-16, %esp\n" /* align stack to 16 bytes */ > "sub ($16 - $4), %esp" /* the 'push %eax' breaks stack alignment, fix up it */ The sub part should have been: "sub $(16 - 4), %esp\n" It's fine to me writing it that way too. -- Ammar Faizi