Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/arch/sparc/gen Use save instruction to set up a loc...
details: https://anonhg.NetBSD.org/src/rev/7968164e8da9
branches: trunk
changeset: 330510:7968164e8da9
user: nakayama <nakayama%NetBSD.org@localhost>
date: Sat Jul 12 19:11:57 2014 +0000
description:
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.
diffstat:
lib/libc/arch/sparc/gen/_setjmp.S | 46 +++++++++++++++++++++++++++-----------
1 files changed, 33 insertions(+), 13 deletions(-)
diffs (76 lines):
diff -r 4901715078d7 -r 7968164e8da9 lib/libc/arch/sparc/gen/_setjmp.S
--- a/lib/libc/arch/sparc/gen/_setjmp.S Sat Jul 12 16:52:57 2014 +0000
+++ b/lib/libc/arch/sparc/gen/_setjmp.S Sat Jul 12 19:11:57 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: _setjmp.S,v 1.9 2011/04/30 23:41:12 martin Exp $ */
+/* $NetBSD: _setjmp.S,v 1.10 2014/07/12 19:11:57 nakayama 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.10 2014/07/12 19:11:57 nakayama Exp $")
#endif /* LIBC_SCCS and not lint */
/*
@@ -59,26 +59,46 @@
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
Home |
Main Index |
Thread Index |
Old Index