1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-10-19 02:29:40 +00:00

Translate T_PROTFLT to SIGSEGV instead of SIGBUS when running under

Linux emulation.  This make Allegro Common Lisp 4.3 work under
FreeBSD!

Submitted by: Fred Gilham <gilham@csl.sri.com>
Commented on by: bde, dg, msmith, tg
Hoping he got everything right:  eivind
This commit is contained in:
Eivind Eklund 1998-04-28 18:15:08 +00:00
parent 71358584f3
commit 288078be0f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=35496
9 changed files with 76 additions and 9 deletions

View File

@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: linux_sysvec.c,v 1.26 1998/02/13 07:34:52 bde Exp $
* $Id: linux_sysvec.c,v 1.27 1998/04/13 17:49:51 sos Exp $
*/
/* XXX we use functions that might not exist. */
@ -98,6 +98,29 @@ int linux_to_bsd_signal[LINUX_NSIG] = {
SIGXCPU, SIGXFSZ, SIGVTALRM, SIGPROF, SIGWINCH, SIGURG, SIGURG, 0
};
/*
* If FreeBSD & Linux have a difference of opinion about what a trap
* means, deal with it here.
*/
static int
translate_traps(int signal, int trap_code)
{
switch(signal) {
case SIGBUS:
switch(trap_code) {
case T_PROTFLT:
case T_TSSFLT:
case T_DOUBLEFLT:
case T_PAGEFLT:
return SIGSEGV;
default:
return signal;
}
default:
return signal;
}
}
static int
linux_fixup(int **stack_base, struct image_params *imgp)
{
@ -374,6 +397,7 @@ struct sysentvec linux_sysvec = {
bsd_to_linux_signal,
ELAST,
bsd_to_linux_errno,
translate_traps,
linux_fixup,
linux_sendsig,
linux_sigcode,
@ -390,6 +414,7 @@ struct sysentvec elf_linux_sysvec = {
bsd_to_linux_signal,
ELAST,
bsd_to_linux_errno,
translate_traps,
elf_linux_fixup,
linux_sendsig,
linux_sigcode,

View File

@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* from: @(#)trap.c 7.4 (Berkeley) 5/13/91
* $Id: trap.c,v 1.125 1998/03/30 09:48:27 phk Exp $
* $Id: trap.c,v 1.126 1998/04/15 17:45:07 bde Exp $
*/
/*
@ -545,6 +545,10 @@ trap(frame)
return;
}
/* Translate fault for emulators (e.g. Linux) */
if (*p->p_sysent->sv_transtrap)
i = (*p->p_sysent->sv_transtrap)(i, type);
trapsignal(p, i, ucode);
#ifdef DEBUG

View File

@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* from: @(#)trap.c 7.4 (Berkeley) 5/13/91
* $Id: trap.c,v 1.125 1998/03/30 09:48:27 phk Exp $
* $Id: trap.c,v 1.126 1998/04/15 17:45:07 bde Exp $
*/
/*
@ -545,6 +545,10 @@ trap(frame)
return;
}
/* Translate fault for emulators (e.g. Linux) */
if (*p->p_sysent->sv_transtrap)
i = (*p->p_sysent->sv_transtrap)(i, type);
trapsignal(p, i, ucode);
#ifdef DEBUG

View File

@ -27,7 +27,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id$
* $Id: ibcs2_sysvec.c,v 1.6 1997/02/22 09:33:28 peter Exp $
*/
#include <sys/param.h>
@ -49,6 +49,7 @@ struct sysentvec ibcs2_svr3_sysvec = {
bsd_to_ibcs2_sig,
ELAST,
bsd_to_ibcs2_errno,
0, /* trap-to-signal translation function */
0, /* fixup */
sendsig,
sigcode, /* use generic trampoline */

View File

@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: linux_sysvec.c,v 1.26 1998/02/13 07:34:52 bde Exp $
* $Id: linux_sysvec.c,v 1.27 1998/04/13 17:49:51 sos Exp $
*/
/* XXX we use functions that might not exist. */
@ -98,6 +98,29 @@ int linux_to_bsd_signal[LINUX_NSIG] = {
SIGXCPU, SIGXFSZ, SIGVTALRM, SIGPROF, SIGWINCH, SIGURG, SIGURG, 0
};
/*
* If FreeBSD & Linux have a difference of opinion about what a trap
* means, deal with it here.
*/
static int
translate_traps(int signal, int trap_code)
{
switch(signal) {
case SIGBUS:
switch(trap_code) {
case T_PROTFLT:
case T_TSSFLT:
case T_DOUBLEFLT:
case T_PAGEFLT:
return SIGSEGV;
default:
return signal;
}
default:
return signal;
}
}
static int
linux_fixup(int **stack_base, struct image_params *imgp)
{
@ -374,6 +397,7 @@ struct sysentvec linux_sysvec = {
bsd_to_linux_signal,
ELAST,
bsd_to_linux_errno,
translate_traps,
linux_fixup,
linux_sendsig,
linux_sigcode,
@ -390,6 +414,7 @@ struct sysentvec elf_linux_sysvec = {
bsd_to_linux_signal,
ELAST,
bsd_to_linux_errno,
translate_traps,
elf_linux_fixup,
linux_sendsig,
linux_sigcode,

View File

@ -26,7 +26,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: imgact_elf.c,v 1.22 1998/03/02 05:47:58 peter Exp $
* $Id: imgact_elf.c,v 1.23 1998/03/28 13:24:52 bde Exp $
*/
#include "opt_rlimit.h"
@ -78,6 +78,7 @@ static struct sysentvec elf_freebsd_sysvec = {
0,
0,
0,
0,
elf_freebsd_fixup,
sendsig,
sigcode,

View File

@ -1,7 +1,7 @@
/*
* sysentvec for native FreeBSD a.out executable format.
*
* $Id: init_sysvec.c,v 1.4 1997/02/22 09:38:59 peter Exp $
* $Id: init_sysvec.c,v 1.5 1997/08/02 14:31:26 bde Exp $
*/
#include <sys/param.h>
@ -19,6 +19,7 @@ struct sysentvec aout_sysvec = {
0,
0,
0,
0,
sendsig,
sigcode,
&szsigcode,

View File

@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* from: @(#)trap.c 7.4 (Berkeley) 5/13/91
* $Id: trap.c,v 1.125 1998/03/30 09:48:27 phk Exp $
* $Id: trap.c,v 1.126 1998/04/15 17:45:07 bde Exp $
*/
/*
@ -545,6 +545,10 @@ trap(frame)
return;
}
/* Translate fault for emulators (e.g. Linux) */
if (*p->p_sysent->sv_transtrap)
i = (*p->p_sysent->sv_transtrap)(i, type);
trapsignal(p, i, ucode);
#ifdef DEBUG

View File

@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: sysent.h,v 1.15 1997/11/06 19:29:47 phk Exp $
* $Id: sysent.h,v 1.16 1998/02/03 21:51:57 bde Exp $
*/
#ifndef _SYS_SYSENT_H_
@ -58,6 +58,8 @@ struct sysentvec {
int *sv_sigtbl; /* signal translation table */
int sv_errsize; /* size of errno translation table */
int *sv_errtbl; /* errno translation table */
int (*sv_transtrap) __P((int, int));
/* translate trap-to-signal mapping */
int (*sv_fixup) __P((int **, struct image_params *));
/* stack fixup function */
void (*sv_sendsig) __P((void (*)(int), int, int, u_long));