Module Name: src Committed By: msaitoh Date: Thu Aug 7 08:53:40 UTC 2014
Modified Files: src/lib/libc/arch/sparc/gen [netbsd-6-1]: _setjmp.S Log Message: Pull up following revision(s) (requested by nakayama in ticket #1100): lib/libc/arch/sparc/gen/_setjmp.S: revision 1.10 Use save instruction to set up a local stack frame. This fixes a segmentation fault caused by bash 4.3 on sparc64 kernels with 32-bit userland, bash uses _setjmp/_longjmp heavyly via sigsetjmp/siglongjmp since 4.3. For 32-bit compat library which is compiled with -mcpu=ultrasparc option (and define __sparc_v9__), use a similar code to 64-bit library. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.9.18.1 src/lib/libc/arch/sparc/gen/_setjmp.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libc/arch/sparc/gen/_setjmp.S diff -u src/lib/libc/arch/sparc/gen/_setjmp.S:1.9 src/lib/libc/arch/sparc/gen/_setjmp.S:1.9.18.1 --- src/lib/libc/arch/sparc/gen/_setjmp.S:1.9 Sat Apr 30 23:41:12 2011 +++ src/lib/libc/arch/sparc/gen/_setjmp.S Thu Aug 7 08:53:40 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: _setjmp.S,v 1.9 2011/04/30 23:41:12 martin Exp $ */ +/* $NetBSD: _setjmp.S,v 1.9.18.1 2014/08/07 08:53:40 msaitoh Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -33,7 +33,7 @@ #include <machine/trap.h> #if defined(LIBC_SCCS) && !defined(lint) -RCSID("$NetBSD: _setjmp.S,v 1.9 2011/04/30 23:41:12 martin Exp $") +RCSID("$NetBSD: _setjmp.S,v 1.9.18.1 2014/08/07 08:53:40 msaitoh Exp $") #endif /* LIBC_SCCS and not lint */ /* @@ -59,26 +59,46 @@ ENTRY(_setjmp) clr %o0 ! return 0 ENTRY(_longjmp) - sub %sp, 64, %sp ! set up a local stack frame - tst %o1 ! compute v ? v : 1 +#ifdef __sparc_v9__ + save %sp, -CCFSZ, %sp + flushw + /* + * We restore the saved stack pointer to %fp, then issue + * a `restore' instruction which will reload the register + * window from the stack. + */ + ld [%i0 + 16], %g3 + ld [%i0 + 24], %g2 + ld [%i0 + 48], %g4 + ld [%i0 + 52], %g7 + ld [%i0 + 4], %i7 /* restore return pc */ + ld [%i0 + 0], %fp /* and stack pointer */ + mov 1, %i0 + movrnz %i1, %i1, %i0 ! compute v ? v : 1 + ret + restore +#else + save %sp, -64, %sp ! set up a local stack frame + tst %i1 ! compute v ? v : 1 be,a 0f - mov 1, %o1 + mov 1, %i1 0: t ST_FLUSHWIN ! flush register windows out to the stack /* restore globals */ - ld [%o0 + 16], %g3 - ld [%o0 + 24], %g2 - ld [%o0 + 48], %g4 - ld [%o0 + 52], %g7 + ld [%i0 + 16], %g3 + ld [%i0 + 24], %g2 + ld [%i0 + 48], %g4 + ld [%i0 + 52], %g7 /* * We restore the saved stack pointer to %fp, then issue * a `restore' instruction which will reload the register * window from the stack. */ - ld [%o0+4], %o7 /* restore return pc */ - ld [%o0+0], %fp /* and stack pointer */ + ld [%i0+4], %i7 /* restore return pc */ + ld [%i0+0], %fp /* and stack pointer */ - retl ! success, return %o1 - restore %o1, 0, %o0 + ret ! success, return %i1 + restore %i1, 0, %o0 +#endif