diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1999-02-10 08:07:21 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1999-02-10 08:07:21 +0000 |
commit | 312b63cab3976ffcb3290a469bbf55b90da4559e (patch) | |
tree | c245105e2e3e6c2682cb15f477fec70558a3286c /sys/compat/freebsd | |
parent | 46635a71c2421fe5bc67f03ee208a6a43ff7ea17 (diff) |
branding support and freebsd elf
Diffstat (limited to 'sys/compat/freebsd')
-rw-r--r-- | sys/compat/freebsd/freebsd_exec.c | 57 | ||||
-rw-r--r-- | sys/compat/freebsd/freebsd_exec.h | 4 |
2 files changed, 57 insertions, 4 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[]; |