Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 2 Nov 2011 18:06:23 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r227023 - head/lib/libc/amd64/gen
Message-ID:  <201111021806.pA2I6Na9032235@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Wed Nov  2 18:06:22 2011
New Revision: 227023
URL: http://svn.freebsd.org/changeset/base/227023

Log:
  Make sure that stack is 16-byte aligned before calling a function,
  as it is required by amd64 ABI. Add a comment for the places were
  the stack is accidentally properly aligned already.
  
  PR:	amd64/162214
  Submitted by:	yamayan <yamayan kbh biglobe ne jp>
  MFC after:	1 week

Modified:
  head/lib/libc/amd64/gen/setjmp.S
  head/lib/libc/amd64/gen/sigsetjmp.S

Modified: head/lib/libc/amd64/gen/setjmp.S
==============================================================================
--- head/lib/libc/amd64/gen/setjmp.S	Wed Nov  2 17:40:21 2011	(r227022)
+++ head/lib/libc/amd64/gen/setjmp.S	Wed Nov  2 18:06:22 2011	(r227023)
@@ -54,6 +54,7 @@ ENTRY(setjmp)
 	movq	$1,%rdi			/* SIG_BLOCK       */
 	movq	$0,%rsi			/* (sigset_t*)set  */
 	leaq	72(%rcx),%rdx		/* 9,10; (sigset_t*)oset */
+	/* stack is 16-byte aligned */
 	call	PIC_PLT(CNAME(_sigprocmask))
 	popq	%rdi
 	movq	%rdi,%rcx
@@ -81,7 +82,9 @@ ENTRY(__longjmp)
 	movq	$3,%rdi			/* SIG_SETMASK     */
 	leaq	72(%rdx),%rsi		/* (sigset_t*)set  */
 	movq	$0,%rdx			/* (sigset_t*)oset */
+	subq	$0x8,%rsp		/* make the stack 16-byte aligned */
 	call	PIC_PLT(CNAME(_sigprocmask))
+	addq	$0x8,%rsp
 	popq	%rsi
 	popq	%rdi			/* jmpbuf */
 	movq	%rdi,%rdx

Modified: head/lib/libc/amd64/gen/sigsetjmp.S
==============================================================================
--- head/lib/libc/amd64/gen/sigsetjmp.S	Wed Nov  2 17:40:21 2011	(r227022)
+++ head/lib/libc/amd64/gen/sigsetjmp.S	Wed Nov  2 18:06:22 2011	(r227023)
@@ -62,6 +62,7 @@ ENTRY(sigsetjmp)
 	movq	$1,%rdi			/* SIG_BLOCK       */
 	movq	$0,%rsi			/* (sigset_t*)set  */
 	leaq	72(%rcx),%rdx		/* 9,10 (sigset_t*)oset */
+	/* stack is 16-byte aligned */
 	call	PIC_PLT(CNAME(_sigprocmask))
 	popq	%rdi
 2:	movq	%rdi,%rcx
@@ -90,7 +91,9 @@ ENTRY(__siglongjmp)
 	movq	$3,%rdi			/* SIG_SETMASK     */
 	leaq	72(%rdx),%rsi		/* (sigset_t*)set  */
 	movq	$0,%rdx			/* (sigset_t*)oset */
+	subq	$0x8,%rsp		/* make the stack 16-byte aligned */
 	call	PIC_PLT(CNAME(_sigprocmask))
+	addq	$0x8,%rsp
 	popq	%rsi
 	popq	%rdi			/* jmpbuf */
 2:	movq	%rdi,%rdx



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201111021806.pA2I6Na9032235>