Rearange jmp_buf content again: storing the sigsetjmp() save_mask midway

inside the environment is not a good idea, we may overwrite it when
fetching other details of the sigjmp environment.
Instead move it to the very end again.
Do not bother to save volatile (caller saved) global registers.
Fixes PR port-sparc64/44918.
This commit is contained in:
martin 2011-04-30 19:39:38 +00:00
parent 8e2b504dac
commit 44283e6e19
3 changed files with 24 additions and 22 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: longjmp.c,v 1.3 2011/04/27 21:08:48 martin Exp $ */
/* $NetBSD: longjmp.c,v 1.4 2011/04/30 19:39:38 martin Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@ -43,14 +43,18 @@
#include <compat/include/setjmp.h>
typedef struct {
__greg_t __glob[5];
__greg_t g3;
__greg_t g6;
__greg_t g7;
__greg_t dummy;
__greg_t save_mask;
} __jmp_buf_regs_t;
/*
* setjmp.S uses hard coded offsets into the jump_buf,
* make sure any changes cause a compile failure here
*/
__CTASSERT(0x68 == offsetof(__jmp_buf_regs_t,__glob[4])+
__CTASSERT(0x68 == offsetof(__jmp_buf_regs_t,save_mask)+
sizeof(struct sigcontext));
void
@ -83,11 +87,11 @@ __longjmp14(jmp_buf env, int val)
uc.uc_mcontext.__gregs[_REG_nPC] = sc->sc_pc+4;
uc.uc_mcontext.__gregs[_REG_G1] = sc->sc_g1;
uc.uc_mcontext.__gregs[_REG_G2] = sc->sc_o0;
uc.uc_mcontext.__gregs[_REG_G3] = r->__glob[0];
uc.uc_mcontext.__gregs[_REG_G4] = r->__glob[1];
uc.uc_mcontext.__gregs[_REG_G5] = r->__glob[2];
uc.uc_mcontext.__gregs[_REG_G6] = r->__glob[3];
uc.uc_mcontext.__gregs[_REG_G7] = r->__glob[4];
uc.uc_mcontext.__gregs[_REG_G3] = r->g3;
uc.uc_mcontext.__gregs[_REG_G4] = 0;
uc.uc_mcontext.__gregs[_REG_G5] = 0;
uc.uc_mcontext.__gregs[_REG_G6] = r->g6;
uc.uc_mcontext.__gregs[_REG_G7] = r->g7;
uc.uc_mcontext.__gregs[_REG_O6] = sc->sc_sp;

View File

@ -1,4 +1,4 @@
/* $NetBSD: setjmp.S,v 1.8 2011/04/27 21:08:48 martin Exp $ */
/* $NetBSD: setjmp.S,v 1.9 2011/04/30 19:39:38 martin Exp $ */
/*
* Copyright (c) 1992, 1993
@ -42,7 +42,7 @@
#if 0
.asciz "@(#)setjmp.s 8.1 (Berkeley) 6/4/93"
#else
RCSID("$NetBSD: setjmp.S,v 1.8 2011/04/27 21:08:48 martin Exp $")
RCSID("$NetBSD: setjmp.S,v 1.9 2011/04/30 19:39:38 martin Exp $")
#endif
#endif /* LIBC_SCCS and not lint */
@ -124,11 +124,9 @@ ENTRY(__setjmp14)
/* 0x38: 4x32bit */ /* sc.sc_mask was already saved above */
/* save additional registers needed to fill a complete mcontext */
stx %l3, [%i0 + 0x48]
stx %l4, [%i0 + 0x50] /* adjust asserts in longjmp.c */
stx %l5, [%i0 + 0x58] /* if you change any of these */
stx %l6, [%i0 + 0x60] /* offsets! */
stx %l7, [%i0 + 0x68]
stx %l3, [%i0 + 0x48] /* adjust asserts in longjmp.c */
stx %l6, [%i0 + 0x50] /* if you change any of these */
stx %l7, [%i0 + 0x58] /* offsets! */
ret /* return 0 */
restore %g0, 0, %o0

View File

@ -1,4 +1,4 @@
/* $NetBSD: sigsetjmp.S,v 1.9 2011/04/27 21:08:48 martin Exp $ */
/* $NetBSD: sigsetjmp.S,v 1.10 2011/04/30 19:39:38 martin Exp $ */
/*
* Copyright (c) 1995 Paul Kranenburg
* All rights reserved.
@ -35,14 +35,14 @@
/*
* We use the sc_npc field inside the sigcontext to store the save mask
*/
#define MASK_OFFSET 0x18
#define MASK_OFFSET 0x68
#ifdef PIC
#ifdef BIGPIC
ENTRY(__sigsetjmp14)
PIC_PROLOGUE(%g1,%o2) ! %g1 = _GLOBAL_OFFSET_TABLE
st %o1,[%o0+MASK_OFFSET] ! jmp_buf.sc.sc_npc
st %o1,[%o0+MASK_OFFSET] ! end of jmpbuf
sethi %hi(_C_LABEL(__setjmp14)), %o2
sethi %hi(_C_LABEL(_setjmp)), %o3
or %o2, %lo(_C_LABEL(__setjmp14)), %o2
@ -56,7 +56,7 @@ ENTRY(__sigsetjmp14)
ENTRY(__siglongjmp14)
PIC_PROLOGUE(%g1,%o2) ! %g1 = _GLOBAL_OFFSET_TABLE
ld [%o0+MASK_OFFSET], %o2 ! jmp_buf.sc.sc_npc
ld [%o0+MASK_OFFSET], %o2 ! end of jmpbuf
sethi %hi(_C_LABEL(__longjmp14)), %o3
sethi %hi(_C_LABEL(_longjmp)), %o4
or %o3, %lo(_C_LABEL(__longjmp14)), %o3
@ -73,7 +73,7 @@ ENTRY(__siglongjmp14)
ENTRY(__sigsetjmp14)
PIC_PROLOGUE(%g1,%o2) ! %g1 = _GLOBAL_OFFSET_TABLE
cmp %o1,0
st %o1,[%o0+MASK_OFFSET] ! jmp_buf.sc.sc_npc
st %o1,[%o0+MASK_OFFSET] ! end of jmpbuf
bne,a 1f
ldx [%g1+_C_LABEL(__setjmp14)], %g1 ! if (%o1 != 0) goto __setjmp;
ldx [%g1+_C_LABEL(_setjmp)], %g1 ! else goto _setjmp;
@ -83,7 +83,7 @@ ENTRY(__sigsetjmp14)
ENTRY(__siglongjmp14)
PIC_PROLOGUE(%g1,%o2) ! %g1 = _GLOBAL_OFFSET_TABLE
ld [%o0+MASK_OFFSET],%o2 ! jmp_buf.sc.sc_npc
ld [%o0+MASK_OFFSET],%o2 ! end of jmpbuf
cmp %o2,0
bne,a 1f
ldx [%g1+_C_LABEL(__longjmp14)], %g1 ! if (%o2 != 0) goto __longjmp;
@ -98,7 +98,7 @@ ENTRY(__siglongjmp14)
ENTRY(__sigsetjmp14)
cmp %o1,0
be _C_LABEL(_setjmp)
st %o1,[%o0+MASK_OFFSET] ! jmp_buf.sc.sc_npc
st %o1,[%o0+MASK_OFFSET] ! end of jmpbuf
ba,a _C_LABEL(__setjmp14)
unimp 0