restructure struct emul and execsw, in preparation to make emulations LKMable:
* move all exec-type specific information from struct emul to execsw[] and provide single struct emul per emulation * elf: - kern/exec_elf32.c:probe_funcs[] is gone, execsw[] how has one entry per emulation and contains pointer to respective probe function - interp is allocated via MALLOC() rather than on stack - elf_args structure is allocated via MALLOC() rather than malloc() * ecoff: the per-emulation hooks moved from alpha and mips specific code to OSF1 and Ultrix compat code as appropriate, execsw[] has one entry per emulation supporting ecoff with appropriate probe function * the makecmds/probe functions don't set emulation, pointer to emulation is part of appropriate execsw[] entry * constify couple of structures
This commit is contained in:
parent
1a5d87c9fa
commit
baae0324b9
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: machdep.c,v 1.223 2000/11/20 20:37:52 thorpej Exp $ */
|
||||
/* $NetBSD: machdep.c,v 1.224 2000/11/21 00:37:49 jdolecek Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
|
||||
@ -73,7 +73,7 @@
|
||||
|
||||
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
||||
|
||||
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.223 2000/11/20 20:37:52 thorpej Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.224 2000/11/21 00:37:49 jdolecek Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -1983,10 +1983,7 @@ delay(n)
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(COMPAT_OSF1) || 1 /* XXX */
|
||||
void cpu_exec_ecoff_setregs __P((struct proc *, struct exec_package *,
|
||||
u_long));
|
||||
|
||||
#if 1 /* XXX */
|
||||
void
|
||||
cpu_exec_ecoff_setregs(p, epp, stack)
|
||||
struct proc *p;
|
||||
@ -2007,31 +2004,18 @@ cpu_exec_ecoff_setregs(p, epp, stack)
|
||||
*
|
||||
*/
|
||||
int
|
||||
cpu_exec_ecoff_hook(p, epp)
|
||||
cpu_exec_ecoff_probe(p, epp)
|
||||
struct proc *p;
|
||||
struct exec_package *epp;
|
||||
{
|
||||
struct ecoff_exechdr *execp = (struct ecoff_exechdr *)epp->ep_hdr;
|
||||
extern struct emul emul_netbsd;
|
||||
int error;
|
||||
extern int osf1_exec_ecoff_hook(struct proc *p,
|
||||
struct exec_package *epp);
|
||||
|
||||
switch (execp->f.f_magic) {
|
||||
#ifdef COMPAT_OSF1
|
||||
case ECOFF_MAGIC_ALPHA:
|
||||
error = osf1_exec_ecoff_hook(p, epp);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case ECOFF_MAGIC_NETBSD_ALPHA:
|
||||
epp->ep_emul = &emul_netbsd;
|
||||
if (execp->f.f_magic == ECOFF_MAGIC_NETBSD_ALPHA)
|
||||
error = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
else
|
||||
error = ENOEXEC;
|
||||
}
|
||||
|
||||
return (error);
|
||||
}
|
||||
#endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: trap.c,v 1.78 2000/06/29 08:44:04 mrg Exp $ */
|
||||
/* $NetBSD: trap.c,v 1.79 2000/11/21 00:37:50 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988 University of Utah.
|
||||
@ -83,12 +83,7 @@ extern struct emul emul_sunos;
|
||||
#endif
|
||||
|
||||
#ifdef COMPAT_LINUX
|
||||
#ifdef EXEC_AOUT
|
||||
extern struct emul emul_linux_aout;
|
||||
#endif
|
||||
#ifdef EXEC_ELF32
|
||||
extern struct emul emul_linux_elf32;
|
||||
#endif
|
||||
extern struct emul emul_linux;
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -756,7 +751,7 @@ syscall(code, frame)
|
||||
struct frame frame;
|
||||
{
|
||||
register caddr_t params;
|
||||
register struct sysent *callp;
|
||||
register const struct sysent *callp;
|
||||
register struct proc *p;
|
||||
int error, opc, nsys;
|
||||
size_t argsize;
|
||||
@ -846,14 +841,7 @@ syscall(code, frame)
|
||||
callp += code;
|
||||
argsize = callp->sy_argsize;
|
||||
#ifdef COMPAT_LINUX
|
||||
if (0
|
||||
# ifdef EXEC_AOUT
|
||||
|| p->p_emul == &emul_linux_aout
|
||||
# endif
|
||||
# ifdef EXEC_ELF32
|
||||
|| p->p_emul == &emul_linux_elf32
|
||||
# endif
|
||||
) {
|
||||
if (p->p_emul == &emul_linux) {
|
||||
/*
|
||||
* Linux passes the args in d1-d5
|
||||
*/
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: trap.c,v 1.54 2000/06/29 08:28:23 mrg Exp $ */
|
||||
/* $NetBSD: trap.c,v 1.55 2000/11/21 00:37:50 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988 University of Utah.
|
||||
@ -94,12 +94,7 @@ extern struct emul emul_sunos;
|
||||
#endif
|
||||
|
||||
#ifdef COMPAT_LINUX
|
||||
#ifdef EXEC_AOUT
|
||||
extern struct emul emul_linux_aout;
|
||||
#endif
|
||||
#ifdef EXEC_ELF32
|
||||
extern struct emul emul_linux_elf32;
|
||||
#endif
|
||||
extern struct emul emul_linux;
|
||||
#endif
|
||||
|
||||
void syscall __P((register_t, struct frame));
|
||||
@ -992,7 +987,7 @@ syscall(code, frame)
|
||||
struct frame frame;
|
||||
{
|
||||
register caddr_t params;
|
||||
register struct sysent *callp;
|
||||
register const struct sysent *callp;
|
||||
register struct proc *p;
|
||||
int error, opc, nsys;
|
||||
size_t argsize;
|
||||
@ -1082,14 +1077,7 @@ syscall(code, frame)
|
||||
callp += code;
|
||||
argsize = callp->sy_argsize;
|
||||
#ifdef COMPAT_LINUX
|
||||
if (0
|
||||
# ifdef EXEC_AOUT
|
||||
|| p->p_emul == &emul_linux_aout
|
||||
# endif
|
||||
# ifdef EXEC_ELF32
|
||||
|| p->p_emul == &emul_linux_elf32
|
||||
# endif
|
||||
) {
|
||||
if (p->p_emul == &emul_linux) {
|
||||
/*
|
||||
* Linux passes the args in d1-d5
|
||||
*/
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: trap.c,v 1.81 2000/06/29 08:23:03 mrg Exp $ */
|
||||
/* $NetBSD: trap.c,v 1.82 2000/11/21 00:37:50 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988 University of Utah.
|
||||
@ -91,12 +91,7 @@ extern struct emul emul_sunos;
|
||||
#endif
|
||||
|
||||
#ifdef COMPAT_LINUX
|
||||
#ifdef EXEC_AOUT
|
||||
extern struct emul emul_linux_aout;
|
||||
#endif
|
||||
#ifdef EXEC_ELF32
|
||||
extern struct emul emul_linux_elf32;
|
||||
#endif
|
||||
extern struct emul emul_linux;
|
||||
#endif
|
||||
|
||||
int writeback __P((struct frame *fp, int docachepush));
|
||||
@ -987,7 +982,7 @@ syscall(code, frame)
|
||||
struct frame frame;
|
||||
{
|
||||
caddr_t params;
|
||||
struct sysent *callp;
|
||||
struct const sysent *callp;
|
||||
struct proc *p;
|
||||
int error, opc, nsys;
|
||||
size_t argsize;
|
||||
@ -1077,14 +1072,7 @@ syscall(code, frame)
|
||||
callp += code;
|
||||
argsize = callp->sy_argsize;
|
||||
#ifdef COMPAT_LINUX
|
||||
if (0
|
||||
# ifdef EXEC_AOUT
|
||||
|| p->p_emul == &emul_linux_aout
|
||||
# endif
|
||||
# ifdef EXEC_ELF32
|
||||
|| p->p_emul == &emul_linux_elf32
|
||||
# endif
|
||||
) {
|
||||
if (p->p_emul == &emul_linux) {
|
||||
/*
|
||||
* Linux passes the args in d1-d5
|
||||
*/
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: trap.c,v 1.140 2000/06/29 08:44:54 mrg Exp $ */
|
||||
/* $NetBSD: trap.c,v 1.141 2000/11/21 00:37:50 jdolecek Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
@ -128,31 +128,17 @@
|
||||
#include <sys/exec_elf.h>
|
||||
#include <compat/ibcs2/ibcs2_errno.h>
|
||||
#include <compat/ibcs2/ibcs2_exec.h>
|
||||
extern struct emul emul_ibcs2_coff, emul_ibcs2_xout, emul_ibcs2_elf;
|
||||
extern struct emul emul_ibcs2;
|
||||
#endif
|
||||
|
||||
#ifdef COMPAT_LINUX
|
||||
# include <sys/exec.h>
|
||||
# include <compat/linux/linux_syscall.h>
|
||||
|
||||
# ifdef EXEC_AOUT
|
||||
extern struct emul emul_linux_aout;
|
||||
# endif
|
||||
# ifdef EXEC_ELF32
|
||||
extern struct emul emul_linux_elf32;
|
||||
# endif
|
||||
# ifdef EXEC_ELF64
|
||||
extern struct emul emul_linux_elf64;
|
||||
# endif
|
||||
extern struct emul emul_linux;
|
||||
#endif /* COMPAT_LINUX */
|
||||
|
||||
#ifdef COMPAT_FREEBSD
|
||||
# ifdef EXEC_AOUT
|
||||
extern struct emul emul_freebsd_aout;
|
||||
# endif /* EXEC_AOUT */
|
||||
# ifdef EXEC_ELF32
|
||||
extern struct emul emul_freebsd_elf32;
|
||||
# endif /* EXEC_ELF32 */
|
||||
extern struct emul emul_freebsd;
|
||||
#endif /* COMPAT_FREEBSD */
|
||||
|
||||
#ifdef COMPAT_AOUT
|
||||
@ -613,7 +599,7 @@ syscall(frame)
|
||||
struct trapframe frame;
|
||||
{
|
||||
register caddr_t params;
|
||||
register struct sysent *callp;
|
||||
register const struct sysent *callp;
|
||||
register struct proc *p;
|
||||
int error, opc, nsys;
|
||||
size_t argsize;
|
||||
@ -639,35 +625,18 @@ syscall(frame)
|
||||
callp = p->p_emul->e_sysent;
|
||||
|
||||
#ifdef COMPAT_LINUX
|
||||
linux = 0
|
||||
# ifdef EXEC_AOUT
|
||||
|| (p->p_emul == &emul_linux_aout)
|
||||
# endif /* EXEC_AOUT */
|
||||
# ifdef EXEC_ELF32
|
||||
|| (p->p_emul == &emul_linux_elf32)
|
||||
# endif /* EXEC_ELF32 */
|
||||
# ifdef EXEC_ELF64
|
||||
|| (p->p_emul == &emul_linux_elf64)
|
||||
# endif /* EXEC_ELF64 */
|
||||
;
|
||||
linux = (p->p_emul == &emul_linux);
|
||||
#endif /* COMPAT_LINUX */
|
||||
|
||||
#ifdef COMPAT_FREEBSD
|
||||
freebsd = 0
|
||||
# ifdef EXEC_AOUT
|
||||
|| (p->p_emul == &emul_freebsd_aout)
|
||||
# endif /* EXEC_AOUT */
|
||||
# ifdef EXEC_ELF32
|
||||
|| (p->p_emul == &emul_freebsd_elf32)
|
||||
# endif /* EXEC_ELF32 */
|
||||
;
|
||||
freebsd = (p->p_emul == &emul_freebsd);
|
||||
#endif /* COMPAT_FREEBSD */
|
||||
|
||||
#ifdef COMPAT_IBCS2
|
||||
if (p->p_emul == &emul_ibcs2_coff || p->p_emul == &emul_ibcs2_elf ||
|
||||
p->p_emul == &emul_ibcs2_xout)
|
||||
if (p->p_emul == &emul_ibcs2) {
|
||||
if (IBCS2_HIGH_SYSCALL(code))
|
||||
code = IBCS2_CVT_HIGH_SYSCALL(code);
|
||||
}
|
||||
#endif /* COMPAT_IBCS2 */
|
||||
params = (caddr_t)frame.tf_esp + sizeof(int);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: trap.c,v 1.84 2000/06/29 08:15:13 mrg Exp $ */
|
||||
/* $NetBSD: trap.c,v 1.85 2000/11/21 00:37:50 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988 University of Utah.
|
||||
@ -88,12 +88,7 @@ extern struct emul emul_sunos;
|
||||
#endif
|
||||
|
||||
#ifdef COMPAT_LINUX
|
||||
#ifdef EXEC_AOUT
|
||||
extern struct emul emul_linux_aout;
|
||||
#endif
|
||||
#ifdef EXEC_ELF32
|
||||
extern struct emul emul_linux_elf32;
|
||||
#endif
|
||||
extern struct emul emul_linux;
|
||||
#endif
|
||||
|
||||
int astpending;
|
||||
@ -960,7 +955,7 @@ syscall(code, frame)
|
||||
struct frame frame;
|
||||
{
|
||||
caddr_t params;
|
||||
struct sysent *callp;
|
||||
struct const sysent *callp;
|
||||
struct proc *p;
|
||||
int error, opc, nsys;
|
||||
size_t argsize;
|
||||
@ -1050,14 +1045,7 @@ syscall(code, frame)
|
||||
callp += code;
|
||||
argsize = callp->sy_argsize;
|
||||
#ifdef COMPAT_LINUX
|
||||
if (0
|
||||
# ifdef EXEC_AOUT
|
||||
|| p->p_emul == &emul_linux_aout
|
||||
# endif
|
||||
# ifdef EXEC_ELF32
|
||||
|| p->p_emul == &emul_linux_elf32
|
||||
# endif
|
||||
) {
|
||||
if (p->p_emul == &emul_linux) {
|
||||
/*
|
||||
* Linux passes the args in d1-d5
|
||||
*/
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cpu_exec.c,v 1.24 2000/06/29 08:11:27 mrg Exp $ */
|
||||
/* $NetBSD: cpu_exec.c,v 1.25 2000/11/21 00:37:51 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -134,8 +134,6 @@ cpu_exec_aout_makecmds(p, epp)
|
||||
}
|
||||
|
||||
#ifdef COMPAT_ULTRIX
|
||||
extern struct emul emul_ultrix;
|
||||
|
||||
void
|
||||
cpu_exec_ecoff_setregs(p, epp, stack)
|
||||
struct proc *p;
|
||||
@ -148,23 +146,6 @@ cpu_exec_ecoff_setregs(p, epp, stack)
|
||||
setregs(p, epp, stack);
|
||||
f->f_regs[GP] = (register_t)execp->a.gp_value;
|
||||
}
|
||||
|
||||
/*
|
||||
* cpu_exec_ecoff_hook():
|
||||
* cpu-dependent ECOFF format hook for execve().
|
||||
*
|
||||
* Do any machine-dependent diddling of the exec package when doing ECOFF.
|
||||
*
|
||||
*/
|
||||
int
|
||||
cpu_exec_ecoff_hook(p, epp)
|
||||
struct proc *p;
|
||||
struct exec_package *epp;
|
||||
{
|
||||
|
||||
epp->ep_emul = &emul_ultrix;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: trap.c,v 1.44 2000/11/20 19:35:30 scw Exp $ */
|
||||
/* $NetBSD: trap.c,v 1.45 2000/11/21 00:37:51 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988 University of Utah.
|
||||
@ -89,12 +89,7 @@ extern struct emul emul_sunos;
|
||||
#endif
|
||||
|
||||
#ifdef COMPAT_LINUX
|
||||
#ifdef EXEC_AOUT
|
||||
extern struct emul emul_linux_aout;
|
||||
#endif
|
||||
#ifdef EXEC_ELF32
|
||||
extern struct emul emul_linux_elf32;
|
||||
#endif
|
||||
extern struct emul emul_linux;
|
||||
#endif
|
||||
|
||||
int writeback __P((struct frame *fp, int docachepush));
|
||||
@ -998,7 +993,7 @@ syscall(code, frame)
|
||||
struct frame frame;
|
||||
{
|
||||
caddr_t params;
|
||||
struct sysent *callp;
|
||||
struct const sysent *callp;
|
||||
struct proc *p;
|
||||
int error, opc, nsys;
|
||||
size_t argsize;
|
||||
@ -1088,14 +1083,7 @@ syscall(code, frame)
|
||||
callp += code;
|
||||
argsize = callp->sy_argsize;
|
||||
#ifdef COMPAT_LINUX
|
||||
if (0
|
||||
# ifdef EXEC_AOUT
|
||||
|| p->p_emul == &emul_linux_aout
|
||||
# endif
|
||||
# ifdef EXEC_ELF32
|
||||
|| p->p_emul == &emul_linux_elf32
|
||||
# endif
|
||||
) {
|
||||
if (p->p_emul == &emul_linux) {
|
||||
/*
|
||||
* Linux passes the args in d1-d5
|
||||
*/
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: trap.c,v 1.7 2000/06/29 08:02:52 mrg Exp $ */
|
||||
/* $NetBSD: trap.c,v 1.8 2000/11/21 00:37:51 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988 University of Utah.
|
||||
@ -80,12 +80,7 @@ extern struct emul emul_sunos;
|
||||
#endif
|
||||
|
||||
#ifdef COMPAT_LINUX
|
||||
#ifdef EXEC_AOUT
|
||||
extern struct emul emul_linux_aout;
|
||||
#endif
|
||||
#ifdef EXEC_ELF32
|
||||
extern struct emul emul_linux_elf32;
|
||||
#endif
|
||||
extern struct emul emul_linux;
|
||||
#endif
|
||||
|
||||
int writeback __P((struct frame *fp, int docachepush));
|
||||
@ -946,7 +941,7 @@ syscall(code, frame)
|
||||
struct frame frame;
|
||||
{
|
||||
caddr_t params;
|
||||
struct sysent *callp;
|
||||
struct const sysent *callp;
|
||||
struct proc *p;
|
||||
int error, opc, nsys;
|
||||
size_t argsize;
|
||||
@ -1036,14 +1031,7 @@ syscall(code, frame)
|
||||
callp += code;
|
||||
argsize = callp->sy_argsize;
|
||||
#ifdef COMPAT_LINUX
|
||||
if (0
|
||||
# ifdef EXEC_AOUT
|
||||
|| p->p_emul == &emul_linux_aout
|
||||
# endif
|
||||
# ifdef EXEC_ELF32
|
||||
|| p->p_emul == &emul_linux_elf32
|
||||
# endif
|
||||
) {
|
||||
if (p->p_emul == &emul_linux) {
|
||||
/*
|
||||
* Linux passes the args in d1-d5
|
||||
*/
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: trap.c,v 1.25 2000/06/29 07:58:50 mrg Exp $ */
|
||||
/* $NetBSD: trap.c,v 1.26 2000/11/21 00:37:51 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* This file was taken from mvme68k/mvme68k/trap.c
|
||||
@ -96,12 +96,7 @@ extern struct emul emul_sunos;
|
||||
#endif
|
||||
|
||||
#ifdef COMPAT_LINUX
|
||||
#ifdef EXEC_AOUT
|
||||
extern struct emul emul_linux_aout;
|
||||
#endif
|
||||
#ifdef EXEC_ELF32
|
||||
extern struct emul emul_linux_elf32;
|
||||
#endif
|
||||
extern struct emul emul_linux;
|
||||
#endif
|
||||
|
||||
int writeback __P((struct frame *fp, int docachepush));
|
||||
@ -995,7 +990,7 @@ syscall(code, frame)
|
||||
struct frame frame;
|
||||
{
|
||||
caddr_t params;
|
||||
struct sysent *callp;
|
||||
struct const sysent *callp;
|
||||
struct proc *p;
|
||||
int error, opc, nsys;
|
||||
size_t argsize;
|
||||
@ -1085,14 +1080,7 @@ syscall(code, frame)
|
||||
callp += code;
|
||||
argsize = callp->sy_argsize;
|
||||
#ifdef COMPAT_LINUX
|
||||
if (0
|
||||
# ifdef EXEC_AOUT
|
||||
|| p->p_emul == &emul_linux_aout
|
||||
# endif
|
||||
# ifdef EXEC_ELF32
|
||||
|| p->p_emul == &emul_linux_elf32
|
||||
# endif
|
||||
) {
|
||||
if (p->p_emul == &emul_linux) {
|
||||
/*
|
||||
* Linux passes the args in d1-d5
|
||||
*/
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: trap.c,v 1.93 2000/06/29 07:40:12 mrg Exp $ */
|
||||
/* $NetBSD: trap.c,v 1.94 2000/11/21 00:37:52 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996
|
||||
@ -96,7 +96,7 @@ extern struct emul emul_sunos;
|
||||
#include <sparc/sparc/cpuvar.h>
|
||||
|
||||
#ifdef COMPAT_AOUT
|
||||
extern struct emul emul_netbsd_aout;
|
||||
extern struct emul emul_netbsd;
|
||||
#endif /* COMPAT_AOUT */
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -1137,7 +1137,7 @@ syscall(code, tf, pc)
|
||||
register_t pc;
|
||||
{
|
||||
int i, nsys, *ap, nap;
|
||||
struct sysent *callp;
|
||||
struct const sysent *callp;
|
||||
struct proc *p;
|
||||
int error, new;
|
||||
struct args {
|
||||
@ -1198,7 +1198,7 @@ syscall(code, tf, pc)
|
||||
case SYS___syscall:
|
||||
if (callp != sysent
|
||||
#ifdef COMPAT_AOUT
|
||||
&& p->p_emul != &emul_netbsd_aout /* Our a.out */
|
||||
&& p->p_emul != &emul_netbsd /* Our a.out */
|
||||
#endif
|
||||
)
|
||||
break;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: trap.c,v 1.93 2000/06/29 07:19:09 mrg Exp $ */
|
||||
/* $NetBSD: trap.c,v 1.94 2000/11/21 00:37:52 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Gordon W. Ross
|
||||
@ -89,12 +89,7 @@ extern struct emul emul_sunos;
|
||||
#endif
|
||||
|
||||
#ifdef COMPAT_LINUX
|
||||
#ifdef EXEC_AOUT
|
||||
extern struct emul emul_linux_aout;
|
||||
#endif
|
||||
#ifdef EXEC_ELF32
|
||||
extern struct emul emul_linux_elf32;
|
||||
#endif
|
||||
extern struct emul emul_linux;
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -589,7 +584,7 @@ syscall(code, tf)
|
||||
struct trapframe tf;
|
||||
{
|
||||
register caddr_t params;
|
||||
register struct sysent *callp;
|
||||
register const struct sysent *callp;
|
||||
register struct proc *p;
|
||||
int error, opc, nsys;
|
||||
size_t argsize;
|
||||
@ -682,14 +677,7 @@ syscall(code, tf)
|
||||
callp += code;
|
||||
argsize = callp->sy_argsize;
|
||||
#ifdef COMPAT_LINUX
|
||||
if (0
|
||||
# ifdef EXEC_AOUT
|
||||
|| p->p_emul == &emul_linux_aout
|
||||
# endif
|
||||
# ifdef EXEC_ELF32
|
||||
|| p->p_emul == &emul_linux_elf32
|
||||
# endif
|
||||
) {
|
||||
if (p->p_emul == &emul_linux) {
|
||||
/*
|
||||
* Linux passes the args in d1-d5
|
||||
*/
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: trap.c,v 1.43 2000/06/29 07:07:57 mrg Exp $ */
|
||||
/* $NetBSD: trap.c,v 1.44 2000/11/21 00:37:52 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988 University of Utah.
|
||||
@ -92,12 +92,7 @@ extern struct emul emul_sunos;
|
||||
#endif
|
||||
|
||||
#ifdef COMPAT_LINUX
|
||||
#ifdef EXEC_AOUT
|
||||
extern struct emul emul_linux_aout;
|
||||
#endif
|
||||
#ifdef EXEC_ELF32
|
||||
extern struct emul emul_linux_elf32;
|
||||
#endif
|
||||
extern struct emul emul_linux;
|
||||
#endif
|
||||
|
||||
int writeback __P((struct frame *fp, int docachepush));
|
||||
@ -1037,7 +1032,7 @@ syscall(code, frame)
|
||||
struct frame frame;
|
||||
{
|
||||
caddr_t params;
|
||||
struct sysent *callp;
|
||||
struct const sysent *callp;
|
||||
struct proc *p;
|
||||
int error, opc, nsys;
|
||||
size_t argsize;
|
||||
@ -1127,14 +1122,7 @@ syscall(code, frame)
|
||||
callp += code;
|
||||
argsize = callp->sy_argsize;
|
||||
#ifdef COMPAT_LINUX
|
||||
if (0
|
||||
# ifdef EXEC_AOUT
|
||||
|| p->p_emul == &emul_linux_aout
|
||||
# endif
|
||||
# ifdef EXEC_ELF32
|
||||
|| p->p_emul == &emul_linux_elf32
|
||||
# endif
|
||||
) {
|
||||
if (p->p_emul == &emul_linux) {
|
||||
/*
|
||||
* Linux passes the args in d1-d5
|
||||
*/
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: aout_exec.c,v 1.3 2000/11/13 21:32:16 jdolecek Exp $ */
|
||||
/* $NetBSD: aout_exec.c,v 1.4 2000/11/21 00:37:52 jdolecek Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
@ -44,7 +44,6 @@
|
||||
#include <sys/exec.h>
|
||||
#include <sys/signalvar.h>
|
||||
|
||||
#include <compat/aout/aout_exec.h>
|
||||
#include <compat/aout/aout_syscall.h>
|
||||
|
||||
const char aout_emul_path[] = "/emul/aout";
|
||||
@ -67,18 +66,6 @@ struct emul emul_netbsd_aout = {
|
||||
#else
|
||||
NULL,
|
||||
#endif
|
||||
0,
|
||||
copyargs,
|
||||
setregs,
|
||||
sigcode,
|
||||
esigcode,
|
||||
};
|
||||
|
||||
int
|
||||
exec_aoutcompat_makecmds(p, epp)
|
||||
struct proc *p;
|
||||
struct exec_package *epp;
|
||||
{
|
||||
epp->ep_emul = &emul_netbsd_aout;
|
||||
return exec_aout_makecmds(p, epp);
|
||||
}
|
||||
|
@ -1,39 +0,0 @@
|
||||
/* $NetBSD: aout_exec.h,v 1.1 1999/02/11 09:41:34 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
int exec_aoutcompat_makecmds __P((struct proc *, struct exec_package *));
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: freebsd_exec.c,v 1.7 2000/11/13 21:32:17 jdolecek Exp $ */
|
||||
/* $NetBSD: freebsd_exec.c,v 1.8 2000/11/21 00:37:53 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993, 1994 Christopher G. Demetriou
|
||||
@ -56,8 +56,7 @@
|
||||
extern struct sysent freebsd_sysent[];
|
||||
extern const char * const freebsd_syscallnames[];
|
||||
|
||||
#ifdef EXEC_AOUT
|
||||
struct emul emul_freebsd_aout = {
|
||||
const struct emul emul_freebsd = {
|
||||
"freebsd",
|
||||
NULL,
|
||||
freebsd_sendsig,
|
||||
@ -65,42 +64,24 @@ struct emul emul_freebsd_aout = {
|
||||
FREEBSD_SYS_MAXSYSCALL,
|
||||
freebsd_sysent,
|
||||
freebsd_syscallnames,
|
||||
0,
|
||||
copyargs,
|
||||
freebsd_setregs,
|
||||
freebsd_sigcode,
|
||||
freebsd_esigcode,
|
||||
};
|
||||
#endif /* EXEC_AOUT */
|
||||
|
||||
#ifdef EXEC_ELF32
|
||||
|
||||
struct emul ELFNAMEEND(emul_freebsd) = {
|
||||
"freebsd",
|
||||
NULL,
|
||||
freebsd_sendsig,
|
||||
FREEBSD_SYS_syscall,
|
||||
FREEBSD_SYS_MAXSYSCALL,
|
||||
freebsd_sysent,
|
||||
freebsd_syscallnames,
|
||||
FREEBSD_ELF_AUX_ARGSIZ,
|
||||
ELFNAME(copyargs),
|
||||
freebsd_setregs,
|
||||
freebsd_sigcode,
|
||||
freebsd_esigcode,
|
||||
};
|
||||
|
||||
int
|
||||
ELFNAME2(freebsd,probe)(p, epp, eh, itp, pos)
|
||||
ELFNAME2(freebsd,probe)(p, epp, veh, itp, pos)
|
||||
struct proc *p;
|
||||
struct exec_package *epp;
|
||||
Elf_Ehdr *eh;
|
||||
void *veh;
|
||||
char *itp;
|
||||
Elf_Addr *pos;
|
||||
vaddr_t *pos;
|
||||
{
|
||||
int error;
|
||||
size_t i;
|
||||
size_t phsize;
|
||||
Elf_Ehdr *eh = (Elf_Ehdr *) veh;
|
||||
Elf_Phdr *ph;
|
||||
Elf_Phdr *ephp;
|
||||
Elf_Nhdr *np;
|
||||
@ -158,7 +139,6 @@ ELFNAME2(freebsd,probe)(p, epp, eh, itp, pos)
|
||||
return error;
|
||||
free((void *)bp, M_TEMP);
|
||||
}
|
||||
epp->ep_emul = &ELFNAMEEND(emul_freebsd);
|
||||
*pos = ELF_NO_ADDR;
|
||||
#ifdef DEBUG_FREEBSD_ELF
|
||||
printf("freebsd_elf32_probe: returning 0\n");
|
||||
@ -216,9 +196,7 @@ exec_freebsd_aout_makecmds(p, epp)
|
||||
error = exec_aout_prep_omagic(p, epp);
|
||||
break;
|
||||
}
|
||||
if (error == 0)
|
||||
epp->ep_emul = &emul_freebsd_aout;
|
||||
else
|
||||
if (error)
|
||||
kill_vmcmds(&epp->ep_vmcmds);
|
||||
|
||||
return error;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: freebsd_exec.h,v 1.5 1999/04/30 23:07:01 cgd Exp $ */
|
||||
/* $NetBSD: freebsd_exec.h,v 1.6 2000/11/21 00:37:53 jdolecek Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -100,17 +100,18 @@ int exec_freebsd_aout_makecmds __P((struct proc *, struct exec_package *));
|
||||
#endif /* EXEC_AOUT */
|
||||
|
||||
#ifdef EXEC_ELF32
|
||||
#define FREEBSD_ELF_AUX_ARGSIZ howmany(sizeof(AuxInfo) * 8, sizeof(char *))
|
||||
#define FREEBSD_ELF_AUX_ARGSIZ howmany(sizeof(Aux32Info) * 8, sizeof(char *))
|
||||
|
||||
#define FREEBSD_ELF_BRAND_STRING "FreeBSD"
|
||||
#define FREEBSD_ELF_INTERP_PREFIX_STRING "/usr/libexec/ld-elf.so"
|
||||
|
||||
int freebsd_elf32_probe __P((struct proc *, struct exec_package *, Elf32_Ehdr *,
|
||||
char *, Elf32_Addr *));
|
||||
int freebsd_elf32_probe __P((struct proc *, struct exec_package *, void *,
|
||||
char *, vaddr_t *));
|
||||
#endif /* EXEC_ELF32 */
|
||||
|
||||
void freebsd_setregs __P((struct proc *, struct exec_package *, u_long));
|
||||
|
||||
extern char freebsd_sigcode[], freebsd_esigcode[];
|
||||
extern const struct emul emul_freebsd;
|
||||
|
||||
#endif /* !_FREEBSD_EXEC_H */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: hpux_exec.c,v 1.17 2000/11/13 21:32:17 jdolecek Exp $ */
|
||||
/* $NetBSD: hpux_exec.c,v 1.18 2000/11/21 00:37:53 jdolecek Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
|
||||
@ -104,7 +104,7 @@ static int exec_hpux_prep_nmagic __P((struct proc *, struct exec_package *));
|
||||
static int exec_hpux_prep_zmagic __P((struct proc *, struct exec_package *));
|
||||
static int exec_hpux_prep_omagic __P((struct proc *, struct exec_package *));
|
||||
|
||||
struct emul emul_hpux = {
|
||||
const struct emul emul_hpux = {
|
||||
"hpux",
|
||||
native_to_hpux_errno,
|
||||
hpux_sendsig,
|
||||
@ -112,9 +112,6 @@ struct emul emul_hpux = {
|
||||
HPUX_SYS_MAXSYSCALL,
|
||||
hpux_sysent,
|
||||
hpux_syscallnames,
|
||||
0,
|
||||
copyargs,
|
||||
hpux_setregs,
|
||||
sigcode,
|
||||
esigcode,
|
||||
};
|
||||
@ -158,10 +155,7 @@ exec_hpux_makecmds(p, epp)
|
||||
break;
|
||||
}
|
||||
|
||||
if (error == 0) {
|
||||
/* set up our emulation information */
|
||||
epp->ep_emul = &emul_hpux;
|
||||
} else
|
||||
if (error != 0)
|
||||
kill_vmcmds(&epp->ep_vmcmds);
|
||||
|
||||
return (error);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ibcs2_exec.c,v 1.36 2000/11/13 21:32:17 jdolecek Exp $ */
|
||||
/* $NetBSD: ibcs2_exec.c,v 1.37 2000/11/21 00:37:53 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995, 1998 Scott Bartram
|
||||
@ -64,10 +64,6 @@
|
||||
#include <compat/ibcs2/ibcs2_syscall.h>
|
||||
|
||||
|
||||
#ifdef EXEC_ELF32
|
||||
#define IBCS2_ELF_AUX_ARGSIZ howmany(sizeof(AuxInfo) * 8, sizeof(char *))
|
||||
#endif
|
||||
|
||||
int exec_ibcs2_coff_prep_omagic __P((struct proc *, struct exec_package *,
|
||||
struct coff_filehdr *,
|
||||
struct coff_aouthdr *));
|
||||
@ -90,6 +86,8 @@ int coff_load_shlib __P((struct proc *, const char *, struct exec_package *));
|
||||
static int coff_find_section __P((struct proc *, struct vnode *,
|
||||
struct coff_filehdr *, struct coff_scnhdr *,
|
||||
int));
|
||||
static void ibcs2_e_proc_exec __P((struct proc *, struct exec_package *));
|
||||
|
||||
#ifdef EXEC_ELF32
|
||||
static int ibcs2_elf32_signature __P((struct proc *p, struct exec_package *,
|
||||
Elf32_Ehdr *));
|
||||
@ -108,7 +106,7 @@ int ibcs2_debug = 1;
|
||||
int ibcs2_debug = 0;
|
||||
#endif
|
||||
|
||||
struct emul emul_ibcs2_coff = {
|
||||
const struct emul emul_ibcs2 = {
|
||||
"ibcs2",
|
||||
native_to_ibcs2_errno,
|
||||
ibcs2_sendsig,
|
||||
@ -116,46 +114,13 @@ struct emul emul_ibcs2_coff = {
|
||||
IBCS2_SYS_MAXSYSCALL,
|
||||
ibcs2_sysent,
|
||||
ibcs2_syscallnames,
|
||||
0,
|
||||
copyargs,
|
||||
ibcs2_setregs,
|
||||
ibcs2_sigcode,
|
||||
ibcs2_esigcode,
|
||||
ibcs2_e_proc_exec,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
struct emul emul_ibcs2_xout = {
|
||||
"ibcs2",
|
||||
native_to_ibcs2_errno,
|
||||
ibcs2_sendsig,
|
||||
0,
|
||||
IBCS2_SYS_MAXSYSCALL,
|
||||
ibcs2_sysent,
|
||||
ibcs2_syscallnames,
|
||||
0,
|
||||
copyargs,
|
||||
ibcs2_setregs,
|
||||
ibcs2_sigcode,
|
||||
ibcs2_esigcode,
|
||||
};
|
||||
|
||||
#ifdef EXEC_ELF32
|
||||
struct emul emul_ibcs2_elf = {
|
||||
"ibcs2",
|
||||
native_to_ibcs2_errno,
|
||||
ibcs2_sendsig,
|
||||
0,
|
||||
IBCS2_SYS_MAXSYSCALL,
|
||||
ibcs2_sysent,
|
||||
ibcs2_syscallnames,
|
||||
IBCS2_ELF_AUX_ARGSIZ,
|
||||
elf32_copyargs,
|
||||
ibcs2_setregs,
|
||||
ibcs2_sigcode,
|
||||
ibcs2_esigcode,
|
||||
};
|
||||
#endif /* EXEC_ELF32 */
|
||||
|
||||
|
||||
/*
|
||||
* The SCO compiler adds the string "SCO" to the .notes section of all
|
||||
* binaries I've seen so far.
|
||||
@ -216,9 +181,9 @@ int
|
||||
ibcs2_elf32_probe(p, epp, eh, itp, pos)
|
||||
struct proc *p;
|
||||
struct exec_package *epp;
|
||||
Elf32_Ehdr *eh;
|
||||
void *eh;
|
||||
char *itp;
|
||||
Elf32_Addr *pos;
|
||||
vaddr_t *pos;
|
||||
{
|
||||
const char *bp;
|
||||
int error;
|
||||
@ -234,7 +199,6 @@ ibcs2_elf32_probe(p, epp, eh, itp, pos)
|
||||
return error;
|
||||
free((void *)bp, M_TEMP);
|
||||
}
|
||||
epp->ep_emul = &emul_ibcs2_elf;
|
||||
*pos = ELF32_NO_ADDR;
|
||||
return 0;
|
||||
}
|
||||
@ -286,9 +250,6 @@ exec_ibcs2_coff_makecmds(p, epp)
|
||||
return ENOEXEC;
|
||||
}
|
||||
|
||||
if (error == 0)
|
||||
epp->ep_emul = &emul_ibcs2_coff;
|
||||
|
||||
if (error)
|
||||
kill_vmcmds(&epp->ep_vmcmds);
|
||||
|
||||
@ -866,9 +827,6 @@ exec_ibcs2_xout_makecmds(p, epp)
|
||||
#endif
|
||||
error = exec_ibcs2_xout_prep_nmagic(p, epp, xp, xep);
|
||||
|
||||
if (error == 0)
|
||||
epp->ep_emul = &emul_ibcs2_xout;
|
||||
|
||||
if (error)
|
||||
kill_vmcmds(&epp->ep_vmcmds);
|
||||
|
||||
@ -1013,3 +971,19 @@ exec_ibcs2_xout_setup_stack(p, epp)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* This is exec process hook. Find out if this is x.out executable, if
|
||||
* yes, set flag appropriately, so that emul code which needs to adjust
|
||||
* behaviour accordingly can do so.
|
||||
*/
|
||||
static void
|
||||
ibcs2_e_proc_exec(p, epp)
|
||||
struct proc *p;
|
||||
struct exec_package *epp;
|
||||
{
|
||||
if (epp->ep_es->es_check == exec_ibcs2_xout_makecmds)
|
||||
p->p_emuldata = IBCS2_EXEC_XENIX;
|
||||
else
|
||||
p->p_emuldata = IBCS2_EXEC_OTHER;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ibcs2_exec.h,v 1.8 2000/06/21 05:45:18 matt Exp $ */
|
||||
/* $NetBSD: ibcs2_exec.h,v 1.9 2000/11/21 00:37:53 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995, 1998 Scott Bartram
|
||||
@ -176,13 +176,21 @@ struct xiter {
|
||||
long xi_offset; /* offset within segment to replicated data */
|
||||
};
|
||||
|
||||
extern const struct emul emul_ibcs2;
|
||||
|
||||
#define XOUT_HDR_SIZE (sizeof(struct xexec) + sizeof(struct xext))
|
||||
|
||||
int exec_ibcs2_xout_makecmds __P((struct proc *, struct exec_package *));
|
||||
|
||||
#ifdef EXEC_ELF32
|
||||
#define IBCS2_ELF_AUX_ARGSIZ howmany(sizeof(Aux32Info) * 8, sizeof(char *))
|
||||
|
||||
int ibcs2_elf32_probe __P((struct proc *, struct exec_package *,
|
||||
Elf32_Ehdr *, char *, Elf32_Addr *));
|
||||
void *, char *, vaddr_t *));
|
||||
#endif
|
||||
|
||||
/* following two are used for indication of executable type */
|
||||
#define IBCS2_EXEC_XENIX ((void *)0x01) /* XENIX x.out executable */
|
||||
#define IBCS2_EXEC_OTHER ((void *)0x02) /* something else */
|
||||
|
||||
#endif /* !_IBCS2_EXEC_H_ */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ibcs2_misc.c,v 1.52 2000/08/29 14:33:27 sommerfeld Exp $ */
|
||||
/* $NetBSD: ibcs2_misc.c,v 1.53 2000/11/21 00:37:53 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995, 1998 Scott Bartram
|
||||
@ -106,9 +106,7 @@
|
||||
#include <compat/ibcs2/ibcs2_utime.h>
|
||||
#include <compat/ibcs2/ibcs2_syscallargs.h>
|
||||
#include <compat/ibcs2/ibcs2_sysi86.h>
|
||||
|
||||
extern struct emul emul_ibcs2_coff, emul_ibcs2_xout, emul_ibcs2_elf;
|
||||
|
||||
#include <compat/ibcs2/ibcs2_exec.h>
|
||||
|
||||
int
|
||||
ibcs2_sys_ulimit(p, v, retval)
|
||||
@ -775,7 +773,7 @@ ibcs2_sys_time(p, v, retval)
|
||||
|
||||
microtime(&tv);
|
||||
*retval = tv.tv_sec;
|
||||
if (p->p_emul != &emul_ibcs2_xout && SCARG(uap, tp))
|
||||
if (p->p_emuldata == IBCS2_EXEC_XENIX && SCARG(uap, tp))
|
||||
return copyout((caddr_t)&tv.tv_sec, (caddr_t)SCARG(uap, tp),
|
||||
sizeof(ibcs2_time_t));
|
||||
else
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: linux_exec.h,v 1.3 2000/11/17 03:55:18 erh Exp $ */
|
||||
/* $NetBSD: linux_exec.h,v 1.4 2000/11/21 00:37:53 jdolecek Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
@ -45,7 +45,11 @@
|
||||
#define LINUX_GCC_SIGNATURE 1
|
||||
|
||||
#define LINUX_ELF_AUX_ARGSIZ \
|
||||
(howmany(ELF_AUX_ENTRIES * sizeof(AuxInfo), sizeof(Elf_Addr)))
|
||||
(howmany(ELF_AUX_ENTRIES * sizeof(Aux32Info), sizeof(Elf32_Addr)))
|
||||
#ifdef ELF32NAME
|
||||
#define LINUX_COPYARGS_FUNCTION ELF32NAME(copyargs)
|
||||
#else
|
||||
#define LINUX_COPYARGS_FUNCTION ELFNAME(copyargs)
|
||||
#endif
|
||||
|
||||
#endif /* !_I386_LINUX_EXEC_H */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: linux_exec.c,v 1.37 2000/06/29 02:40:38 mrg Exp $ */
|
||||
/* $NetBSD: linux_exec.c,v 1.38 2000/11/21 00:37:53 jdolecek Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1994, 1995, 1998 The NetBSD Foundation, Inc.
|
||||
@ -62,10 +62,15 @@
|
||||
|
||||
#include <compat/linux/linux_syscallargs.h>
|
||||
#include <compat/linux/linux_syscall.h>
|
||||
|
||||
#include <compat/linux/common/linux_misc.h>
|
||||
#include <compat/linux/common/linux_errno.h>
|
||||
|
||||
const char linux_emul_path[] = "/emul/linux";
|
||||
|
||||
extern struct sysent linux_sysent[];
|
||||
extern const char * const linux_syscallnames[];
|
||||
extern char linux_sigcode[], linux_esigcode[];
|
||||
|
||||
/*
|
||||
* Execve(2). Just check the alternate emulation path, and pass it on
|
||||
* to the NetBSD execve().
|
||||
@ -93,3 +98,18 @@ linux_sys_execve(p, v, retval)
|
||||
|
||||
return sys_execve(p, &ap, retval);
|
||||
}
|
||||
|
||||
/*
|
||||
* Emulation switch.
|
||||
*/
|
||||
const struct emul emul_linux = {
|
||||
"linux",
|
||||
native_to_linux_errno,
|
||||
linux_sendsig,
|
||||
LINUX_SYS_syscall,
|
||||
LINUX_SYS_MAXSYSCALL,
|
||||
linux_sysent,
|
||||
linux_syscallnames,
|
||||
linux_sigcode,
|
||||
linux_esigcode,
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: linux_exec.h,v 1.12 1998/12/15 19:31:39 itohy Exp $ */
|
||||
/* $NetBSD: linux_exec.h,v 1.13 2000/11/21 00:37:54 jdolecek Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
|
||||
@ -52,6 +52,7 @@
|
||||
|
||||
/* Defines for a.out executables */
|
||||
#define LINUX_AOUT_HDR_SIZE (sizeof (struct exec))
|
||||
#define LINUX_AOUT_AUX_ARGSIZ 2
|
||||
|
||||
#define LINUX_N_MAGIC(ep) ((ep)->a_midmag & 0xffff)
|
||||
#define LINUX_N_MACHTYPE(ep) (((ep)->a_midmag >> 16) & 0xff)
|
||||
@ -75,16 +76,20 @@
|
||||
|
||||
#ifdef _KERNEL
|
||||
__BEGIN_DECLS
|
||||
extern const struct emul emul_linux;
|
||||
|
||||
void linux_setregs __P((struct proc *, struct exec_package *, u_long));
|
||||
int exec_linux_aout_makecmds __P((struct proc *, struct exec_package *));
|
||||
void *linux_aout_copyargs __P((struct exec_package *,
|
||||
struct ps_strings *, void *, void *));
|
||||
|
||||
#ifdef EXEC_ELF32
|
||||
int linux_elf32_probe __P((struct proc *, struct exec_package *, Elf32_Ehdr *,
|
||||
char *, Elf32_Addr *));
|
||||
int linux_elf32_probe __P((struct proc *, struct exec_package *, void *,
|
||||
char *, vaddr_t *));
|
||||
#endif
|
||||
#ifdef EXEC_ELF64
|
||||
int linux_elf64_probe __P((struct proc *, struct exec_package *, Elf64_Ehdr *,
|
||||
char *, Elf64_Addr *));
|
||||
int linux_elf64_probe __P((struct proc *, struct exec_package *, void *,
|
||||
char *, vaddr_t *));
|
||||
#endif
|
||||
__END_DECLS
|
||||
#endif /* !_KERNEL */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: linux_exec_aout.c,v 1.41 2000/11/13 21:32:18 jdolecek Exp $ */
|
||||
/* $NetBSD: linux_exec_aout.c,v 1.42 2000/11/21 00:37:54 jdolecek Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
|
||||
@ -62,42 +62,23 @@
|
||||
#include <compat/linux/common/linux_util.h>
|
||||
#include <compat/linux/common/linux_exec.h>
|
||||
#include <compat/linux/common/linux_machdep.h>
|
||||
#include <compat/linux/common/linux_errno.h>
|
||||
|
||||
#include <compat/linux/linux_syscallargs.h>
|
||||
#include <compat/linux/linux_syscall.h>
|
||||
|
||||
|
||||
static void *linux_aout_copyargs __P((struct exec_package *,
|
||||
void *linux_aout_copyargs __P((struct exec_package *,
|
||||
struct ps_strings *, void *, void *));
|
||||
|
||||
#define LINUX_AOUT_AUX_ARGSIZ 2
|
||||
static int exec_linux_aout_prep_zmagic __P((struct proc *,
|
||||
struct exec_package *));
|
||||
static int exec_linux_aout_prep_nmagic __P((struct proc *,
|
||||
struct exec_package *));
|
||||
static int exec_linux_aout_prep_omagic __P((struct proc *,
|
||||
struct exec_package *));
|
||||
static int exec_linux_aout_prep_qmagic __P((struct proc *,
|
||||
struct exec_package *));
|
||||
|
||||
extern char linux_sigcode[], linux_esigcode[];
|
||||
extern struct sysent linux_sysent[];
|
||||
extern const char * const linux_syscallnames[];
|
||||
|
||||
int exec_linux_aout_prep_zmagic __P((struct proc *, struct exec_package *));
|
||||
int exec_linux_aout_prep_nmagic __P((struct proc *, struct exec_package *));
|
||||
int exec_linux_aout_prep_omagic __P((struct proc *, struct exec_package *));
|
||||
int exec_linux_aout_prep_qmagic __P((struct proc *, struct exec_package *));
|
||||
|
||||
struct emul emul_linux_aout = {
|
||||
"linux",
|
||||
native_to_linux_errno,
|
||||
linux_sendsig,
|
||||
LINUX_SYS_syscall,
|
||||
LINUX_SYS_MAXSYSCALL,
|
||||
linux_sysent,
|
||||
linux_syscallnames,
|
||||
LINUX_AOUT_AUX_ARGSIZ,
|
||||
linux_aout_copyargs,
|
||||
linux_setregs,
|
||||
linux_sigcode,
|
||||
linux_esigcode,
|
||||
};
|
||||
|
||||
static void *
|
||||
void *
|
||||
linux_aout_copyargs(pack, arginfo, stack, argp)
|
||||
struct exec_package *pack;
|
||||
struct ps_strings *arginfo;
|
||||
@ -180,8 +161,6 @@ exec_linux_aout_makecmds(p, epp)
|
||||
error = exec_linux_aout_prep_omagic(p, epp);
|
||||
break;
|
||||
}
|
||||
if (error == 0)
|
||||
epp->ep_emul = &emul_linux_aout;
|
||||
return error;
|
||||
}
|
||||
|
||||
@ -191,7 +170,7 @@ exec_linux_aout_makecmds(p, epp)
|
||||
* as an NMAGIC here. XXX
|
||||
*/
|
||||
|
||||
int
|
||||
static int
|
||||
exec_linux_aout_prep_zmagic(p, epp)
|
||||
struct proc *p;
|
||||
struct exec_package *epp;
|
||||
@ -227,7 +206,7 @@ exec_linux_aout_prep_zmagic(p, epp)
|
||||
* Not different from the normal stuff.
|
||||
*/
|
||||
|
||||
int
|
||||
static int
|
||||
exec_linux_aout_prep_nmagic(p, epp)
|
||||
struct proc *p;
|
||||
struct exec_package *epp;
|
||||
@ -266,7 +245,7 @@ exec_linux_aout_prep_nmagic(p, epp)
|
||||
* Business as usual.
|
||||
*/
|
||||
|
||||
int
|
||||
static int
|
||||
exec_linux_aout_prep_omagic(p, epp)
|
||||
struct proc *p;
|
||||
struct exec_package *epp;
|
||||
@ -305,7 +284,7 @@ exec_linux_aout_prep_omagic(p, epp)
|
||||
return exec_aout_setup_stack(p, epp);
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
exec_linux_aout_prep_qmagic(p, epp)
|
||||
struct proc *p;
|
||||
struct exec_package *epp;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: linux_exec_elf32.c,v 1.47 2000/11/17 03:55:18 erh Exp $ */
|
||||
/* $NetBSD: linux_exec_elf32.c,v 1.48 2000/11/21 00:37:54 jdolecek Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
|
||||
@ -66,7 +66,6 @@
|
||||
#include <compat/linux/common/linux_util.h>
|
||||
#include <compat/linux/common/linux_exec.h>
|
||||
#include <compat/linux/common/linux_machdep.h>
|
||||
#include <compat/linux/common/linux_errno.h>
|
||||
|
||||
#include <compat/linux/linux_syscallargs.h>
|
||||
#include <compat/linux/linux_syscall.h>
|
||||
@ -78,25 +77,6 @@ static int ELFNAME2(linux,gcc_signature) __P((struct proc *p,
|
||||
struct exec_package *, Elf_Ehdr *));
|
||||
#endif
|
||||
|
||||
extern char linux_sigcode[], linux_esigcode[];
|
||||
extern struct sysent linux_sysent[];
|
||||
extern const char * const linux_syscallnames[];
|
||||
|
||||
struct emul ELFNAMEEND(emul_linux) = {
|
||||
"linux",
|
||||
native_to_linux_errno,
|
||||
linux_sendsig,
|
||||
LINUX_SYS_syscall,
|
||||
LINUX_SYS_MAXSYSCALL,
|
||||
linux_sysent,
|
||||
linux_syscallnames,
|
||||
LINUX_ELF_AUX_ARGSIZ,
|
||||
LINUX_COPYARGS_FUNCTION,
|
||||
linux_setregs,
|
||||
linux_sigcode,
|
||||
linux_esigcode,
|
||||
};
|
||||
|
||||
#ifdef LINUX_GCC_SIGNATURE
|
||||
/*
|
||||
* Take advantage of the fact that all the linux binaries are compiled
|
||||
@ -207,7 +187,7 @@ ELFNAME2(linux,signature)(p, epp, eh)
|
||||
goto out3;
|
||||
}
|
||||
#ifdef DEBUG_LINUX
|
||||
printf("linux_signature: interp=%s\n", notep);
|
||||
printf("linux_signature: interp=%s\n", (char *)notep);
|
||||
#endif
|
||||
if (strncmp(&((char *)notep)[8], "linux", 5) == 0 ||
|
||||
strncmp((char *)notep, "/lib/ld.so.", 11) == 0) {
|
||||
@ -268,9 +248,9 @@ int
|
||||
ELFNAME2(linux,probe)(p, epp, eh, itp, pos)
|
||||
struct proc *p;
|
||||
struct exec_package *epp;
|
||||
Elf_Ehdr *eh;
|
||||
void *eh;
|
||||
char *itp;
|
||||
Elf_Addr *pos;
|
||||
vaddr_t *pos;
|
||||
{
|
||||
const char *bp;
|
||||
int error;
|
||||
@ -291,7 +271,6 @@ ELFNAME2(linux,probe)(p, epp, eh, itp, pos)
|
||||
return error;
|
||||
free((void *)bp, M_TEMP);
|
||||
}
|
||||
epp->ep_emul = &ELFNAMEEND(emul_linux);
|
||||
*pos = ELF_NO_ADDR;
|
||||
#ifdef DEBUG_LINUX
|
||||
printf("linux_probe: returning 0\n");
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: m68k4k_exec.c,v 1.5 2000/06/28 15:39:29 mrg Exp $ */
|
||||
/* $NetBSD: m68k4k_exec.c,v 1.6 2000/11/21 00:37:54 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993, 1994 Christopher G. Demetriou
|
||||
@ -44,8 +44,6 @@
|
||||
#error YOU GOTTA BE KIDDING!
|
||||
#endif
|
||||
|
||||
#include "opt_compat_aout.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/proc.h>
|
||||
@ -56,10 +54,6 @@
|
||||
|
||||
#include <compat/m68k4k/m68k4k_exec.h>
|
||||
|
||||
#if defined(COMPAT_AOUT)
|
||||
extern struct emul emul_netbsd_aout;
|
||||
#endif
|
||||
|
||||
int exec_m68k4k_prep_zmagic __P((struct proc *, struct exec_package *));
|
||||
int exec_m68k4k_prep_nmagic __P((struct proc *, struct exec_package *));
|
||||
int exec_m68k4k_prep_omagic __P((struct proc *, struct exec_package *));
|
||||
@ -116,10 +110,6 @@ exec_m68k4k_makecmds(p, epp)
|
||||
|
||||
if (error)
|
||||
kill_vmcmds(&epp->ep_vmcmds);
|
||||
#if defined(COMPAT_AOUT)
|
||||
else
|
||||
epp->ep_emul = &emul_netbsd_aout;
|
||||
#endif
|
||||
|
||||
return error;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: netbsd32_exec.c,v 1.22 2000/11/13 21:32:18 jdolecek Exp $ */
|
||||
/* $NetBSD: netbsd32_exec.c,v 1.23 2000/11/21 00:37:54 jdolecek Exp $ */
|
||||
/* from: NetBSD: exec_aout.c,v 1.15 1996/09/26 23:34:46 cgd Exp */
|
||||
|
||||
/*
|
||||
@ -75,8 +75,7 @@ static int netbsd32_exec_aout_prep_nmagic __P((struct proc *,
|
||||
static int netbsd32_exec_aout_prep_omagic __P((struct proc *,
|
||||
struct exec_package *));
|
||||
|
||||
#ifdef EXEC_AOUT
|
||||
struct emul emul_netbsd32 = {
|
||||
const struct emul emul_netbsd32 = {
|
||||
"netbsd32",
|
||||
NULL,
|
||||
netbsd32_sendsig,
|
||||
@ -88,34 +87,11 @@ struct emul emul_netbsd32 = {
|
||||
#else
|
||||
NULL,
|
||||
#endif
|
||||
0,
|
||||
netbsd32_copyargs,
|
||||
netbsd32_setregs,
|
||||
netbsd32_sigcode,
|
||||
netbsd32_esigcode,
|
||||
};
|
||||
#endif /* EXEC_AOUT */
|
||||
|
||||
#ifdef EXEC_ELF32
|
||||
/* Elf emul structure */
|
||||
struct emul ELFNAMEEND(emul_netbsd32) = {
|
||||
"netbsd32",
|
||||
NULL,
|
||||
netbsd32_sendsig,
|
||||
netbsd32_SYS_syscall,
|
||||
netbsd32_SYS_MAXSYSCALL,
|
||||
netbsd32_sysent,
|
||||
#ifdef SYSCALL_DEBUG
|
||||
netbsd32_syscallnames,
|
||||
#else
|
||||
NULL,
|
||||
#endif
|
||||
howmany(ELF_AUX_ENTRIES * sizeof(AuxInfo), sizeof(Elf_Addr)),
|
||||
netbsd32_elf32_copyargs,
|
||||
netbsd32_setregs,
|
||||
netbsd32_sigcode,
|
||||
netbsd32_esigcode,
|
||||
};
|
||||
|
||||
extern int ELFNAME2(netbsd,signature) __P((struct proc *, struct exec_package *,
|
||||
Elf_Ehdr *));
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: netbsd32_exec.h,v 1.4 1999/12/30 15:40:45 eeh Exp $ */
|
||||
/* $NetBSD: netbsd32_exec.h,v 1.5 2000/11/21 00:37:54 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998 Matthew R. Green
|
||||
@ -54,8 +54,8 @@ struct netbsd32_exec {
|
||||
int exec_netbsd32_makecmds __P((struct proc *, struct exec_package *));
|
||||
#endif
|
||||
#ifdef EXEC_ELF32
|
||||
int netbsd32_elf32_probe __P((struct proc *, struct exec_package *, Elf32_Ehdr *,
|
||||
char *, Elf32_Addr *));
|
||||
int netbsd32_elf32_probe __P((struct proc *, struct exec_package *, void *,
|
||||
char *, vaddr_t *));
|
||||
#endif /* EXEC_ELF32 */
|
||||
|
||||
#endif /* !_NETBSD32_EXEC_H_ */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: osf1_exec.c,v 1.11 2000/11/13 21:32:18 jdolecek Exp $ */
|
||||
/* $NetBSD: osf1_exec.c,v 1.12 2000/11/21 00:37:54 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
|
||||
@ -49,10 +49,6 @@
|
||||
#include <compat/osf1/osf1_util.h>
|
||||
#include <compat/osf1/osf1_cvt.h>
|
||||
|
||||
/* XXX BELONGS IN A 'PUBLIC' HEADER */
|
||||
int osf1_exec_ecoff_hook(struct proc *p, struct exec_package *epp);
|
||||
|
||||
|
||||
struct osf1_exec_emul_arg {
|
||||
int flags;
|
||||
#define OSF1_EXEC_EMUL_FLAGS_HAVE_LOADER 0x01
|
||||
@ -66,15 +62,11 @@ static void *osf1_copyargs(struct exec_package *pack,
|
||||
|
||||
static int osf1_exec_ecoff_dynamic(struct proc *p, struct exec_package *epp);
|
||||
|
||||
#define MAX_AUX_ENTRIES 4 /* max we'll ever push (right now) */
|
||||
|
||||
extern struct sysent osf1_sysent[];
|
||||
extern const char * const osf1_syscallnames[];
|
||||
extern void cpu_exec_ecoff_setregs __P((struct proc *, struct exec_package *,
|
||||
u_long));
|
||||
extern char osf1_sigcode[], osf1_esigcode[];
|
||||
|
||||
struct emul emul_osf1 = {
|
||||
const struct emul emul_osf1 = {
|
||||
"osf1",
|
||||
(int *)osf1_errno_rxlist,
|
||||
sendsig,
|
||||
@ -82,23 +74,20 @@ struct emul emul_osf1 = {
|
||||
OSF1_SYS_MAXSYSCALL,
|
||||
osf1_sysent,
|
||||
osf1_syscallnames,
|
||||
howmany(MAX_AUX_ENTRIES * sizeof (struct osf1_auxv) +
|
||||
2 * (MAXPATHLEN + 1), sizeof (char *)), /* exec & loader names */
|
||||
osf1_copyargs,
|
||||
cpu_exec_ecoff_setregs,
|
||||
osf1_sigcode,
|
||||
osf1_esigcode,
|
||||
};
|
||||
|
||||
int
|
||||
osf1_exec_ecoff_hook(struct proc *p, struct exec_package *epp)
|
||||
osf1_exec_ecoff_probe(struct proc *p, struct exec_package *epp)
|
||||
{
|
||||
struct ecoff_exechdr *execp = (struct ecoff_exechdr *)epp->ep_hdr;
|
||||
struct osf1_exec_emul_arg *emul_arg;
|
||||
int error;
|
||||
|
||||
/* if we're here and we're exec-able at all, we're an OSF/1 binary */
|
||||
epp->ep_emul = &emul_osf1;
|
||||
/* check if the binary is osf1 ecoff */
|
||||
if (execp->f.f_magic != ECOFF_MAGIC_ALPHA)
|
||||
return ENOEXEC;
|
||||
|
||||
/* set up the exec package emul arg as appropriate */
|
||||
emul_arg = malloc(sizeof *emul_arg, M_TEMP, M_WAITOK);
|
||||
@ -113,7 +102,7 @@ osf1_exec_ecoff_hook(struct proc *p, struct exec_package *epp)
|
||||
MAXPATHLEN + 1, NULL);
|
||||
#ifdef DIAGNOSTIC
|
||||
if (error != 0)
|
||||
panic("osf1_exec_ecoff_hook: copyinstr failed");
|
||||
panic("osf1_exec_ecoff_probe: copyinstr failed");
|
||||
#endif
|
||||
|
||||
/* do any special object file handling */
|
||||
|
41
sys/compat/osf1/osf1_exec.h
Normal file
41
sys/compat/osf1/osf1_exec.h
Normal file
@ -0,0 +1,41 @@
|
||||
/* $NetBSD: osf1_exec.h,v 1.1 2000/11/21 00:37:54 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2000 The NetBSD foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _OSF1_EXEC_H
|
||||
#define _OSF1_EXEC_H
|
||||
#define OSF1_MAX_AUX_ENTRIES 4 /* max we'll ever push (right now) */
|
||||
|
||||
void cpu_exec_ecoff_setregs __P((struct proc *, struct exec_package *, u_long));
|
||||
int osf1_exec_ecoff_probe __P((struct proc *, struct exec_package *));
|
||||
|
||||
#endif /* OSF1_EXEC_H */
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pecoff_exec.c,v 1.3 2000/06/28 15:39:34 mrg Exp $ */
|
||||
/* $NetBSD: pecoff_exec.c,v 1.4 2000/11/21 00:37:55 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2000 Masaru OKI
|
||||
@ -56,9 +56,6 @@
|
||||
#include <compat/pecoff/pecoff_exec.h>
|
||||
#include <compat/pecoff/pecoff_util.h>
|
||||
|
||||
void * pecoff_copyargs __P((struct exec_package *pack,
|
||||
struct ps_strings *arginfo,
|
||||
void *stack, void *argp));
|
||||
int pecoff_signature __P((struct proc *p, struct vnode *vp,
|
||||
struct pecoff_dos_filehdr *dp));
|
||||
int pecoff_load_file __P((struct proc *p, struct exec_package *epp,
|
||||
@ -87,7 +84,12 @@ int pecoff_read_from __P((struct proc *p, struct vnode *vp, int pos,
|
||||
const char pecoff_emul_path[] = "/emul/pecoff";
|
||||
extern char sigcode[], esigcode[];
|
||||
|
||||
struct emul emul_pecoff = {
|
||||
#if 0
|
||||
/*
|
||||
* For now, we use just emul_netbsd for pecoff binaries. This may change
|
||||
* later.
|
||||
*/
|
||||
const struct emul emul_pecoff = {
|
||||
"pecoff",
|
||||
0,
|
||||
sendsig,
|
||||
@ -99,12 +101,10 @@ struct emul emul_pecoff = {
|
||||
#else
|
||||
0,
|
||||
#endif
|
||||
howmany(sizeof(struct pecoff_args), sizeof(char *)),
|
||||
pecoff_copyargs,
|
||||
setregs,
|
||||
sigcode,
|
||||
esigcode,
|
||||
};
|
||||
#endif /* 0 */
|
||||
|
||||
|
||||
void *
|
||||
@ -358,9 +358,7 @@ exec_pecoff_makecmds(p, epp)
|
||||
}
|
||||
error = exec_pecoff_coff_makecmds(p, epp, fp, peofs);
|
||||
|
||||
if (error == 0)
|
||||
epp->ep_emul = &emul_pecoff;
|
||||
else
|
||||
if (error != 0)
|
||||
kill_vmcmds(&epp->ep_vmcmds);
|
||||
|
||||
free(fp, M_TEMP);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pecoff_exec.h,v 1.1 2000/06/09 22:38:56 oki Exp $ */
|
||||
/* $NetBSD: pecoff_exec.h,v 1.2 2000/11/21 00:37:55 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2000 Masaru OKI
|
||||
@ -103,7 +103,11 @@ struct pecoff_args {
|
||||
u_long a_ldexport;
|
||||
};
|
||||
|
||||
extern const struct emul emul_pecoff;
|
||||
|
||||
struct exec_package;
|
||||
int exec_pecoff_makecmds __P((struct proc *, struct exec_package *));
|
||||
void * pecoff_copyargs __P((struct exec_package *pack,
|
||||
struct ps_strings *arginfo, void *stack, void *argp));
|
||||
|
||||
#endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: sunos_exec.c,v 1.21 2000/11/13 21:32:19 jdolecek Exp $ */
|
||||
/* $NetBSD: sunos_exec.c,v 1.22 2000/11/21 00:37:55 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993 Theo de Raadt
|
||||
@ -83,9 +83,6 @@ struct emul emul_sunos = {
|
||||
#else
|
||||
NULL,
|
||||
#endif
|
||||
0,
|
||||
copyargs,
|
||||
setregs,
|
||||
sunos_sigcode,
|
||||
sunos_esigcode,
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: svr4_exec.c,v 1.33 2000/11/13 21:32:19 jdolecek Exp $ */
|
||||
/* $NetBSD: svr4_exec.c,v 1.34 2000/11/21 00:37:55 jdolecek Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1994 The NetBSD Foundation, Inc.
|
||||
@ -60,15 +60,12 @@
|
||||
#include <compat/svr4/svr4_errno.h>
|
||||
#include <compat/svr4/svr4_signal.h>
|
||||
|
||||
static void *svr4_copyargs __P((struct exec_package *, struct ps_strings *,
|
||||
void *, void *));
|
||||
|
||||
const char svr4_emul_path[] = "/emul/svr4";
|
||||
extern char svr4_sigcode[], svr4_esigcode[];
|
||||
extern struct sysent svr4_sysent[];
|
||||
extern const char * const svr4_syscallnames[];
|
||||
|
||||
struct emul emul_svr4 = {
|
||||
const struct emul emul_svr4 = {
|
||||
"svr4",
|
||||
native_to_svr4_errno,
|
||||
svr4_sendsig,
|
||||
@ -76,14 +73,11 @@ struct emul emul_svr4 = {
|
||||
SVR4_SYS_MAXSYSCALL,
|
||||
svr4_sysent,
|
||||
svr4_syscallnames,
|
||||
SVR4_AUX_ARGSIZ,
|
||||
svr4_copyargs,
|
||||
svr4_setregs,
|
||||
svr4_sigcode,
|
||||
svr4_esigcode,
|
||||
};
|
||||
|
||||
static void *
|
||||
void *
|
||||
svr4_copyargs(pack, arginfo, stack, argp)
|
||||
struct exec_package *pack;
|
||||
struct ps_strings *arginfo;
|
||||
@ -120,9 +114,9 @@ int
|
||||
svr4_elf32_probe(p, epp, eh, itp, pos)
|
||||
struct proc *p;
|
||||
struct exec_package *epp;
|
||||
Elf32_Ehdr *eh;
|
||||
void *eh;
|
||||
char *itp;
|
||||
Elf32_Addr *pos;
|
||||
vaddr_t *pos;
|
||||
{
|
||||
const char *bp;
|
||||
int error;
|
||||
@ -135,7 +129,6 @@ svr4_elf32_probe(p, epp, eh, itp, pos)
|
||||
return error;
|
||||
free((void *)bp, M_TEMP);
|
||||
}
|
||||
epp->ep_emul = &emul_svr4;
|
||||
*pos = SVR4_INTERP_ADDR;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: svr4_exec.h,v 1.15 1999/08/22 13:11:38 kleink Exp $ */
|
||||
/* $NetBSD: svr4_exec.h,v 1.16 2000/11/21 00:37:55 jdolecek Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1994 The NetBSD Foundation, Inc.
|
||||
@ -40,11 +40,14 @@
|
||||
#define _SVR4_EXEC_H_
|
||||
|
||||
#ifdef SVR4_COMPAT_SOLARIS2
|
||||
# define SVR4_AUX_ARGSIZ howmany(sizeof(AuxInfo) * 12, sizeof(char *))
|
||||
# define SVR4_AUX_ARGSIZ howmany(sizeof(Aux32Info) * 12, sizeof(char *))
|
||||
#else
|
||||
# define SVR4_AUX_ARGSIZ howmany(sizeof(AuxInfo) * 8, sizeof(char *))
|
||||
# define SVR4_AUX_ARGSIZ howmany(sizeof(Aux32Info) * 8, sizeof(char *))
|
||||
#endif
|
||||
|
||||
void *svr4_copyargs __P((struct exec_package *, struct ps_strings *,
|
||||
void *, void *));
|
||||
|
||||
/*
|
||||
* The following is horrible; there must be a better way. I need to
|
||||
* play with brk(2) a bit more.
|
||||
@ -78,8 +81,10 @@
|
||||
# define SVR4_INTERP_ADDR ELFDEFNNAME(NO_ADDR)
|
||||
#endif
|
||||
|
||||
extern const struct emul emul_svr4;
|
||||
|
||||
void svr4_setregs __P((struct proc *, struct exec_package *, u_long));
|
||||
int svr4_elf32_probe __P((struct proc *, struct exec_package *, Elf32_Ehdr *,
|
||||
char *, Elf32_Addr *));
|
||||
int svr4_elf32_probe __P((struct proc *, struct exec_package *, void *,
|
||||
char *, vaddr_t *));
|
||||
|
||||
#endif /* !_SVR4_EXEC_H_ */
|
||||
|
37
sys/compat/ultrix/ultrix_exec.h
Normal file
37
sys/compat/ultrix/ultrix_exec.h
Normal file
@ -0,0 +1,37 @@
|
||||
/* $NetBSD: ultrix_exec.h,v 1.1 2000/11/21 00:37:55 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
extern const struct emul emul_ultrix;
|
||||
|
||||
int ultrix_exec_ecoff_probe __P((struct proc *, struct exec_package *));
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ultrix_misc.c,v 1.60 2000/11/19 12:47:52 simonb Exp $ */
|
||||
/* $NetBSD: ultrix_misc.c,v 1.61 2000/11/21 00:37:55 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995, 1997 Jonathan Stone (hereinafter referred to as the author)
|
||||
@ -81,6 +81,7 @@
|
||||
|
||||
#include "opt_nfsserver.h"
|
||||
#include "opt_sysv.h"
|
||||
#include "opt_execfmt.h"
|
||||
|
||||
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
||||
|
||||
@ -137,13 +138,19 @@
|
||||
|
||||
#include <compat/ultrix/ultrix_flock.h>
|
||||
|
||||
#ifdef EXEC_ECOFF
|
||||
#include <sys/exec_ecoff.h>
|
||||
#include <compat/ultrix/ultrix_exec.h>
|
||||
#endif
|
||||
|
||||
static int ultrix_to_bsd_flock __P((struct ultrix_flock *, struct flock *));
|
||||
static void bsd_to_ultrix_flock __P((struct flock *, struct ultrix_flock *));
|
||||
|
||||
extern struct sysent ultrix_sysent[];
|
||||
extern const char * const ultrix_syscallnames[];
|
||||
|
||||
|
||||
#if 0
|
||||
/* XXX what executable format does Ultrix/vax use ? */
|
||||
/*
|
||||
* Select the appropriate setregs callback for the target architecture.
|
||||
*/
|
||||
@ -155,13 +162,12 @@ extern const char * const ultrix_syscallnames[];
|
||||
#ifdef __vax__
|
||||
#define ULTRIX_EXEC_SETREGS setregs
|
||||
#endif /* vax */
|
||||
#endif
|
||||
|
||||
|
||||
extern void ULTRIX_EXEC_SETREGS __P((struct proc *, struct exec_package *,
|
||||
u_long));
|
||||
extern char ultrix_sigcode[], ultrix_esigcode[];
|
||||
|
||||
struct emul emul_ultrix = {
|
||||
const struct emul emul_ultrix = {
|
||||
"ultrix",
|
||||
NULL,
|
||||
sendsig,
|
||||
@ -169,9 +175,6 @@ struct emul emul_ultrix = {
|
||||
ULTRIX_SYS_MAXSYSCALL,
|
||||
ultrix_sysent,
|
||||
ultrix_syscallnames,
|
||||
0,
|
||||
copyargs,
|
||||
ULTRIX_EXEC_SETREGS,
|
||||
ultrix_sigcode,
|
||||
ultrix_esigcode,
|
||||
};
|
||||
@ -906,3 +909,21 @@ ultrix_sys_fcntl(p, v, retval)
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
||||
#ifdef EXEC_ECOFF
|
||||
/*
|
||||
* cpu_exec_ecoff_probe():
|
||||
* cpu-dependent ECOFF format hook for execve().
|
||||
*
|
||||
* Do any machine-dependent diddling of the exec package when doing ECOFF.
|
||||
*
|
||||
*/
|
||||
int
|
||||
ultrix_exec_ecoff_probe(p, epp)
|
||||
struct proc *p;
|
||||
struct exec_package *epp;
|
||||
{
|
||||
/* XXX should add some check here */
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: exec_conf.c,v 1.43 2000/06/09 22:38:57 oki Exp $ */
|
||||
/* $NetBSD: exec_conf.c,v 1.44 2000/11/21 00:37:55 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993, 1994 Christopher G. Demetriou
|
||||
@ -42,6 +42,8 @@
|
||||
#include "opt_compat_aout.h"
|
||||
#include "opt_compat_vax1k.h"
|
||||
#include "opt_compat_pecoff.h"
|
||||
#include "opt_compat_osf1.h"
|
||||
#include "opt_compat_ultrix.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/exec.h>
|
||||
@ -64,7 +66,19 @@
|
||||
|
||||
#if defined(EXEC_ELF32) || defined(EXEC_ELF64)
|
||||
#include <sys/exec_elf.h>
|
||||
#define CONCAT(x,y) __CONCAT(x,y)
|
||||
#define ELF32NAME(x) CONCAT(elf,CONCAT(32,CONCAT(_,x)))
|
||||
#define ELF32NAME2(x,y) CONCAT(x,CONCAT(_elf32_,y))
|
||||
#define ELF64NAME(x) CONCAT(elf,CONCAT(64,CONCAT(_,x)))
|
||||
#define ELF64NAME2(x,y) CONCAT(x,CONCAT(_elf64_,y))
|
||||
#ifdef EXEC_ELF32
|
||||
int ELF32NAME2(netbsd,probe)(struct proc *, struct exec_package *,
|
||||
void *, char *, vaddr_t *);
|
||||
#else /* EXEC_ELF64 */
|
||||
int ELF64NAME2(netbsd,probe)(struct proc *, struct exec_package *,
|
||||
void *, char *, vaddr_t *);
|
||||
#endif
|
||||
#endif /* ELF32 || ELF64 */
|
||||
|
||||
#ifdef COMPAT_SUNOS
|
||||
#include <compat/sunos/sunos_exec.h>
|
||||
@ -77,6 +91,7 @@
|
||||
#ifdef COMPAT_IBCS2
|
||||
#include <sys/exec_coff.h>
|
||||
#include <compat/ibcs2/ibcs2_exec.h>
|
||||
#include <machine/ibcs2_machdep.h>
|
||||
#endif
|
||||
|
||||
#ifdef COMPAT_LINUX
|
||||
@ -103,73 +118,188 @@
|
||||
#include <compat/vax1k/vax1k_exec.h>
|
||||
#endif
|
||||
|
||||
#ifdef COMPAT_AOUT
|
||||
#include <compat/aout/aout_exec.h>
|
||||
#endif
|
||||
|
||||
#ifdef COMPAT_PECOFF
|
||||
#include <sys/exec_coff.h>
|
||||
#include <compat/pecoff/pecoff_exec.h>
|
||||
#endif
|
||||
|
||||
struct execsw execsw[] = {
|
||||
#ifdef LKM
|
||||
{ 0, NULL, }, /* entries for LKMs */
|
||||
{ 0, NULL, },
|
||||
{ 0, NULL, },
|
||||
{ 0, NULL, },
|
||||
{ 0, NULL, },
|
||||
#ifdef COMPAT_OSF1
|
||||
#include <compat/osf1/osf1_exec.h>
|
||||
#endif
|
||||
|
||||
#ifdef COMPAT_ULTRIX
|
||||
#include <compat/ultrix/ultrix_exec.h>
|
||||
#endif
|
||||
|
||||
extern const struct emul emul_netbsd;
|
||||
# ifdef COMPAT_AOUT
|
||||
extern const struct emul emul_netbsd_aout;
|
||||
#endif
|
||||
|
||||
const struct execsw execsw[] = {
|
||||
#ifdef EXEC_SCRIPT
|
||||
{ MAXINTERP, exec_script_makecmds, }, /* shell scripts */
|
||||
{ MAXINTERP, exec_script_makecmds, }, /* shell scripts */
|
||||
#endif
|
||||
#ifdef EXEC_AOUT
|
||||
#ifdef COMPAT_NETBSD32
|
||||
{ sizeof(struct netbsd32_exec), exec_netbsd32_makecmds, }, /* sparc 32 bit */
|
||||
{ sizeof(struct netbsd32_exec), exec_netbsd32_makecmds, { NULL },
|
||||
&emul_netbsd32, 0,
|
||||
0, netbsd32_copyargs, netbsd32_setregs }, /* sparc 32 bit */
|
||||
#endif
|
||||
# ifdef COMPAT_AOUT
|
||||
{ sizeof(struct exec), exec_aoutcompat_makecmds, },/* compat a.out */
|
||||
# else
|
||||
{ sizeof(struct exec), exec_aout_makecmds, }, /* a.out binaries */
|
||||
# endif
|
||||
{ sizeof(struct exec), exec_aout_makecmds, { NULL },
|
||||
#ifdef COMPAT_AOUT
|
||||
&emul_netbsd_aout,
|
||||
#else
|
||||
&emul_netbsd,
|
||||
#endif /* COMPAT_AOUT */
|
||||
0,
|
||||
0, copyargs, setregs }, /* a.out binaries */
|
||||
#endif
|
||||
#ifdef EXEC_COFF
|
||||
{ COFF_HDR_SIZE, exec_coff_makecmds, }, /* coff binaries */
|
||||
{ COFF_HDR_SIZE, exec_coff_makecmds, { NULL },
|
||||
&emul_netbsd, 0,
|
||||
0, copyargs, setregs }, /* coff binaries */
|
||||
#endif
|
||||
#ifdef EXEC_ECOFF
|
||||
{ ECOFF_HDR_SIZE, exec_ecoff_makecmds, }, /* ecoff binaries */
|
||||
#ifdef COMPAT_OSF1
|
||||
{ ECOFF_HDR_SIZE, exec_ecoff_makecmds,
|
||||
{ ecoff_probe_func: osf1_exec_ecoff_probe },
|
||||
&emul_osf1, 0,
|
||||
howmany(OSF1_MAX_AUX_ENTRIES * sizeof (struct osf1_auxv) +
|
||||
2 * (MAXPATHLEN + 1), sizeof (char *)), /* exec & loader names */
|
||||
0, osf1_copyargs, cpu_exec_ecoff_setregs }, /* OSF1 ecoff binaries */
|
||||
#endif /* COMPAT_OSF1 */
|
||||
{ ECOFF_HDR_SIZE, exec_ecoff_makecmds,
|
||||
{ ecoff_probe_func: cpu_exec_ecoff_probe },
|
||||
&emul_netbsd, 0,
|
||||
0, copyargs, cpu_exec_ecoff_setregs }, /* ecoff binaries */
|
||||
#ifdef COMPAT_ULTRIX
|
||||
/* XXX this has to be last, the probe function always succeeds */
|
||||
{ ECOFF_HDR_SIZE, exec_ecoff_makecmds,
|
||||
{ ecoff_probe_func: ultrix_exec_ecoff_probe },
|
||||
&emul_ultrix, 0,
|
||||
0, copyargs, cpu_exec_ecoff_setregs }, /* Ultrix ecoff binaries */
|
||||
#endif /* COMPAT_ULTRIX */
|
||||
#endif
|
||||
#ifdef EXEC_ELF32
|
||||
{ sizeof (Elf32_Ehdr), exec_elf32_makecmds, }, /* 32bit ELF bins */
|
||||
/* 32bit ELF bins */
|
||||
#ifdef COMPAT_NETBSD32
|
||||
{ sizeof (Elf32_Ehdr), exec_elf32_makecmds,
|
||||
{ elf_probe_func: ELF32NAME2(netbsd32,probe) },
|
||||
&emul_netbsd32, 0,
|
||||
howmany(ELF_AUX_ENTRIES * sizeof(Aux32Info), sizeof (Elf32_Addr)),
|
||||
netbsd32_elf32_copyargs, netbsd32_setregs }, /* NetBSD32 32bit ELF bins */
|
||||
/* This one should go first so it matches instead of netbsd */
|
||||
#endif
|
||||
#ifdef EXEC_ELF64
|
||||
{ sizeof (Elf64_Ehdr), exec_elf64_makecmds, }, /* 64bit ELF bins */
|
||||
{ sizeof (Elf32_Ehdr), exec_elf32_makecmds,
|
||||
{ elf_probe_func: ELF32NAME2(netbsd,probe) },
|
||||
&emul_netbsd, 0,
|
||||
howmany(ELF_AUX_ENTRIES * sizeof(Aux32Info), sizeof (Elf32_Addr)),
|
||||
elf32_copyargs, setregs }, /* NetBSD 32bit ELF bins */
|
||||
#ifdef COMPAT_FREEBSD
|
||||
{ sizeof (Elf32_Ehdr), exec_elf32_makecmds,
|
||||
{ elf_probe_func: ELF32NAME2(freebsd,probe) },
|
||||
&emul_freebsd, 0,
|
||||
FREEBSD_ELF_AUX_ARGSIZ,
|
||||
elf32_copyargs, setregs }, /* FreeBSD 32bit ELF bins (not 64bit safe )*/
|
||||
#endif
|
||||
#ifdef COMPAT_SUNOS
|
||||
{ SUNOS_AOUT_HDR_SIZE, exec_sunos_aout_makecmds, }, /* SunOS a.out */
|
||||
#ifdef COMPAT_LINUX
|
||||
{ sizeof (Elf32_Ehdr), exec_elf32_makecmds,
|
||||
{ elf_probe_func: ELF32NAME2(linux,probe) },
|
||||
&emul_linux, 0,
|
||||
LINUX_ELF_AUX_ARGSIZ,
|
||||
LINUX_COPYARGS_FUNCTION, setregs }, /* Linux 32bit ELF bins */
|
||||
#endif
|
||||
#if defined(COMPAT_LINUX) && defined(EXEC_AOUT)
|
||||
{ LINUX_AOUT_HDR_SIZE, exec_linux_aout_makecmds, }, /* linux a.out */
|
||||
#ifdef COMPAT_SVR4
|
||||
{ sizeof (Elf32_Ehdr), exec_elf32_makecmds,
|
||||
{ elf_probe_func: ELF32NAME2(svr4,probe) },
|
||||
&emul_svr4, 0,
|
||||
SVR4_AUX_ARGSIZ,
|
||||
svr4_copyargs, svr4_setregs }, /* SVR4 32bit ELF bins (not 64bit safe) */
|
||||
#endif
|
||||
#ifdef COMPAT_IBCS2
|
||||
{ COFF_HDR_SIZE, exec_ibcs2_coff_makecmds, }, /* coff binaries */
|
||||
{ XOUT_HDR_SIZE, exec_ibcs2_xout_makecmds, }, /* x.out binaries */
|
||||
{ sizeof (Elf32_Ehdr), exec_elf32_makecmds,
|
||||
{ elf_probe_func: ELF32NAME2(ibcs2,probe) },
|
||||
&emul_ibcs2, 0,
|
||||
IBCS2_ELF_AUX_ARGSIZ, elf32_copyargs, setregs },
|
||||
/* SCO 32bit ELF bins (not 64bit safe) */
|
||||
#endif
|
||||
{ sizeof (Elf32_Ehdr), exec_elf32_makecmds, { NULL },
|
||||
&emul_netbsd, 0,
|
||||
howmany(ELF_AUX_ENTRIES * sizeof(Aux32Info), sizeof (Elf32_Addr)),
|
||||
elf32_copyargs, setregs }, /* NetBSD 32bit ELF bins */
|
||||
#endif /* EXEC_ELF32 */
|
||||
#ifdef EXEC_ELF64
|
||||
/* 64bit ELF bins */
|
||||
#ifdef COMPAT_NETBSD32
|
||||
{ sizeof (Elf64_Ehdr), exec_elf64_makecmds,
|
||||
{ elf_probe_func: ELF64NAME2(netbsd32,probe)},
|
||||
&emul_netbsd32, 0,
|
||||
howmany(ELF_AUX_ENTRIES * sizeof(Aux64Info), sizeof (Elf64_Addr)),
|
||||
elf64_copyargs, setregs }, /* NetBSD32 64bit ELF bins */
|
||||
/* This one should go first so it matches instead of netbsd */
|
||||
#endif
|
||||
{ sizeof (Elf64_Ehdr), exec_elf64_makecmds,
|
||||
{ elf_probe_func: ELF64NAME2(netbsd,probe) },
|
||||
&emul_netbsd, 0,
|
||||
howmany(ELF_AUX_ENTRIES * sizeof(Aux64Info), sizeof (Elf64_Addr)),
|
||||
elf64_copyargs, setregs }, /* NetBSD 64bit ELF bins */
|
||||
#ifdef COMPAT_LINUX
|
||||
{ sizeof (Elf64_Ehdr), exec_elf64_makecmds,
|
||||
{ elf_probe_func: ELF64NAME2(linux,probe) },
|
||||
&emul_linux, 0,
|
||||
LINUX_ELF_AUX_ARGSIZ,
|
||||
LINUX_COPYARGS_FUNCTION, setregs }, /* Linux 64bit ELF bins */
|
||||
#endif
|
||||
{ sizeof (Elf64_Ehdr), exec_elf64_makecmds, { NULL },
|
||||
&emul_netbsd, 0,
|
||||
howmany(ELF_AUX_ENTRIES * sizeof(Aux64Info), sizeof (Elf64_Addr)),
|
||||
elf64_copyargs, setregs }, /* NetBSD 64bit ELF bins */
|
||||
#endif /* EXEC_ELF64 */
|
||||
#ifdef COMPAT_SUNOS
|
||||
{ SUNOS_AOUT_HDR_SIZE, exec_sunos_aout_makecmds, { NULL },
|
||||
&emul_sunos, 0,
|
||||
0, copyargs, setregs }, /* SunOS a.out */
|
||||
#endif
|
||||
#if defined(COMPAT_LINUX) && defined(EXEC_AOUT)
|
||||
{ LINUX_AOUT_HDR_SIZE, exec_linux_aout_makecmds, { NULL },
|
||||
&emul_linux, 0,
|
||||
LINUX_AOUT_AUX_ARGSIZ, linux_aout_copyargs, linux_setregs }, /* linux a.out */
|
||||
#endif
|
||||
#ifdef COMPAT_IBCS2
|
||||
{ COFF_HDR_SIZE, exec_ibcs2_coff_makecmds, { NULL },
|
||||
&emul_ibcs2, 0,
|
||||
0, copyargs, ibcs2_setregs }, /* coff binaries */
|
||||
{ XOUT_HDR_SIZE, exec_ibcs2_xout_makecmds, { NULL },
|
||||
&emul_ibcs2, 0,
|
||||
0, copyargs, ibcs2_setregs }, /* x.out binaries */
|
||||
#endif
|
||||
#if defined(COMPAT_FREEBSD) && defined(EXEC_AOUT)
|
||||
{ FREEBSD_AOUT_HDR_SIZE, exec_freebsd_aout_makecmds, }, /* a.out */
|
||||
{ FREEBSD_AOUT_HDR_SIZE, exec_freebsd_aout_makecmds, { NULL },
|
||||
&emul_freebsd, 0,
|
||||
0, copyargs, freebsd_setregs }, /* a.out */
|
||||
#endif
|
||||
#ifdef COMPAT_HPUX
|
||||
{ HPUX_EXEC_HDR_SIZE, exec_hpux_makecmds, }, /* HP-UX a.out */
|
||||
{ HPUX_EXEC_HDR_SIZE, exec_hpux_makecmds, { NULL },
|
||||
&emul_hpux, 0,
|
||||
0, copyargs, hpux_setregs }, /* HP-UX a.out */
|
||||
#endif
|
||||
#ifdef COMPAT_M68K4K
|
||||
{ sizeof(struct exec), exec_m68k4k_makecmds, }, /* m68k4k a.out */
|
||||
{ sizeof(struct exec), exec_m68k4k_makecmds, { NULL },
|
||||
&emul_netbsd, 0,
|
||||
0, copyargs, setregs }, /* m68k4k a.out */
|
||||
#endif
|
||||
#ifdef COMPAT_VAX1K
|
||||
{ sizeof(struct exec), exec_vax1k_makecmds, }, /* vax1k a.out */
|
||||
{ sizeof(struct exec), exec_vax1k_makecmds, { NULL },
|
||||
&emul_netbsd, 0,
|
||||
0, copyargs, setregs }, /* vax1k a.out */
|
||||
#endif
|
||||
#ifdef COMPAT_PECOFF
|
||||
{ sizeof(struct exec), exec_pecoff_makecmds, }, /* Win32/CE PE/COFF */
|
||||
{ sizeof(struct exec), exec_pecoff_makecmds, { NULL },
|
||||
&emul_netbsd, 0, /* XXX emul_pecoff once it's different */
|
||||
howmany(sizeof(struct pecoff_args), sizeof(char *)),
|
||||
pecoff_copyargs, setregs }, /* Win32/CE PE/COFF */
|
||||
#endif
|
||||
};
|
||||
int nexecs = (sizeof(execsw) / sizeof(*execsw));
|
||||
int exec_maxhdrsz;
|
||||
int exec_maxhdrsz = 0;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: exec_ecoff.c,v 1.13 2000/08/01 04:57:28 thorpej Exp $ */
|
||||
/* $NetBSD: exec_ecoff.c,v 1.14 2000/11/21 00:37:55 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Adam Glass
|
||||
@ -65,7 +65,7 @@ exec_ecoff_makecmds(struct proc *p, struct exec_package *epp)
|
||||
if (ECOFF_BADMAG(execp))
|
||||
return ENOEXEC;
|
||||
|
||||
error = cpu_exec_ecoff_hook(p, epp);
|
||||
error = (*epp->ep_esch->u.ecoff_probe_func)(p, epp);
|
||||
|
||||
/*
|
||||
* if there was an error or there are already vmcmds set up,
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: exec_elf32.c,v 1.57 2000/11/14 22:14:53 thorpej Exp $ */
|
||||
/* $NetBSD: exec_elf32.c,v 1.58 2000/11/21 00:37:56 jdolecek Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1994 The NetBSD Foundation, Inc.
|
||||
@ -68,12 +68,7 @@
|
||||
#define ELFSIZE 32
|
||||
#endif
|
||||
|
||||
#include "opt_compat_linux.h"
|
||||
#include "opt_compat_ibcs2.h"
|
||||
#include "opt_compat_svr4.h"
|
||||
#include "opt_compat_freebsd.h"
|
||||
#include "opt_compat_netbsd32.h"
|
||||
#include "opt_syscall_debug.h"
|
||||
#include "opt_compat_ibcs2.h" /* XXX quirk for PT_SHLIB section */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/proc.h>
|
||||
@ -87,27 +82,10 @@
|
||||
#include <sys/mount.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <uvm/uvm_extern.h>
|
||||
#include <machine/cpu.h>
|
||||
#include <machine/reg.h>
|
||||
|
||||
#ifdef COMPAT_NETBSD32
|
||||
#include <compat/netbsd32/netbsd32_exec.h>
|
||||
#endif
|
||||
|
||||
#ifdef COMPAT_LINUX
|
||||
#include <compat/linux/common/linux_exec.h>
|
||||
#endif
|
||||
|
||||
#ifdef COMPAT_SVR4
|
||||
#include <compat/svr4/svr4_exec.h>
|
||||
#endif
|
||||
|
||||
#ifdef COMPAT_IBCS2
|
||||
#include <compat/ibcs2/ibcs2_exec.h>
|
||||
#endif
|
||||
|
||||
#ifdef COMPAT_FREEBSD
|
||||
#include <compat/freebsd/freebsd_exec.h>
|
||||
#endif
|
||||
extern const struct emul emul_netbsd;
|
||||
|
||||
int ELFNAME(check_header)(Elf_Ehdr *, int);
|
||||
int ELFNAME(load_file)(struct proc *, struct exec_package *, char *,
|
||||
@ -115,55 +93,10 @@ int ELFNAME(load_file)(struct proc *, struct exec_package *, char *,
|
||||
void ELFNAME(load_psection)(struct exec_vmcmd_set *, struct vnode *,
|
||||
const Elf_Phdr *, Elf_Addr *, u_long *, int *, int);
|
||||
|
||||
int ELFNAME2(netbsd,signature)(struct proc *, struct exec_package *,
|
||||
static int ELFNAME2(netbsd,signature)(struct proc *, struct exec_package *,
|
||||
Elf_Ehdr *);
|
||||
static int ELFNAME2(netbsd,probe)(struct proc *, struct exec_package *,
|
||||
Elf_Ehdr *, char *, Elf_Addr *);
|
||||
|
||||
extern char sigcode[], esigcode[];
|
||||
#ifdef SYSCALL_DEBUG
|
||||
extern const char * const syscallnames[];
|
||||
#endif
|
||||
|
||||
struct emul ELFNAMEEND(emul_netbsd) = {
|
||||
"netbsd",
|
||||
NULL,
|
||||
sendsig,
|
||||
SYS_syscall,
|
||||
SYS_MAXSYSCALL,
|
||||
sysent,
|
||||
#ifdef SYSCALL_DEBUG
|
||||
syscallnames,
|
||||
#else
|
||||
NULL,
|
||||
#endif
|
||||
howmany(ELF_AUX_ENTRIES * sizeof(AuxInfo), sizeof (Elf_Addr)),
|
||||
ELFNAME(copyargs),
|
||||
setregs,
|
||||
sigcode,
|
||||
esigcode,
|
||||
};
|
||||
|
||||
int (*ELFNAME(probe_funcs)[])(struct proc *, struct exec_package *,
|
||||
Elf_Ehdr *, char *, Elf_Addr *) = {
|
||||
#if defined(COMPAT_NETBSD32) && (ELFSIZE == 32)
|
||||
/* This one should go first so it matches instead of netbsd */
|
||||
ELFNAME2(netbsd32,probe),
|
||||
#endif
|
||||
ELFNAME2(netbsd,probe),
|
||||
#if defined(COMPAT_FREEBSD) && (ELFSIZE == 32)
|
||||
ELFNAME2(freebsd,probe), /* XXX not 64-bit safe */
|
||||
#endif
|
||||
#if defined(COMPAT_LINUX)
|
||||
ELFNAME2(linux,probe),
|
||||
#endif
|
||||
#if defined(COMPAT_SVR4) && (ELFSIZE == 32)
|
||||
ELFNAME2(svr4,probe), /* XXX not 64-bit safe */
|
||||
#endif
|
||||
#if defined(COMPAT_IBCS2) && (ELFSIZE == 32)
|
||||
ELFNAME2(ibcs2,probe), /* XXX not 64-bit safe */
|
||||
#endif
|
||||
};
|
||||
int ELFNAME2(netbsd,probe)(struct proc *, struct exec_package *,
|
||||
void *, char *, vaddr_t *);
|
||||
|
||||
/* round up and down to page boundaries. */
|
||||
#define ELF_ROUND(a, b) (((a) + (b) - 1) & ~((b) - 1))
|
||||
@ -513,8 +446,8 @@ ELFNAME2(exec,makecmds)(struct proc *p, struct exec_package *epp)
|
||||
Elf_Ehdr *eh = epp->ep_hdr;
|
||||
Elf_Phdr *ph, *pp;
|
||||
Elf_Addr phdr = 0, pos = 0;
|
||||
int error, i, n, nload;
|
||||
char interp[MAXPATHLEN];
|
||||
int error, i, nload;
|
||||
char *interp = NULL;
|
||||
u_long phsize;
|
||||
|
||||
if (epp->ep_hdrvalid < sizeof(Elf_Ehdr))
|
||||
@ -554,12 +487,13 @@ ELFNAME2(exec,makecmds)(struct proc *p, struct exec_package *epp)
|
||||
epp->ep_taddr = epp->ep_tsize = ELFDEFNNAME(NO_ADDR);
|
||||
epp->ep_daddr = epp->ep_dsize = ELFDEFNNAME(NO_ADDR);
|
||||
|
||||
MALLOC(interp, char *, MAXPATHLEN, M_TEMP, M_WAITOK);
|
||||
interp[0] = '\0';
|
||||
|
||||
for (i = 0; i < eh->e_phnum; i++) {
|
||||
pp = &ph[i];
|
||||
if (pp->p_type == PT_INTERP) {
|
||||
if (pp->p_filesz >= sizeof(interp))
|
||||
if (pp->p_filesz >= MAXPATHLEN)
|
||||
goto bad;
|
||||
if ((error = ELFNAME(read_from)(p, epp->ep_vp,
|
||||
pp->p_offset, (caddr_t) interp,
|
||||
@ -569,12 +503,6 @@ ELFNAME2(exec,makecmds)(struct proc *p, struct exec_package *epp)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Setup things for native emulation.
|
||||
*/
|
||||
epp->ep_emul = &ELFNAMEEND(emul_netbsd);
|
||||
pos = ELFDEFNNAME(NO_ADDR);
|
||||
|
||||
/*
|
||||
* On the same architecture, we may be emulating different systems.
|
||||
* See which one will accept this executable. This currently only
|
||||
@ -583,25 +511,16 @@ ELFNAME2(exec,makecmds)(struct proc *p, struct exec_package *epp)
|
||||
*
|
||||
* Probe functions would normally see if the interpreter (if any)
|
||||
* exists. Emulation packages may possibly replace the interpreter in
|
||||
* interp[] with a changed path (/emul/xxx/<path>), and also
|
||||
* set the ep_emul field in the exec package structure.
|
||||
* interp[] with a changed path (/emul/xxx/<path>).
|
||||
*/
|
||||
n = sizeof(ELFNAME(probe_funcs)) / sizeof(ELFNAME(probe_funcs)[0]);
|
||||
if (n != 0) {
|
||||
error = ENOEXEC;
|
||||
for (i = 0; i < n && error; i++)
|
||||
error = ELFNAME(probe_funcs)[i](p, epp, eh,
|
||||
interp, &pos);
|
||||
#ifdef notyet
|
||||
/*
|
||||
* We should really use a signature in our native binaries
|
||||
* and have our own probe function for matching binaries,
|
||||
* before trying the emulations. For now, if the emulation
|
||||
* probes failed we default to native.
|
||||
*/
|
||||
if (!epp->ep_esch->u.elf_probe_func) {
|
||||
p->p_emul = epp->ep_esch->es_emul;
|
||||
pos = ELFDEFNNAME(NO_ADDR);
|
||||
} else {
|
||||
error = (*epp->ep_esch->u.elf_probe_func)(p, epp, eh, interp,
|
||||
(vaddr_t *)&pos);
|
||||
if (error)
|
||||
goto bad;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@ -686,11 +605,11 @@ ELFNAME2(exec,makecmds)(struct proc *p, struct exec_package *epp)
|
||||
if (interp[0]) {
|
||||
struct elf_args *ap;
|
||||
|
||||
ap = (struct elf_args *)malloc(sizeof(struct elf_args),
|
||||
MALLOC(ap, struct elf_args *, sizeof(struct elf_args),
|
||||
M_TEMP, M_WAITOK);
|
||||
if ((error = ELFNAME(load_file)(p, epp, interp,
|
||||
&epp->ep_vmcmds, &epp->ep_entry, ap, &pos)) != 0) {
|
||||
free((char *)ap, M_TEMP);
|
||||
FREE((char *)ap, M_TEMP);
|
||||
goto bad;
|
||||
}
|
||||
pos += phsize;
|
||||
@ -709,17 +628,20 @@ ELFNAME2(exec,makecmds)(struct proc *p, struct exec_package *epp)
|
||||
NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn, PAGE_SIZE, 0,
|
||||
epp->ep_vp, 0, VM_PROT_READ);
|
||||
#endif
|
||||
FREE(interp, M_TEMP);
|
||||
free((char *)ph, M_TEMP);
|
||||
vn_marktext(epp->ep_vp);
|
||||
return exec_elf_setup_stack(p, epp);
|
||||
|
||||
bad:
|
||||
if (interp)
|
||||
FREE(interp, M_TEMP);
|
||||
free((char *)ph, M_TEMP);
|
||||
kill_vmcmds(&epp->ep_vmcmds);
|
||||
return ENOEXEC;
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
ELFNAME2(netbsd,signature)(struct proc *p, struct exec_package *epp,
|
||||
Elf_Ehdr *eh)
|
||||
{
|
||||
@ -776,15 +698,14 @@ out1:
|
||||
return error;
|
||||
}
|
||||
|
||||
static int
|
||||
int
|
||||
ELFNAME2(netbsd,probe)(struct proc *p, struct exec_package *epp,
|
||||
Elf_Ehdr *eh, char *itp, Elf_Addr *pos)
|
||||
void *eh, char *itp, vaddr_t *pos)
|
||||
{
|
||||
int error;
|
||||
|
||||
if ((error = ELFNAME2(netbsd,signature)(p, epp, eh)) != 0)
|
||||
return error;
|
||||
epp->ep_emul = &ELFNAMEEND(emul_netbsd);
|
||||
*pos = ELFDEFNNAME(NO_ADDR);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: exec_script.c,v 1.26 2000/08/03 20:41:21 thorpej Exp $ */
|
||||
/* $NetBSD: exec_script.c,v 1.27 2000/11/21 00:37:56 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993, 1994, 1996 Christopher G. Demetriou
|
||||
@ -237,7 +237,7 @@ check_shell:
|
||||
|
||||
if ((error = check_exec(p, epp)) == 0) {
|
||||
/* note that we've clobbered the header */
|
||||
epp->ep_flags |= EXEC_DESTR;
|
||||
epp->ep_flags |= EXEC_DESTR|EXEC_HASES;
|
||||
|
||||
/*
|
||||
* It succeeded. Unlock the script and
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: init_main.c,v 1.183 2000/11/13 21:32:15 jdolecek Exp $ */
|
||||
/* $NetBSD: init_main.c,v 1.184 2000/11/21 00:37:56 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995 Christopher G. Demetriou. All rights reserved.
|
||||
@ -55,7 +55,6 @@
|
||||
#include <sys/filedesc.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/exec.h>
|
||||
#include <sys/callout.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/mount.h>
|
||||
@ -144,29 +143,7 @@ static void check_console(struct proc *p);
|
||||
static void start_init(void *);
|
||||
void main(void);
|
||||
|
||||
extern char sigcode[], esigcode[];
|
||||
#ifdef SYSCALL_DEBUG
|
||||
extern const char * const syscallnames[];
|
||||
#endif
|
||||
|
||||
struct emul emul_netbsd = {
|
||||
"netbsd",
|
||||
NULL,
|
||||
sendsig,
|
||||
SYS_syscall,
|
||||
SYS_MAXSYSCALL,
|
||||
sysent,
|
||||
#ifdef SYSCALL_DEBUG
|
||||
syscallnames,
|
||||
#else
|
||||
NULL,
|
||||
#endif
|
||||
0,
|
||||
copyargs,
|
||||
setregs,
|
||||
sigcode,
|
||||
esigcode,
|
||||
};
|
||||
extern const struct emul emul_netbsd; /* defined in kern_exec.c */
|
||||
|
||||
/*
|
||||
* System startup; initialize the world, create process 0, mount root
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: kern_exec.c,v 1.123 2000/11/16 20:04:33 jdolecek Exp $ */
|
||||
/* $NetBSD: kern_exec.c,v 1.124 2000/11/21 00:37:56 jdolecek Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (C) 1993, 1994, 1996 Christopher G. Demetriou
|
||||
@ -33,6 +33,7 @@
|
||||
*/
|
||||
|
||||
#include "opt_ktrace.h"
|
||||
#include "opt_syscall_debug.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -52,6 +53,7 @@
|
||||
#include <sys/mman.h>
|
||||
#include <sys/signalvar.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/syscall.h>
|
||||
|
||||
#include <sys/syscallargs.h>
|
||||
|
||||
@ -60,6 +62,27 @@
|
||||
#include <machine/cpu.h>
|
||||
#include <machine/reg.h>
|
||||
|
||||
extern char sigcode[], esigcode[];
|
||||
#ifdef SYSCALL_DEBUG
|
||||
extern const char * const syscallnames[];
|
||||
#endif
|
||||
|
||||
const struct emul emul_netbsd = {
|
||||
"netbsd",
|
||||
NULL,
|
||||
sendsig,
|
||||
SYS_syscall,
|
||||
SYS_MAXSYSCALL,
|
||||
sysent,
|
||||
#ifdef SYSCALL_DEBUG
|
||||
syscallnames,
|
||||
#else
|
||||
NULL,
|
||||
#endif
|
||||
sigcode,
|
||||
esigcode,
|
||||
};
|
||||
|
||||
/*
|
||||
* check exec:
|
||||
* given an "executable" described in the exec package's namei info,
|
||||
@ -146,10 +169,16 @@ check_exec(struct proc *p, struct exec_package *epp)
|
||||
if (execsw[i].es_check == NULL)
|
||||
continue;
|
||||
|
||||
epp->ep_esch = &execsw[i];
|
||||
newerror = (*execsw[i].es_check)(p, epp);
|
||||
/* make sure the first "interesting" error code is saved. */
|
||||
if (!newerror || error == ENOEXEC)
|
||||
error = newerror;
|
||||
|
||||
/* if es_check call was successful, update epp->ep_es */
|
||||
if (!newerror && (epp->ep_flags & EXEC_HASES) == 0)
|
||||
epp->ep_es = &execsw[i];
|
||||
|
||||
if (epp->ep_flags & EXEC_DESTR && error != 0)
|
||||
return error;
|
||||
}
|
||||
@ -222,7 +251,6 @@ sys_execve(struct proc *p, void *v, register_t *retval)
|
||||
char **tmpfap;
|
||||
int szsigcode;
|
||||
struct exec_vmcmd *base_vcp = NULL;
|
||||
extern struct emul emul_netbsd;
|
||||
|
||||
/*
|
||||
* figure out the maximum size of an exec header, if necessary.
|
||||
@ -252,7 +280,6 @@ sys_execve(struct proc *p, void *v, register_t *retval)
|
||||
pack.ep_vmcmds.evs_cnt = 0;
|
||||
pack.ep_vmcmds.evs_used = 0;
|
||||
pack.ep_vap = &attr;
|
||||
pack.ep_emul = &emul_netbsd;
|
||||
pack.ep_flags = 0;
|
||||
|
||||
/* see if we can run it. */
|
||||
@ -335,15 +362,15 @@ sys_execve(struct proc *p, void *v, register_t *retval)
|
||||
|
||||
dp = (char *) ALIGN(dp);
|
||||
|
||||
szsigcode = pack.ep_emul->e_esigcode - pack.ep_emul->e_sigcode;
|
||||
szsigcode = pack.ep_es->es_emul->e_esigcode - pack.ep_es->es_emul->e_sigcode;
|
||||
|
||||
/* Now check if args & environ fit into new stack */
|
||||
if (pack.ep_flags & EXEC_32)
|
||||
len = ((argc + envc + 2 + pack.ep_emul->e_arglen) * sizeof(int) +
|
||||
len = ((argc + envc + 2 + pack.ep_es->es_arglen) * sizeof(int) +
|
||||
sizeof(int) + dp + STACKGAPLEN + szsigcode +
|
||||
sizeof(struct ps_strings)) - argp;
|
||||
else
|
||||
len = ((argc + envc + 2 + pack.ep_emul->e_arglen) * sizeof(char *) +
|
||||
len = ((argc + envc + 2 + pack.ep_es->es_arglen) * sizeof(char *) +
|
||||
sizeof(int) + dp + STACKGAPLEN + szsigcode +
|
||||
sizeof(struct ps_strings)) - argp;
|
||||
|
||||
@ -424,7 +451,7 @@ sys_execve(struct proc *p, void *v, register_t *retval)
|
||||
|
||||
stack = (char *) (vm->vm_minsaddr - len);
|
||||
/* Now copy argc, args & environ to new stack */
|
||||
if (!(*pack.ep_emul->e_copyargs)(&pack, &arginfo, stack, argp)) {
|
||||
if (!(*pack.ep_es->es_copyargs)(&pack, &arginfo, stack, argp)) {
|
||||
#ifdef DEBUG
|
||||
printf("execve: copyargs failed\n");
|
||||
#endif
|
||||
@ -449,7 +476,7 @@ sys_execve(struct proc *p, void *v, register_t *retval)
|
||||
|
||||
/* copy out the process's signal trapoline code */
|
||||
if (szsigcode) {
|
||||
if (copyout((char *)pack.ep_emul->e_sigcode,
|
||||
if (copyout((char *)pack.ep_es->es_emul->e_sigcode,
|
||||
p->p_sigacts->ps_sigcode = (char *)p->p_psstr - szsigcode,
|
||||
szsigcode)) {
|
||||
#ifdef DEBUG
|
||||
@ -521,7 +548,7 @@ sys_execve(struct proc *p, void *v, register_t *retval)
|
||||
vput(pack.ep_vp);
|
||||
|
||||
/* setup new registers and do misc. setup. */
|
||||
(*pack.ep_emul->e_setregs)(p, &pack, (u_long) stack);
|
||||
(*pack.ep_es->es_setregs)(p, &pack, (u_long) stack);
|
||||
|
||||
if (p->p_flag & P_TRACED)
|
||||
psignal(p, SIGTRAP);
|
||||
@ -538,18 +565,19 @@ sys_execve(struct proc *p, void *v, register_t *retval)
|
||||
* same, the exec hook code should deallocate any old emulation
|
||||
* resources held previously by this process.
|
||||
*/
|
||||
if (p->p_emul && p->p_emul->e_proc_exit && p->p_emul != pack.ep_emul)
|
||||
if (p->p_emul && p->p_emul->e_proc_exit
|
||||
&& p->p_emul != pack.ep_es->es_emul)
|
||||
(*p->p_emul->e_proc_exit)(p);
|
||||
|
||||
/*
|
||||
* Call exec hook. Emulation code may NOT store reference to anything
|
||||
* from &pack.
|
||||
*/
|
||||
if (pack.ep_emul->e_proc_exec)
|
||||
(*pack.ep_emul->e_proc_exec)(p, &pack);
|
||||
if (pack.ep_es->es_emul->e_proc_exec)
|
||||
(*pack.ep_es->es_emul->e_proc_exec)(p, &pack);
|
||||
|
||||
/* update p_emul, the old value is no longer needed */
|
||||
p->p_emul = pack.ep_emul;
|
||||
p->p_emul = pack.ep_es->es_emul;
|
||||
|
||||
#ifdef KTRACE
|
||||
if (KTRPOINT(p, KTR_EMUL))
|
||||
@ -586,7 +614,7 @@ exec_abort:
|
||||
uvm_deallocate(&vm->vm_map, VM_MIN_ADDRESS,
|
||||
VM_MAXUSER_ADDRESS - VM_MIN_ADDRESS);
|
||||
if (pack.ep_emul_arg)
|
||||
free(pack.ep_emul_arg, M_TEMP);
|
||||
FREE(pack.ep_emul_arg, M_TEMP);
|
||||
PNBUF_PUT(nid.ni_cnd.cn_pnbuf);
|
||||
vn_lock(pack.ep_vp, LK_EXCLUSIVE | LK_RETRY);
|
||||
VOP_CLOSE(pack.ep_vp, FREAD, cred, p);
|
||||
@ -623,7 +651,7 @@ copyargs(struct exec_package *pack, struct ps_strings *arginfo,
|
||||
argc >>= 32;
|
||||
#endif
|
||||
|
||||
dp = (char *) (cpp + argc + envc + 2 + pack->ep_emul->e_arglen);
|
||||
dp = (char *) (cpp + argc + envc + 2 + pack->ep_es->es_arglen);
|
||||
sp = argp;
|
||||
|
||||
/* XXX don't copy them out, remap them! */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: kern_xxx.c,v 1.44 2000/06/27 17:41:32 mrg Exp $ */
|
||||
/* $NetBSD: kern_xxx.c,v 1.45 2000/11/21 00:37:56 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 1993
|
||||
@ -96,8 +96,8 @@ scdebug_call(p, code, args)
|
||||
struct proc *p;
|
||||
register_t code, args[];
|
||||
{
|
||||
struct sysent *sy;
|
||||
struct emul *em;
|
||||
const struct sysent *sy;
|
||||
const struct emul *em;
|
||||
int i;
|
||||
|
||||
if (!(scdebug & SCDEBUG_CALLS))
|
||||
@ -133,8 +133,8 @@ scdebug_ret(p, code, error, retval)
|
||||
int error;
|
||||
register_t retval[];
|
||||
{
|
||||
struct sysent *sy;
|
||||
struct emul *em;
|
||||
const struct sysent *sy;
|
||||
const struct emul *em;
|
||||
|
||||
if (!(scdebug & SCDEBUG_RETURNS))
|
||||
return;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: exec.h,v 1.72 2000/09/28 19:05:07 eeh Exp $ */
|
||||
/* $NetBSD: exec.h,v 1.73 2000/11/21 00:37:56 jdolecek Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1994 Christopher G. Demetriou
|
||||
@ -107,6 +107,21 @@ typedef int (*exec_makecmds_fcn) __P((struct proc *, struct exec_package *));
|
||||
struct execsw {
|
||||
u_int es_hdrsz; /* size of header for this format */
|
||||
exec_makecmds_fcn es_check; /* function to check exec format */
|
||||
union { /* probe function */
|
||||
int (*elf_probe_func) __P((struct proc *,
|
||||
struct exec_package *, void *, char *, vaddr_t *));
|
||||
int (*ecoff_probe_func) __P((struct proc *,
|
||||
struct exec_package *));
|
||||
} u;
|
||||
const struct emul *es_emul; /* os emulation */
|
||||
int es_flags; /* miscellaneous flags */
|
||||
int es_arglen; /* Extra argument size in words */
|
||||
/* Copy arguments on the new stack */
|
||||
void *(*es_copyargs) __P((struct exec_package *, struct ps_strings *,
|
||||
void *, void *));
|
||||
/* Set registers before execution */
|
||||
void (*es_setregs) __P((struct proc *, struct exec_package *,
|
||||
u_long));
|
||||
};
|
||||
|
||||
/* exec vmspace-creation command set; see below */
|
||||
@ -138,8 +153,9 @@ struct exec_package {
|
||||
u_int ep_flags; /* flags; see below. */
|
||||
char **ep_fa; /* a fake args vector for scripts */
|
||||
int ep_fd; /* a file descriptor we're holding */
|
||||
struct emul *ep_emul; /* os emulation */
|
||||
void *ep_emul_arg; /* emulation argument */
|
||||
const struct execsw *ep_es; /* appropriate execsw entry */
|
||||
const struct execsw *ep_esch;/* checked execsw entry */
|
||||
};
|
||||
#define EXEC_INDIR 0x0001 /* script handling already done */
|
||||
#define EXEC_HASFD 0x0002 /* holding a shell script */
|
||||
@ -147,6 +163,7 @@ struct exec_package {
|
||||
#define EXEC_SKIPARG 0x0008 /* don't copy user-supplied argv[0] */
|
||||
#define EXEC_DESTR 0x0010 /* destructive ops performed */
|
||||
#define EXEC_32 0x0020 /* 32-bit binary emulation */
|
||||
#define EXEC_HASES 0x0040 /* don't update exec switch pointer */
|
||||
|
||||
struct exec_vmcmd {
|
||||
int (*ev_proc) __P((struct proc *p, struct exec_vmcmd *cmd));
|
||||
@ -219,7 +236,7 @@ void new_vmcmd __P((struct exec_vmcmd_set *evsp,
|
||||
* Functions for specific exec types should be defined in their own
|
||||
* header file.
|
||||
*/
|
||||
extern struct execsw execsw[];
|
||||
extern const struct execsw execsw[];
|
||||
extern int nexecs;
|
||||
extern int exec_maxhdrsz;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: exec_ecoff.h,v 1.11 1999/04/27 05:36:43 cgd Exp $ */
|
||||
/* $NetBSD: exec_ecoff.h,v 1.12 2000/11/21 00:37:56 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Adam Glass
|
||||
@ -105,7 +105,9 @@ struct ecoff_exechdr {
|
||||
#ifdef _KERNEL
|
||||
int exec_ecoff_makecmds __P((struct proc *, struct exec_package *));
|
||||
int exec_ecoff_setup_stack __P((struct proc *, struct exec_package *));
|
||||
int cpu_exec_ecoff_hook __P((struct proc *, struct exec_package *));
|
||||
int cpu_exec_ecoff_probe __P((struct proc *, struct exec_package *));
|
||||
void cpu_exec_ecoff_setregs __P((struct proc *, struct exec_package *,
|
||||
u_long));
|
||||
|
||||
int exec_ecoff_prep_omagic __P((struct proc *, struct exec_package *,
|
||||
struct ecoff_exechdr *, struct vnode *));
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: proc.h,v 1.110 2000/11/19 00:56:39 sommerfeld Exp $ */
|
||||
/* $NetBSD: proc.h,v 1.111 2000/11/21 00:37:56 jdolecek Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1986, 1989, 1991, 1993
|
||||
@ -91,16 +91,8 @@ struct emul {
|
||||
void (*e_sendsig) __P((sig_t, int, sigset_t *, u_long));
|
||||
int e_nosys; /* Offset of the nosys() syscall */
|
||||
int e_nsysent; /* Number of system call entries */
|
||||
struct sysent *e_sysent; /* System call array */
|
||||
const struct sysent *e_sysent; /* System call array */
|
||||
const char * const *e_syscallnames; /* System call name array */
|
||||
int e_arglen; /* Extra argument size in words */
|
||||
/* Copy arguments on the new stack */
|
||||
void *(*e_copyargs) __P((struct exec_package *, struct ps_strings *,
|
||||
void *, void *));
|
||||
/* Set registers before execution */
|
||||
void (*e_setregs) __P((struct proc *, struct exec_package *,
|
||||
u_long));
|
||||
|
||||
char *e_sigcode; /* Start of sigcode */
|
||||
char *e_esigcode; /* End of sigcode */
|
||||
|
||||
@ -187,7 +179,7 @@ struct proc {
|
||||
int p_locks; /* DEBUG: lockmgr count of held locks */
|
||||
|
||||
int p_holdcnt; /* If non-zero, don't swap. */
|
||||
struct emul *p_emul; /* Emulation information */
|
||||
const struct emul *p_emul; /* Emulation information */
|
||||
void *p_emuldata; /* Per-process emulation data, or NULL.
|
||||
* Malloc type M_EMULDATA */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user