Subject: Re: amd64 alignment problem - gcc's fault or libpthread's?
To: Frank van der Linden <fvdl@NetBSD.org>
From: Matthias Drochner <M.Drochner@fz-juelich.de>
List: tech-toolchain
Date: 02/27/2004 17:49:04
This is a multipart MIME message.

--==_Exmh_107508330280670
Content-Type: text/plain; charset=us-ascii


fvdl@NetBSD.org said:
> Yes, the ABI requires a 16-byte stack alignment.

So it seems I have to retract my gcc PR...

> The stack setup in libpthread is.. well. I don't like it.

I'm not sure I understand all the details, but the appended patch
helps for me.

> The movaps instruction is used to save the float arguments pased
> to the varargs function (passed in %rax).

Yes, the way this is done -- computed goto or so - is
interesting too...

best regards
Matthias



--==_Exmh_107508330280670
Content-Type: text/plain ; name="mc.txt"; charset=us-ascii
Content-Description: mc.txt
Content-Disposition: attachment; filename="mc.txt"

Index: arch/x86_64/gen/makecontext.c
===================================================================
RCS file: /cvsroot/src/lib/libc/arch/x86_64/gen/makecontext.c,v
retrieving revision 1.1
diff -u -r1.1 makecontext.c
--- arch/x86_64/gen/makecontext.c	30 Jan 2003 02:07:31 -0000	1.1
+++ arch/x86_64/gen/makecontext.c	27 Feb 2004 16:45:16 -0000
@@ -69,7 +69,7 @@
 	    ((uintptr_t)ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size);
 
 	/* LINTED uintptr_t is safe */
-	sp  = (uintptr_t *)(((uintptr_t)sp & ~15) - 8);
+	sp  = (uintptr_t *)(((uintptr_t)sp & ~15));
 	sp--;
 	if (stackargs > 0)
 		sp -= stackargs;

--==_Exmh_107508330280670--