[glibc] alpha: Fix stack alignment in makecontext

Adhemerval Zanella via Glibc-cvs <[email protected]> Mon, 3 Aug 2026 19:14:58 +0000 (GMT)
Newsgroups gmane.comp.lib.glibc.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=4a07bb292f921c10e71fbf48c4a7f44391feb06c

commit 4a07bb292f921c10e71fbf48c4a7f44391feb06c
Author: Magnus Lindholm <[email protected]>
Date:   Mon Aug 3 17:51:59 2026 +0200

    alpha: Fix stack alignment in makecontext
    
    The Alpha ABI requires the stack pointer to be 16-byte aligned.
    However, __makecontext did not realign it after reserving space for
    arguments. Depending on uc_stack.ss_size, this could leave the stack
    only 8-byte aligned.
    
    Round the new stack pointer down to a 16-byte boundary after reserving
    the argument area.
    
    This fixes stdlib/tst-makecontext2.
    
    Signed-off-by: Magnus Lindholm <[email protected]>
    Reviewed-by: Adhemerval Zanella  <[email protected]>

Diff:
---
 sysdeps/unix/sysv/linux/alpha/makecontext.S | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sysdeps/unix/sysv/linux/alpha/makecontext.S b/sysdeps/unix/sysv/linux/alpha/makecontext.S
index b0479315d5..1de0dd2653 100644
--- a/sysdeps/unix/sysv/linux/alpha/makecontext.S
+++ b/sysdeps/unix/sysv/linux/alpha/makecontext.S
@@ -38,6 +38,9 @@ ENTRY(__makecontext)
 	s8addq	$1, 0, $2
 	subq	$8, $2, $8
 
+	/* The Alpha ABI requires a 16-byte-aligned stack pointer.  */
+	bic	$8, 15, $8
+
 	/* Copy all parameters.  Switch statement header here.  */
 	ldah	$3, $jumptable($29)	!gprelhigh
 	cmple	$18, 6, $1