diff options
Diffstat (limited to 'sys/compat')
-rw-r--r-- | sys/compat/freebsd/freebsd_exec.c | 57 | ||||
-rw-r--r-- | sys/compat/freebsd/freebsd_exec.h | 4 | ||||
-rw-r--r-- | sys/compat/linux/linux_exec.c | 8 |
3 files changed, 63 insertions, 6 deletions
diff --git a/sys/compat/freebsd/freebsd_exec.c b/sys/compat/freebsd/freebsd_exec.c index a152b17580f..f8307218d2c 100644 --- a/sys/compat/freebsd/freebsd_exec.c +++ b/sys/compat/freebsd/freebsd_exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: freebsd_exec.c,v 1.4 1996/08/31 09:24:00 pefo Exp $ */ +/* $OpenBSD: freebsd_exec.c,v 1.5 1999/02/10 08:07:19 deraadt Exp $ */ /* $NetBSD: freebsd_exec.c,v 1.2 1996/05/18 16:02:08 christos Exp $ */ /* @@ -39,16 +39,37 @@ #include <sys/exec.h> #include <sys/resourcevar.h> #include <vm/vm.h> +#include <sys/exec_elf.h> +#include <sys/exec_olf.h> #include <machine/freebsd_machdep.h> #include <compat/freebsd/freebsd_syscall.h> #include <compat/freebsd/freebsd_exec.h> +#include <compat/freebsd/freebsd_util.h> extern struct sysent freebsd_sysent[]; extern char *freebsd_syscallnames[]; -struct emul emul_freebsd = { +extern const char freebsd_emul_path[]; + +struct emul emul_aout_freebsd = { + "freebsd", + NULL, + freebsd_sendsig, + FREEBSD_SYS_syscall, + FREEBSD_SYS_MAXSYSCALL, + freebsd_sysent, + freebsd_syscallnames, + 0, + copyargs, + setregs, + NULL, + freebsd_sigcode, + freebsd_esigcode, +}; + +struct emul emul_elf_freebsd = { "freebsd", NULL, freebsd_sendsig, @@ -106,9 +127,39 @@ exec_freebsd_aout_makecmds(p, epp) break; } if (error == 0) - epp->ep_emul = &emul_freebsd; + epp->ep_emul = &emul_aout_freebsd; else kill_vmcmds(&epp->ep_vmcmds); return error; } + +int +freebsd_elf_probe(p, epp, itp, pos, os) + struct proc *p; + struct exec_package *epp; + char *itp; + u_long *pos; + u_int8_t *os; +{ + Elf32_Ehdr *eh = epp->ep_hdr; + char *bp, *brand; + int error; + size_t len; + + brand = elf_check_brand(eh); + if (brand == NULL || strcmp(brand, "FreeBSD")) + return (EINVAL); + if (itp[0]) { + if ((error = emul_find(p, NULL, freebsd_emul_path, itp, &bp, 0))) + return (error); + if ((error = copystr(bp, itp, MAXPATHLEN, &len))) + return (error); + free(bp, M_TEMP); + } + epp->ep_emul = &emul_elf_freebsd; + *pos = ELF32_NO_ADDR; + if (*os == OOS_NULL) + *os = OOS_FREEBSD; + return (0); +} diff --git a/sys/compat/freebsd/freebsd_exec.h b/sys/compat/freebsd/freebsd_exec.h index 6930a10f110..da8e3e50fde 100644 --- a/sys/compat/freebsd/freebsd_exec.h +++ b/sys/compat/freebsd/freebsd_exec.h @@ -1,4 +1,4 @@ -/* $OpenBSD: freebsd_exec.h,v 1.2 1996/08/02 20:34:45 niklas Exp $ */ +/* $OpenBSD: freebsd_exec.h,v 1.3 1999/02/10 08:07:19 deraadt Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -95,6 +95,8 @@ #define FREEBSD_AOUT_HDR_SIZE sizeof(struct exec) int exec_freebsd_aout_makecmds __P((struct proc *, struct exec_package *)); +int freebsd_elf_probe __P((struct proc *, struct exec_package *, char *, + u_long *, u_int8_t *)); extern char freebsd_sigcode[], freebsd_esigcode[]; diff --git a/sys/compat/linux/linux_exec.c b/sys/compat/linux/linux_exec.c index 5002aaa0acf..c14c75ebb0a 100644 --- a/sys/compat/linux/linux_exec.c +++ b/sys/compat/linux/linux_exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: linux_exec.c,v 1.9 1999/01/11 05:12:12 millert Exp $ */ +/* $OpenBSD: linux_exec.c,v 1.10 1999/02/10 08:07:20 deraadt Exp $ */ /* $NetBSD: linux_exec.c,v 1.13 1996/04/05 00:01:10 christos Exp $ */ /* @@ -374,10 +374,14 @@ linux_elf_probe(p, epp, itp, pos, os) u_long *pos; u_int8_t *os; { - char *bp; + Elf32_Ehdr *eh = epp->ep_hdr; + char *bp, *brand; int error; size_t len; + brand = elf_check_brand(eh); + if (brand && strcmp(brand, "Linux")) + return (EINVAL); if (itp[0]) { if ((error = emul_find(p, NULL, linux_emul_path, itp, &bp, 0))) return (error); |