diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/i386/conf/GENERIC | 3 | ||||
-rw-r--r-- | sys/arch/i386/conf/files.i386 | 5 | ||||
-rw-r--r-- | sys/arch/i386/i386/trap.c | 8 | ||||
-rw-r--r-- | sys/compat/aout/compat_aout.c | 195 | ||||
-rw-r--r-- | sys/compat/aout/files.aout | 6 | ||||
-rw-r--r-- | sys/compat/common/Makefile | 6 | ||||
-rw-r--r-- | sys/kern/exec_aout.c | 8 |
7 files changed, 224 insertions, 7 deletions
diff --git a/sys/arch/i386/conf/GENERIC b/sys/arch/i386/conf/GENERIC index 46fb6586c3c..c19fb519102 100644 --- a/sys/arch/i386/conf/GENERIC +++ b/sys/arch/i386/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.343 2003/06/08 00:42:23 miod Exp $ +# $OpenBSD: GENERIC,v 1.344 2003/06/24 22:45:33 espie Exp $ # $NetBSD: GENERIC,v 1.48 1996/05/20 18:17:23 mrg Exp $ # # GENERIC -- everything that's currently supported @@ -30,6 +30,7 @@ option COMPAT_IBCS2 # binary compatibility with SCO and ISC option COMPAT_LINUX # binary compatibility with Linux option COMPAT_FREEBSD # binary compatibility with FreeBSD option COMPAT_BSDOS # binary compatibility with BSD/OS +option COMPAT_AOUT # a.out binaries are emulated #option NTFS # Experimental NTFS support diff --git a/sys/arch/i386/conf/files.i386 b/sys/arch/i386/conf/files.i386 index bd9c620e6fb..0d7002baf43 100644 --- a/sys/arch/i386/conf/files.i386 +++ b/sys/arch/i386/conf/files.i386 @@ -1,4 +1,4 @@ -# $OpenBSD: files.i386,v 1.104 2003/05/14 22:53:59 tedu Exp $ +# $OpenBSD: files.i386,v 1.105 2003/06/24 22:45:33 espie Exp $ # $NetBSD: files.i386,v 1.73 1996/05/07 00:58:36 thorpej Exp $ # # new style config file for i386 architecture @@ -223,6 +223,9 @@ file arch/i386/isa/joy_isapnp.c joy_isapnp # VM86 mode file arch/i386/i386/vm86.c vm86 +# a.out binary compatibility (COMPAT_AOUT) +include "../../../compat/aout/files.aout" + # SVR4 binary compatibility (COMPAT_SVR4) include "../../../compat/svr4/files.svr4" file arch/i386/i386/svr4_machdep.c compat_svr4 diff --git a/sys/arch/i386/i386/trap.c b/sys/arch/i386/i386/trap.c index e0ed74e9708..16b63c1ad1e 100644 --- a/sys/arch/i386/i386/trap.c +++ b/sys/arch/i386/i386/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.58 2003/06/02 23:27:47 millert Exp $ */ +/* $OpenBSD: trap.c,v 1.59 2003/06/24 22:45:33 espie Exp $ */ /* $NetBSD: trap.c,v 1.95 1996/05/05 06:50:02 mycroft Exp $ */ /*- @@ -87,6 +87,9 @@ extern struct emul emul_aout_freebsd, emul_elf_freebsd; #ifdef COMPAT_BSDOS extern struct emul emul_bsdos; #endif +#ifdef COMPAT_AOUT +extern struct emul emul_aout; +#endif #include "npx.h" @@ -644,6 +647,9 @@ syscall(frame) && p->p_emul != &emul_aout_freebsd && p->p_emul != &emul_elf_freebsd #endif +#ifdef COMPAT_AOUT + && p->p_emul != &emul_aout +#endif #ifdef COMPAT_BSDOS && p->p_emul != &emul_bsdos #endif diff --git a/sys/compat/aout/compat_aout.c b/sys/compat/aout/compat_aout.c new file mode 100644 index 00000000000..075524cde75 --- /dev/null +++ b/sys/compat/aout/compat_aout.c @@ -0,0 +1,195 @@ +/* $OpenBSD: compat_aout.c,v 1.1 2003/06/24 22:45:33 espie Exp $ */ + +/* + * Copyright (c) 2003 Marc Espie + * 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. 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. + * + */ +#include <sys/param.h> +#include <sys/syscall.h> +#include <sys/signalvar.h> +#include <sys/mount.h> +#include <sys/syscallargs.h> +#include <sys/fcntl.h> +#include <compat/common/compat_util.h> + +void aout_compat_setup(struct exec_package *epp); + +extern char sigcode[], esigcode[]; + +struct sysent aout_sysent[SYS_MAXSYSCALL]; + +struct emul emul_aout = { + "native", + NULL, + sendsig, + SYS_syscall, + SYS_MAXSYSCALL, + NULL, +#ifdef SYSCALL_DEBUG + syscallnames, +#else + NULL, +#endif + 0, + copyargs, + setregs, + NULL, + sigcode, + esigcode, +}; + +#ifdef syscallarg +#undef syscallarg +#endif + +#define syscallarg(x) \ + union { \ + register_t pad; \ + struct { x datum; } le; \ + struct { \ + int8_t pad[ (sizeof (register_t) < sizeof (x)) \ + ? 0 \ + : sizeof (register_t) - sizeof (x)]; \ + x datum; \ + } be; \ + } + + +struct aout_sys_open_args { + syscallarg(char *) path; + syscallarg(int) flags; + syscallarg(int) mode; +}; + +struct aout_sys_link_args { + syscallarg(char *) path; + syscallarg(char *) link; +}; + +struct aout_sys_unlink_args { + syscallarg(char *) path; +}; + +struct aout_sys_rename_args { + syscallarg(char *) from; + syscallarg(char *) to; +}; + +int aout_sys_open(struct proc *, void *, register_t *); +int aout_sys_link(struct proc *, void *, register_t *); +int aout_sys_unlink(struct proc *, void *, register_t *); +int aout_sys_rename(struct proc *, void *, register_t *); + +const char aout_path[] = "/emul/a.out"; + +#define AOUT_CHECK_ALT_EXIST(p, sgp, path) \ + CHECK_ALT_EXIST(p, sgp, aout_path, path) + +#define AOUT_CHECK_ALT_CREAT(p, sgp, path) \ + CHECK_ALT_CREAT(p, sgp, aout_path, path) + +/* XXX We just translate enough calls to allow ldconfig and ld.so to work. */ + +void +aout_compat_setup(struct exec_package *epp) +{ + if (emul_aout.e_sysent == NULL) { + memcpy(aout_sysent, sysent, sizeof aout_sysent); + aout_sysent[SYS_open].sy_call = aout_sys_open; + aout_sysent[SYS_link].sy_call = aout_sys_link; + aout_sysent[SYS_unlink].sy_call = aout_sys_unlink; + aout_sysent[SYS_rename].sy_call = aout_sys_rename; + emul_aout.e_sysent = aout_sysent; + } + epp->ep_emul = &emul_aout; +} + +int +aout_sys_open(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct aout_sys_open_args /* { + syscallarg(char *) path; + syscallarg(int) flags; + syscallarg(int) mode; + } */ *uap = v; + caddr_t sg = stackgap_init(p->p_emul); + + if (SCARG(uap, flags) & O_CREAT) + AOUT_CHECK_ALT_CREAT(p, &sg, SCARG(uap, path)); + else + AOUT_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + return sys_open(p, uap, retval); +} + +int +aout_sys_link(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct aout_sys_link_args /* { + syscallarg(char *) path; + syscallarg(char *) link; + } */ *uap = v; + caddr_t sg = stackgap_init(p->p_emul); + + AOUT_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + AOUT_CHECK_ALT_CREAT(p, &sg, SCARG(uap, link)); + return sys_link(p, uap, retval); +} + +int +aout_sys_unlink(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct aout_sys_unlink_args /* { + syscallarg(char *) path; + } */ *uap = v; + caddr_t sg = stackgap_init(p->p_emul); + + AOUT_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + return sys_unlink(p, uap, retval); +} + + +int +aout_sys_rename(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct aout_sys_rename_args /* { + syscallarg(char *) from; + syscallarg(char *) to; + } */ *uap = v; + caddr_t sg = stackgap_init(p->p_emul); + + AOUT_CHECK_ALT_EXIST(p, &sg, SCARG(uap, from)); + AOUT_CHECK_ALT_CREAT(p, &sg, SCARG(uap, to)); + return sys_rename(p, uap, retval); +} diff --git a/sys/compat/aout/files.aout b/sys/compat/aout/files.aout new file mode 100644 index 00000000000..131b526ea60 --- /dev/null +++ b/sys/compat/aout/files.aout @@ -0,0 +1,6 @@ +# $OpenBSD: files.aout,v 1.1 2003/06/24 22:45:33 espie Exp $ +# +# machine-independent a.out compat code. +# Included by ports that need it. + +file compat/aout/compat_aout.c compat_aout diff --git a/sys/compat/common/Makefile b/sys/compat/common/Makefile index 558d5d3898c..49e3098dc34 100644 --- a/sys/compat/common/Makefile +++ b/sys/compat/common/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.13 2003/01/30 03:29:49 millert Exp $ +# $OpenBSD: Makefile,v 1.14 2003/06/24 22:45:33 espie Exp $ # $NetBSD: Makefile,v 1.8 1996/05/18 15:52:19 christos Exp $ LIB= compat @@ -9,8 +9,8 @@ MACHINE_ARCH= ${XMACHINE_ARCH} .PATH: ${COMPATDIR} -SRCS= compat_exec.c compat_util.c compat_dir.c compat_vm.c kern_exit_43.c \ - kern_ipc_23.c kern_info_09.c kern_info_43.c \ +SRCS= compat_exec.c compat_util.c compat_dir.c compat_vm.c \ + kern_exit_43.c kern_ipc_23.c kern_info_09.c kern_info_43.c \ kern_resource_43.c kern_sig_43.c tty_43.c uipc_syscalls_43.c \ vfs_syscalls_25.c vfs_syscalls_43.c vm_43.c diff --git a/sys/kern/exec_aout.c b/sys/kern/exec_aout.c index 515928f61ba..d385246e109 100644 --- a/sys/kern/exec_aout.c +++ b/sys/kern/exec_aout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_aout.c,v 1.8 2002/07/26 23:32:50 deraadt Exp $ */ +/* $OpenBSD: exec_aout.c,v 1.9 2003/06/24 22:45:33 espie Exp $ */ /* $NetBSD: exec_aout.c,v 1.14 1996/02/04 02:15:01 christos Exp $ */ /* @@ -41,6 +41,9 @@ #include <uvm/uvm_extern.h> #if defined(_KERN_DO_AOUT) +#if defined(COMPAT_AOUT) +void aout_compat_setup(struct exec_package *epp); +#endif /* * exec_aout_makecmds(): Check if it's an a.out-format executable. @@ -89,6 +92,9 @@ exec_aout_makecmds(p, epp) if (error) kill_vmcmds(&epp->ep_vmcmds); +#ifdef COMPAT_AOUT + aout_compat_setup(epp); +#endif return error; } |