diff mbox

libgcc patch committed: Align stack in __stack_split_initialize

Message ID CAOyqgcWfO9WjwcOyX854by56NiJ7pGaRbDhuU71VzVo7fp9x6g@mail.gmail.com
State New
Headers show

Commit Message

Ian Lance Taylor Feb. 10, 2016, 3:14 p.m. UTC
PR 68562 points out that the x86 stack is misaligned when
__stack_split_initialize calls __generic_morestack_set_initial_sp,
causing crashes with the trunk glibc.  This patch fixes the problem by
aligning the stack.  Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu.  Committed to mainline and gcc 5 branch.

Ian

2016-02-10  Ian Lance Taylor  <iant@google.com>

PR go/68562
* config/i386/morestack.S (__stack_split_initialize): Align
stack.
diff mbox

Patch

Index: config/i386/morestack.S
===================================================================
--- config/i386/morestack.S	(revision 233268)
+++ config/i386/morestack.S	(working copy)
@@ -732,6 +732,7 @@  __stack_split_initialize:
 
 	leal	-16000(%esp),%eax	# We should have at least 16K.
 	movl	%eax,%gs:0x30
+	subl	$4,%esp			# Align stack.
 	pushl	$16000
 	pushl	%esp
 #ifdef __PIC__
@@ -739,13 +740,14 @@  __stack_split_initialize:
 #else
 	call	__generic_morestack_set_initial_sp
 #endif
-	addl	$8,%esp
+	addl	$12,%esp
 	ret
 
 #else /* defined(__x86_64__) */
 
 	leaq	-16000(%rsp),%rax	# We should have at least 16K.
 	X86_64_SAVE_NEW_STACK_BOUNDARY (ax)
+	subq	$8,%rsp			# Align stack.
 	movq	%rsp,%rdi
 	movq	$16000,%rsi
 #ifdef __PIC__
@@ -753,6 +755,7 @@  __stack_split_initialize:
 #else
 	call	__generic_morestack_set_initial_sp
 #endif
+	addq	$8,%rsp
 	ret
 
 #endif /* defined(__x86_64__) */