[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[commits] r8734 - in /fsf/trunk/libc: ./ debug/ sysdeps/i386/ sysdeps/ia64/ sysdeps/unix/sysv/linux/i386/ sysdeps/unix/sysv/linux/x86_...



Author: eglibc
Date: Fri Jul 31 00:04:15 2009
New Revision: 8734

Log:
Import glibc-mainline for 2009-07-31

Added:
    fsf/trunk/libc/debug/tst-longjmp_chk2.c
    fsf/trunk/libc/sysdeps/unix/sysv/linux/i386/____longjmp_chk.S
    fsf/trunk/libc/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S
Modified:
    fsf/trunk/libc/ChangeLog
    fsf/trunk/libc/debug/Makefile
    fsf/trunk/libc/sysdeps/i386/____longjmp_chk.S
    fsf/trunk/libc/sysdeps/i386/__longjmp.S
    fsf/trunk/libc/sysdeps/ia64/backtrace.c
    fsf/trunk/libc/sysdeps/x86_64/____longjmp_chk.S
    fsf/trunk/libc/sysdeps/x86_64/__longjmp.S

Modified: fsf/trunk/libc/ChangeLog
==============================================================================
--- fsf/trunk/libc/ChangeLog (original)
+++ fsf/trunk/libc/ChangeLog Fri Jul 31 00:04:15 2009
@@ -1,3 +1,27 @@
+2009-07-30  Ulrich Drepper  <drepper@xxxxxxxxxx>
+
+	* sysdeps/unix/sysv/linux/i386/____longjmp_chk.S: New file.
+	* sysdeps/i386/____longjmp_chk.S: Remove all code.  This is now a file
+	which always causes a compile error.
+
+	* sysdeps/i386/__longjmp.S: Remove bound-checking pointer support.
+
+	* sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S: New file.  Content
+	comes from...
+	* sysdeps/x86_64/____longjmp_chk.S: ...here.  This is now a file
+	which always causes a compile error.
+
+	* debug/Makefile (tests): Add tst-longjmp_chk2.
+	* debug/tst-longjmp_chk2.c: New file.
+
+	* sysdeps/x86_64/__longjmp.S: Remove CHECK_RSP handling.  Fix CFI.
+	Remove incorrect use of BP_SYM.
+	* sysdeps/x86_64/____longjmp_chk.S: Rewrite.  Complete implementation
+	here now since it is more complex than just a simple check.
+
+	* sysdeps/ia64/backtrace.c (backtrace_helper): Stop backtrace when
+	we make no more progress.
+
 2009-07-29  Ulrich Drepper  <drepper@xxxxxxxxxx>
 
 	* math/s_fma.c: Don't define alias if __fma is a macro.

Modified: fsf/trunk/libc/debug/Makefile
==============================================================================
--- fsf/trunk/libc/debug/Makefile (original)
+++ fsf/trunk/libc/debug/Makefile Fri Jul 31 00:04:15 2009
@@ -82,6 +82,8 @@
 CFLAGS-recvfrom_chk.c = -fexceptions -fasynchronous-unwind-tables
 CFLAGS-tst-longjmp_chk.c = -fexceptions -fasynchronous-unwind-tables \
 			   -D_FORTIFY_SOURCE=1
+CFLAGS-tst-longjmp_chk2.c = -fexceptions -fasynchronous-unwind-tables \
+			    -D_FORTIFY_SOURCE=1
 
 # We know these tests have problems with format strings, this is what
 # we are testing.  Disable that warning.
@@ -118,7 +120,8 @@
 
 tests = backtrace-tst tst-longjmp_chk tst-chk1 tst-chk2 tst-chk3 \
 	tst-lfschk1 tst-lfschk2 tst-lfschk3 test-strcpy_chk test-stpcpy_chk \
-	tst-chk4 tst-chk5 tst-chk6 tst-lfschk4 tst-lfschk5 tst-lfschk6
+	tst-chk4 tst-chk5 tst-chk6 tst-lfschk4 tst-lfschk5 tst-lfschk6 \
+	tst-longjmp_chk2
 
 extra-libs = libSegFault libpcprofile
 extra-libs-others = $(extra-libs)

Added: fsf/trunk/libc/debug/tst-longjmp_chk2.c
==============================================================================
--- fsf/trunk/libc/debug/tst-longjmp_chk2.c (added)
+++ fsf/trunk/libc/debug/tst-longjmp_chk2.c Fri Jul 31 00:04:15 2009
@@ -1,0 +1,114 @@
+/* Test case mostly written by Paolo Bonzini <pbonzini@xxxxxxxxxx>.  */
+#include <assert.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+
+
+static jmp_buf mainloop;
+static sigset_t mainsigset;
+static int pass;
+
+
+static void
+stackoverflow_handler (int sig)
+{
+  stack_t altstack;
+  pass++;
+  sigaltstack (NULL, &altstack);
+  /* Using printf is not really kosher in signal handlers but we know
+     it will work.  */
+  printf ("%*sin signal handler\n", pass, "");
+  if (altstack.ss_flags & SS_ONSTACK)
+    printf ("%*son alternate stack\n", pass, "");
+  siglongjmp (mainloop, pass);
+}
+
+
+static volatile int *
+recurse_1 (int n, volatile int *p)
+{
+  if (n >= 0)
+    *recurse_1 (n + 1, p) += n;
+  return p;
+}
+
+
+static int
+recurse (int n)
+{
+  int sum = 0;
+  return *recurse_1 (n, &sum);
+}
+
+
+static int
+do_test (void)
+{
+  char mystack[SIGSTKSZ];
+  stack_t altstack;
+  struct sigaction action;
+  sigset_t emptyset;
+  /* Before starting the endless recursion, try to be friendly to the user's
+     machine.  On some Linux 2.2.x systems, there is no stack limit for user
+     processes at all.  We don't want to kill such systems.  */
+  struct rlimit rl;
+  rl.rlim_cur = rl.rlim_max = 0x100000; /* 1 MB */
+  setrlimit (RLIMIT_STACK, &rl);
+  /* Install the alternate stack.  */
+  altstack.ss_sp = mystack;
+  altstack.ss_size = sizeof (mystack);
+  altstack.ss_flags = 0; /* no SS_DISABLE */
+  if (sigaltstack (&altstack, NULL) < 0)
+    {
+      puts ("first sigaltstack failed");
+      return 0;
+    }
+  /* Install the SIGSEGV handler.  */
+  sigemptyset (&action.sa_mask);
+  action.sa_handler = &stackoverflow_handler;
+  action.sa_flags = SA_ONSTACK;
+  sigaction (SIGSEGV, &action, (struct sigaction *) NULL);
+  sigaction (SIGBUS, &action, (struct sigaction *) NULL);
+
+  /* Save the current signal mask.  */
+  sigemptyset (&emptyset);
+  sigprocmask (SIG_BLOCK, &emptyset, &mainsigset);
+
+  /* Provoke two stack overflows in a row.  */
+  if (sigsetjmp (mainloop, 1) != 0)
+    {
+      assert (pass != 0);
+      printf ("%*sout of signal handler\n", pass, "");
+    }
+  else
+    assert (pass == 0);
+
+  sigaltstack (NULL, &altstack);
+  if (altstack.ss_flags & SS_ONSTACK)
+    printf ("%*son alternate stack\n", pass, "");
+  else
+    printf ("%*snot on alternate stack\n", pass, "");
+
+  if (pass < 2)
+    {
+      recurse (0);
+      puts ("recurse call returned");
+      return 2;
+    }
+
+  altstack.ss_flags |= SS_DISABLE;
+  if (sigaltstack (&altstack, NULL) == -1)
+    printf ("disabling alternate stack failed\n");
+  else
+    printf ("disabling alternate stack succeeded \n");
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"

Modified: fsf/trunk/libc/sysdeps/i386/____longjmp_chk.S
==============================================================================
--- fsf/trunk/libc/sysdeps/i386/____longjmp_chk.S (original)
+++ fsf/trunk/libc/sysdeps/i386/____longjmp_chk.S Fri Jul 31 00:04:15 2009
@@ -1,45 +1,1 @@
-/* Copyright (C) 2001,2004,2005,2006,2009 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
-
-	.section .rodata.str1.1,"aMS",@progbits,1
-	.type	longjmp_msg,@object
-longjmp_msg:
-	.string "longjmp causes uninitialized stack frame"
-	.size	longjmp_msg, .-longjmp_msg
-
-
-#define __longjmp ____longjmp_chk
-
-#ifdef PIC
-# define CALL_FAIL	movl	%ebx, %ecx;				      \
-			cfi_register(%ebx,%ecx);			      \
-			LOAD_PIC_REG (bx);				      \
-			leal	longjmp_msg@GOTOFF(%ebx), %eax;		      \
-			call	__GI___fortify_fail@PLT
-#else
-# define CALL_FAIL	movl	$longjmp_msg, %eax;			      \
-			call	__fortify_fail
-#endif
-
-#define CHECK_ESP(reg) \
-	cmpl	reg, %esp;						      \
-	jbe	.Lok;							      \
-	CALL_FAIL;							      \
-.Lok:
-
-#include "__longjmp.S"
+#error "OS-specific version needed"

Modified: fsf/trunk/libc/sysdeps/i386/__longjmp.S
==============================================================================
--- fsf/trunk/libc/sysdeps/i386/__longjmp.S (original)
+++ fsf/trunk/libc/sysdeps/i386/__longjmp.S Fri Jul 31 00:04:15 2009
@@ -21,20 +21,11 @@
 #include <sysdep.h>
 #include <jmpbuf-offsets.h>
 #include <asm-syntax.h>
-#include <bp-sym.h>
-#include <bp-asm.h>
-
-#define PARMS	LINKAGE		/* no space for saved regs */
-#define JBUF	PARMS
-#define VAL	JBUF+PTR_SIZE
 
 	.text
-ENTRY (BP_SYM (__longjmp))
-	ENTER
-
+ENTRY (__longjmp)
 #ifdef PTR_DEMANGLE
-	movl JBUF(%esp), %eax	/* User's jmp_buf in %eax.  */
-	CHECK_BOUNDS_BOTH_WIDE (%eax, JBUF(%esp), $JB_SIZE)
+	movl 4(%esp), %eax	/* User's jmp_buf in %eax.  */
 
 	/* Save the return address now.  */
 	movl (JB_PC*4)(%eax), %edx
@@ -62,18 +53,17 @@
 	cfi_restore(%edi)
 	cfi_restore(%ebp)
 
-	movl VAL(%esp), %eax	/* Second argument is return value.  */
+	movl 8(%esp), %eax	/* Second argument is return value.  */
 	movl %ecx, %esp
 #else
-	movl JBUF(%esp), %ecx	/* User's jmp_buf in %ecx.  */
-	CHECK_BOUNDS_BOTH_WIDE (%ecx, JBUF(%esp), $JB_SIZE)
+	movl 4(%esp), %ecx	/* User's jmp_buf in %ecx.  */
 
 # ifdef CHECK_ESP
 	movl (JB_SP*4)(%ecx), %eax
 	CHECK_ESP (%eax)
 # endif
 
-	movl VAL(%esp), %eax	/* Second argument is return value.  */
+	movl 8(%esp), %eax	/* Second argument is return value.  */
 	/* Save the return address now.  */
 	movl (JB_PC*4)(%ecx), %edx
      	/* Restore registers.  */
@@ -85,4 +75,4 @@
 #endif
 	/* Jump to saved PC.  */
      	jmp *%edx
-END (BP_SYM (__longjmp))
+END (__longjmp)

Modified: fsf/trunk/libc/sysdeps/ia64/backtrace.c
==============================================================================
--- fsf/trunk/libc/sysdeps/ia64/backtrace.c (original)
+++ fsf/trunk/libc/sysdeps/ia64/backtrace.c Fri Jul 31 00:04:15 2009
@@ -1,5 +1,5 @@
 /* Return backtrace of current program state.
-   Copyright (C) 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Jakub Jelinek <jakub@xxxxxxxxxx>, 2003.
 
@@ -61,7 +61,13 @@
   /* We are first called with address in the __backtrace function.
      Skip it.  */
   if (arg->cnt != -1)
-    arg->array[arg->cnt] = (void *) unwind_getip (ctx);
+    {
+      arg->array[arg->cnt] = (void *) unwind_getip (ctx);
+
+      /* Check whether we make any progress.  */
+      if (arg->cnt > 0 && arg->array[arg->cnt - 1] == arg->array[arg->cnt])
+	return _URC_END_OF_STACK;
+    }
   if (++arg->cnt == arg->size)
     return _URC_END_OF_STACK;
   return _URC_NO_REASON;

Added: fsf/trunk/libc/sysdeps/unix/sysv/linux/i386/____longjmp_chk.S
==============================================================================
--- fsf/trunk/libc/sysdeps/unix/sysv/linux/i386/____longjmp_chk.S (added)
+++ fsf/trunk/libc/sysdeps/unix/sysv/linux/i386/____longjmp_chk.S Fri Jul 31 00:04:15 2009
@@ -1,0 +1,143 @@
+/* Copyright (C) 2001,2004,2005,2006,2009 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <sysdep.h>
+#include <jmpbuf-offsets.h>
+#include <asm-syntax.h>
+
+
+	.section .rodata.str1.1,"aMS",@progbits,1
+	.type	longjmp_msg,@object
+longjmp_msg:
+	.string "longjmp causes uninitialized stack frame"
+	.size	longjmp_msg, .-longjmp_msg
+
+
+#ifdef PIC
+# define CALL_FAIL	movl	%ebx, %ecx;				      \
+			cfi_register(%ebx,%ecx);			      \
+			LOAD_PIC_REG (bx);				      \
+			leal	longjmp_msg@GOTOFF(%ebx), %eax;		      \
+			call	__GI___fortify_fail@PLT
+#else
+# define CALL_FAIL	movl	$longjmp_msg, %eax;			      \
+			call	__fortify_fail
+#endif
+
+#define CHECK_ESP(reg) \
+	cmpl	reg, %esp;						      \
+	jbe	.Lok;							      \
+	CALL_FAIL;							      \
+.Lok:
+
+
+	.text
+ENTRY (____longjmp_chk)
+	movl	4(%esp), %ecx	/* User's jmp_buf in %ecx.  */
+
+	/* Save the return address now.  */
+	movl	(JB_PC*4)(%ecx), %edx
+	/* Get the stack pointer.  */
+	movl	(JB_SP*4)(%ecx), %edi
+	cfi_undefined(%edi)
+	PTR_DEMANGLE (%edx)
+	PTR_DEMANGLE (%edi)
+
+	pushl	$0
+	cfi_adjust_cfa_offset(4)
+	cmpl	%edi, %esp
+	jbe	.Lok
+
+	subl	$12, %esp
+	cfi_adjust_cfa_offset(12)
+	xorl	%ebx, %ebx
+	movl	%esp, %ecx
+	movl	$__NR_sigaltstack, %eax
+	ENTER_KERNEL
+	movl	4(%esp), %ebx
+	addl	$12, %esp
+	cfi_adjust_cfa_offset(-12)
+	movl	8(%esp), %ecx
+	testl	%eax, %eax
+	jne	.Lok
+	andl	$1, %ebx
+	movl	%ebx, (%esp)
+.Lok:
+	cfi_def_cfa(%ecx, 0)
+	cfi_register(%eip, %edx)
+	cfi_register(%esp, %edi)
+	cfi_offset(%ebx, JB_BX*4)
+	cfi_offset(%esi, JB_SI*4)
+	cfi_offset(%edi, JB_DI*4)
+	cfi_offset(%ebp, JB_BP*4)
+
+	movl	12(%esp), %eax	/* Second argument is return value.  */
+	xchgl	%edi, %esp
+	cfi_restore(%edi)
+
+	cmpl	%esp, %edi
+	jnbe	.Lcheck
+
+	/* Restore registers.  */
+.Lout:	movl	(JB_BX*4)(%ecx), %ebx
+	movl	(JB_SI*4)(%ecx), %esi
+	movl	(JB_DI*4)(%ecx), %edi
+	movl	(JB_BP*4)(%ecx), %ebp
+	cfi_restore(%ebx)
+	cfi_restore(%esi)
+	cfi_restore(%edi)
+	cfi_restore(%ebp)
+
+	/* Jump to saved PC.  */
+	jmp	*%edx
+
+	cfi_def_cfa(%ecx, 0)
+	cfi_register(%eip, %edx)
+	cfi_offset(%ebx, JB_BX*4)
+	cfi_offset(%esi, JB_SI*4)
+	cfi_offset(%edi, JB_DI*4)
+	cfi_offset(%ebp, JB_BP*4)
+
+.Lcheck:
+	cmpl	$0, (%edi)
+	je	.Lfail
+
+	subl	$12, %esp
+	cfi_adjust_cfa_offset(12)
+	xorl	%ebx, %ebx
+	movl	%esp, %ecx
+	movl	$__NR_sigaltstack, %eax
+	ENTER_KERNEL
+	testl	$1, 4(%esp)
+	leal	12(%esp), %esp
+	movl	8(%edi), %ecx
+	movl	12(%edi), %eax
+	cfi_adjust_cfa_offset(-12)
+	je	.Lout
+
+.Lfail:	xchgl	%edi, %esp
+	cfi_def_cfa(%esp, 8)
+	cfi_restore(%esp)
+	cfi_restore(%ebx)
+	cfi_restore(%esi)
+	cfi_undefined(%edi)
+	cfi_restore(%ebp)
+
+	CALL_FAIL
+	hlt
+END (____longjmp_chk)

Added: fsf/trunk/libc/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S
==============================================================================
--- fsf/trunk/libc/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S (added)
+++ fsf/trunk/libc/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S Fri Jul 31 00:04:15 2009
@@ -1,0 +1,145 @@
+/* Copyright (C) 2001,2004,2005,2006,2009 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <sysdep.h>
+#include <jmpbuf-offsets.h>
+#include <asm-syntax.h>
+
+	.section .rodata.str1.1,"aMS",@progbits,1
+	.type	longjmp_msg,@object
+longjmp_msg:
+	.string "longjmp causes uninitialized stack frame"
+	.size	longjmp_msg, .-longjmp_msg
+
+
+//#define __longjmp ____longjmp_chk
+
+#ifdef PIC
+# define CALL_FAIL	leaq	longjmp_msg(%rip), %rdi;		      \
+			call	__GI___fortify_fail
+#else
+# define CALL_FAIL	movq	$longjmp_msg, %rdi;			      \
+			call	__fortify_fail
+#endif
+
+#define CHECK_RSP(reg) \
+	cmpq	reg, %rsp;						      \
+	jbe	.Lok;							      \
+	CALL_FAIL;							      \
+.Lok:
+
+/* Jump to the position specified by ENV, causing the
+   setjmp call there to return VAL, or 1 if VAL is 0.
+   void __longjmp (__jmp_buf env, int val).  */
+	.text
+ENTRY(____longjmp_chk)
+	/* Restore registers.  */
+	movq	(JB_RSP*8)(%rdi),%r8
+	movq	(JB_RBP*8)(%rdi),%r9
+	movq	(JB_PC*8)(%rdi),%rdx
+#ifdef PTR_DEMANGLE
+	PTR_DEMANGLE (%r8)
+	PTR_DEMANGLE (%r9)
+	PTR_DEMANGLE (%rdx)
+#endif
+
+	/* Save function parameters.  */
+	movq	%rdi, %r10
+	movl	%esi, %ecx
+
+	xorl	%eax, %eax
+	cmpq	%r8, %rsp
+	jbe	.Lok
+
+	subq	$24, %rsp
+	cfi_adjust_cfa_offset(24)
+	xorl	%edi, %edi
+	movq	%rsp, %rsi
+	movl	$__NR_sigaltstack, %eax
+	syscall
+	testl	%eax, %eax
+	movl	$0, %eax
+	leaq	24(%rsp), %rsp
+	cfi_adjust_cfa_offset(-24)
+	jne	.Lok
+	movl	8(%rsp), %eax
+	andl	$1, %eax
+
+.Lok:
+	/* We add unwind information for the target here.  */
+	cfi_def_cfa(%r10, 0)
+	cfi_register(%rsp,%r8)
+	cfi_register(%rbp,%r9)
+	cfi_register(%rip,%rdx)
+	cfi_offset(%rbx,JB_RBX*8)
+	cfi_offset(%r12,JB_R12*8)
+	cfi_offset(%r13,JB_R13*8)
+	cfi_offset(%r14,JB_R14*8)
+	cfi_offset(%r15,JB_R15*8)
+
+	xchgq	%r8, %rsp
+	cfi_restore(%rsp)
+	xchgq	%r9, %rbp
+	cfi_restore(%rbp)
+
+	movq	(JB_RBX*8)(%r10),%rbx
+	movq	(JB_R12*8)(%r10),%r12
+	movq	(JB_R13*8)(%r10),%r13
+	movq	(JB_R14*8)(%r10),%r14
+	movq	(JB_R15*8)(%r10),%r15
+
+	cmpq	%rsp, %r8
+	jnbe	.Lcheck
+
+	/* Set return value for setjmp.  */
+.Lout:	movl	%ecx, %eax
+	jmpq	*%rdx
+
+.Lcheck:
+	testl	%eax, %eax
+	je	.Lfail
+
+	subq	$24, %rsp
+	cfi_adjust_cfa_offset(24)
+	xorl	%edi, %edi
+	movq	%rsp, %rsi
+	movl	$__NR_sigaltstack, %eax
+	syscall
+	addq	$24, %rsp
+	cfi_adjust_cfa_offset(-24)
+	testl	$1, 8(%rsp)
+	je	.Lout
+
+.Lfail:	xchgq	%r8, %rsp
+	/* We want the stack trace to show that of the caller.  */
+	cfi_def_cfa(%rsp, 8)
+	cfi_restore(%rsp)
+	cfi_register(%rbp, %r9)
+	cfi_restore(%rip)
+	cfi_restore(%rbx)
+	cfi_restore(%r12)
+	cfi_restore(%r13)
+	cfi_restore(%r14)
+	cfi_restore(%r15)
+
+	xchgq	%r9, %rbp
+	cfi_restore(%rbp)
+
+	CALL_FAIL
+	hlt
+END (BP_SYM (____longjmp_chk))

Modified: fsf/trunk/libc/sysdeps/x86_64/____longjmp_chk.S
==============================================================================
--- fsf/trunk/libc/sysdeps/x86_64/____longjmp_chk.S (original)
+++ fsf/trunk/libc/sysdeps/x86_64/____longjmp_chk.S Fri Jul 31 00:04:15 2009
@@ -1,42 +1,1 @@
-/* Copyright (C) 2001,2004,2005,2006,2009 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
-
-	.section .rodata.str1.1,"aMS",@progbits,1
-	.type	longjmp_msg,@object
-longjmp_msg:
-	.string "longjmp causes uninitialized stack frame"
-	.size	longjmp_msg, .-longjmp_msg
-
-
-#define __longjmp ____longjmp_chk
-
-#ifdef PIC
-# define CALL_FAIL	leaq	longjmp_msg(%rip), %rdi;		      \
-			call	__GI___fortify_fail
-#else
-# define CALL_FAIL	movq	$longjmp_msg, %rdi;			      \
-			call	__fortify_fail
-#endif
-
-#define CHECK_RSP(reg) \
-	cmpq	reg, %rsp;						      \
-	jbe	.Lok;							      \
-	CALL_FAIL;							      \
-.Lok:
-
-#include "__longjmp.S"
+#error "OS-specific version needed"

Modified: fsf/trunk/libc/sysdeps/x86_64/__longjmp.S
==============================================================================
--- fsf/trunk/libc/sysdeps/x86_64/__longjmp.S (original)
+++ fsf/trunk/libc/sysdeps/x86_64/__longjmp.S Fri Jul 31 00:04:15 2009
@@ -34,16 +34,12 @@
 	PTR_DEMANGLE (%r9)
 	PTR_DEMANGLE (%rdx)
 #endif
-#ifdef CHECK_RSP
-	CHECK_RSP (%r8)
-#endif
 	/* We add unwind information for the target here.  */
 	cfi_def_cfa(%rdi, 0)
 	cfi_register(%rsp,%r8)
 	cfi_register(%rbp,%r9)
 	cfi_register(%rip,%rdx)
 	cfi_offset(%rbx,JB_RBX*8)
-	cfi_offset(%rbp,JB_RBP*8)
 	cfi_offset(%r12,JB_R12*8)
 	cfi_offset(%r13,JB_R13*8)
 	cfi_offset(%r14,JB_R14*8)
@@ -58,4 +54,4 @@
 	movq %r8,%rsp
 	movq %r9,%rbp
 	jmpq *%rdx
-END (BP_SYM (__longjmp))
+END (__longjmp)