summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-12-23 02:42:45 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-12-23 02:42:45 +0000
commit495c33c6637657ace4b7a4db6525175efa4b3b85 (patch)
tree45ac916fb790147465b7a358e916dec86bb02779 /sys/kern
parent4d28f11436de1342c38ec5db96ef30e891b18b66 (diff)
use _{NLIST,KERN}_DO_{AOUT,ELF,ECOFF} to select binary types
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/exec_aout.c54
-rw-r--r--sys/kern/exec_conf.c38
-rw-r--r--sys/kern/exec_ecoff.c55
-rw-r--r--sys/kern/exec_elf.c16
-rw-r--r--sys/kern/exec_subr.c45
5 files changed, 73 insertions, 135 deletions
diff --git a/sys/kern/exec_aout.c b/sys/kern/exec_aout.c
index 3a13bd0711c..458f39e598a 100644
--- a/sys/kern/exec_aout.c
+++ b/sys/kern/exec_aout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exec_aout.c,v 1.2 1996/03/03 17:19:36 niklas Exp $ */
+/* $OpenBSD: exec_aout.c,v 1.3 1996/12/23 02:42:41 deraadt Exp $ */
/* $NetBSD: exec_aout.c,v 1.14 1996/02/04 02:15:01 christos Exp $ */
/*
@@ -40,6 +40,8 @@
#include <sys/resourcevar.h>
#include <vm/vm.h>
+#if defined(_KERN_DO_AOUT)
+
/*
* exec_aout_makecmds(): Check if it's an a.out-format executable.
*
@@ -143,7 +145,7 @@ exec_aout_prep_zmagic(p, epp)
epp->ep_daddr + execp->a_data, NULLVP, 0,
VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
- return exec_aout_setup_stack(p, epp);
+ return exec_setup_stack(p, epp);
}
/*
@@ -181,7 +183,7 @@ exec_aout_prep_nmagic(p, epp)
NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, bsize, baddr,
NULLVP, 0, VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
- return exec_aout_setup_stack(p, epp);
+ return exec_setup_stack(p, epp);
}
/*
@@ -224,49 +226,7 @@ exec_aout_prep_omagic(p, epp)
*/
dsize = epp->ep_dsize + execp->a_text - roundup(execp->a_text, NBPG);
epp->ep_dsize = (dsize > 0) ? dsize : 0;
- return exec_aout_setup_stack(p, epp);
+ return exec_setup_stack(p, epp);
}
-/*
- * exec_aout_setup_stack(): Set up the stack segment for an a.out
- * executable.
- *
- * Note that the ep_ssize parameter must be set to be the current stack
- * limit; this is adjusted in the body of execve() to yield the
- * appropriate stack segment usage once the argument length is
- * calculated.
- *
- * This function returns an int for uniformity with other (future) formats'
- * stack setup functions. They might have errors to return.
- */
-
-int
-exec_aout_setup_stack(p, epp)
- struct proc *p;
- struct exec_package *epp;
-{
-
- epp->ep_maxsaddr = USRSTACK - MAXSSIZ;
- epp->ep_minsaddr = USRSTACK;
- epp->ep_ssize = p->p_rlimit[RLIMIT_STACK].rlim_cur;
-
- /*
- * set up commands for stack. note that this takes *two*, one to
- * map the part of the stack which we can access, and one to map
- * the part which we can't.
- *
- * arguably, it could be made into one, but that would require the
- * addition of another mapping proc, which is unnecessary
- *
- * note that in memory, things assumed to be: 0 ....... ep_maxsaddr
- * <stack> ep_minsaddr
- */
- NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero,
- ((epp->ep_minsaddr - epp->ep_ssize) - epp->ep_maxsaddr),
- epp->ep_maxsaddr, NULLVP, 0, VM_PROT_NONE);
- NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, epp->ep_ssize,
- (epp->ep_minsaddr - epp->ep_ssize), NULLVP, 0,
- VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
-
- return 0;
-}
+#endif /* _KERN_DO_AOUT */
diff --git a/sys/kern/exec_conf.c b/sys/kern/exec_conf.c
index 44a7a6aa3af..f2b8fb4128b 100644
--- a/sys/kern/exec_conf.c
+++ b/sys/kern/exec_conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exec_conf.c,v 1.6 1996/06/07 19:38:58 pefo Exp $ */
+/* $OpenBSD: exec_conf.c,v 1.7 1996/12/23 02:42:42 deraadt Exp $ */
/* $NetBSD: exec_conf.c,v 1.16 1995/12/09 05:34:47 cgd Exp $ */
/*
@@ -33,35 +33,13 @@
#include <sys/param.h>
#include <sys/exec.h>
-
-#undef EXEC_SCRIPT /* XXX */
-#define EXEC_SCRIPT /* XXX */
-#undef EXEC_AOUT /* XXX */
-#define EXEC_AOUT /* XXX */
-
-#if defined(COMPAT_ULTRIX) || defined(COMPAT_OSF1)
-#undef EXEC_ECOFF
-#define EXEC_ECOFF
-#endif
-
-#if defined(COMPAT_SVR4) || defined(COMPAT_LINUX)
-#undef EXEC_ELF
-#define EXEC_ELF
-#endif
-
-#ifdef EXEC_SCRIPT
#include <sys/exec_script.h>
-#endif
-#if defined(NATIVE_EXEC_AOUT) || defined(EXEC_AOUT)
-/*#include <sys/exec_aout.h> -- automatically pulled in */
-#endif
-
-#if defined(NATIVE_EXEC_ECOFF) || defined(EXEC_ECOFF)
+#if defined(_KERN_DO_ECOFF)
#include <sys/exec_ecoff.h>
#endif
-#if defined(NATIVE_EXEC_ELF) || defined(EXEC_ELF)
+#if defined(_KERN_DO_ELF)
#include <sys/exec_elf.h>
#endif
@@ -93,16 +71,14 @@ struct execsw execsw[] = {
{ 0, NULL, },
{ 0, NULL, },
#endif
-#ifdef EXEC_SCRIPT
{ MAXINTERP, exec_script_makecmds, }, /* shell scripts */
-#endif
-#ifdef EXEC_AOUT
+#ifdef _KERN_DO_AOUT
{ sizeof(struct exec), exec_aout_makecmds, }, /* a.out binaries */
#endif
-#ifdef EXEC_ECOFF
+#ifdef _KERN_DO_ECOFF
{ ECOFF_HDR_SIZE, exec_ecoff_makecmds, }, /* ecoff binaries */
#endif
-#if defined(NATIVE_EXEC_ELF) || defined(EXEC_ELF)
+#ifdef _KERN_DO_ELF
{ sizeof(Elf32_Ehdr), exec_elf_makecmds, }, /* elf binaries */
#endif
#ifdef COMPAT_LINUX
@@ -113,7 +89,7 @@ struct execsw execsw[] = {
{ XOUT_HDR_SIZE, exec_ibcs2_xout_makecmds, }, /* x.out binaries */
#endif
#ifdef COMPAT_FREEBSD
- { FREEBSD_AOUT_HDR_SIZE, exec_freebsd_aout_makecmds, }, /* a.out */
+ { FREEBSD_AOUT_HDR_SIZE, exec_freebsd_aout_makecmds, }, /* freebsd */
#endif
#ifdef COMPAT_HPUX
{ HPUX_EXEC_HDR_SIZE, exec_hpux_makecmds, }, /* HP-UX a.out */
diff --git a/sys/kern/exec_ecoff.c b/sys/kern/exec_ecoff.c
index 34cfda7fa65..741fecea34d 100644
--- a/sys/kern/exec_ecoff.c
+++ b/sys/kern/exec_ecoff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exec_ecoff.c,v 1.3 1996/05/22 12:05:19 deraadt Exp $ */
+/* $OpenBSD: exec_ecoff.c,v 1.4 1996/12/23 02:42:42 deraadt Exp $ */
/* $NetBSD: exec_ecoff.c,v 1.8 1996/05/19 20:36:06 jonathan Exp $ */
/*
@@ -41,6 +41,8 @@
#include <sys/resourcevar.h>
#include <vm/vm.h>
+#if defined(_KERN_DO_ECOFF)
+
#include <sys/exec_ecoff.h>
int exec_ecoff_prep_omagic __P((struct proc *, struct exec_package *));
@@ -97,49 +99,6 @@ exec_ecoff_makecmds(p, epp)
}
/*
- * exec_ecoff_setup_stack(): Set up the stack segment for an ecoff
- * executable.
- *
- * Note that the ep_ssize parameter must be set to be the current stack
- * limit; this is adjusted in the body of execve() to yield the
- * appropriate stack segment usage once the argument length is
- * calculated.
- *
- * This function returns an int for uniformity with other (future) formats'
- * stack setup functions. They might have errors to return.
- */
-int
-exec_ecoff_setup_stack(p, epp)
- struct proc *p;
- struct exec_package *epp;
-{
-
- epp->ep_maxsaddr = USRSTACK - MAXSSIZ;
- epp->ep_minsaddr = USRSTACK;
- epp->ep_ssize = p->p_rlimit[RLIMIT_STACK].rlim_cur;
-
- /*
- * set up commands for stack. note that this takes *two*, one to
- * map the part of the stack which we can access, and one to map
- * the part which we can't.
- *
- * arguably, it could be made into one, but that would require the
- * addition of another mapping proc, which is unnecessary
- *
- * note that in memory, things assumed to be: 0 ....... ep_maxsaddr
- * <stack> ep_minsaddr
- */
- NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero,
- ((epp->ep_minsaddr - epp->ep_ssize) - epp->ep_maxsaddr),
- epp->ep_maxsaddr, NULLVP, 0, VM_PROT_NONE);
- NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, epp->ep_ssize,
- (epp->ep_minsaddr - epp->ep_ssize), NULLVP, 0,
- VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
-
- return 0;
-}
-
-/*
* exec_ecoff_prep_omagic(): Prepare a ECOFF OMAGIC binary's exec package
*/
int
@@ -168,7 +127,7 @@ exec_ecoff_prep_omagic(p, epp)
ECOFF_SEGMENT_ALIGN(execp, eap->bss_start), NULLVP, 0,
VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
- return exec_ecoff_setup_stack(p, epp);
+ return exec_setup_stack(p, epp);
}
/*
@@ -205,7 +164,7 @@ exec_ecoff_prep_nmagic(p, epp)
ECOFF_SEGMENT_ALIGN(execp, eap->bss_start), NULLVP, 0,
VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
- return exec_ecoff_setup_stack(p, epp);
+ return exec_setup_stack(p, epp);
}
/*
@@ -261,5 +220,7 @@ exec_ecoff_prep_zmagic(p, epp)
ECOFF_SEGMENT_ALIGN(execp, eap->bss_start), NULLVP, 0,
VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
- return exec_ecoff_setup_stack(p, epp);
+ return exec_setup_stack(p, epp);
}
+
+#endif /* _KERN_DO_ECOFF */
diff --git a/sys/kern/exec_elf.c b/sys/kern/exec_elf.c
index 053fdf9cb0a..649a062acc3 100644
--- a/sys/kern/exec_elf.c
+++ b/sys/kern/exec_elf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exec_elf.c,v 1.18 1996/11/24 18:31:25 etheisen Exp $ */
+/* $OpenBSD: exec_elf.c,v 1.19 1996/12/23 02:42:43 deraadt Exp $ */
/*
* Copyright (c) 1996 Per Fogelstrom
@@ -40,6 +40,9 @@
#include <sys/namei.h>
#include <sys/vnode.h>
#include <sys/exec.h>
+
+#if defined(_KERN_DO_ELF)
+
#include <sys/exec_elf.h>
#include <sys/exec_olf.h>
#include <sys/file.h>
@@ -47,13 +50,6 @@
#include <sys/signalvar.h>
#include <sys/stat.h>
-#if defined(COMPAT_LINUX) || defined(COMPAT_SVR4) /*XXX should be */
-#undef EXEC_ELF /*XXX defined in */
-#define EXEC_ELF /*XXX machine/exec.h */
-#endif /*XXX instead ? */
-
-#if defined(NATIVE_EXEC_ELF) || defined(EXEC_ELF)
-
#include <sys/mman.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
@@ -616,7 +612,7 @@ exec_elf_makecmds(p, epp)
free((char *) ph, M_TEMP);
epp->ep_vp->v_flag |= VTEXT;
- return exec_aout_setup_stack(p, epp);
+ return exec_setup_stack(p, epp);
bad:
free((char *) ph, M_TEMP);
@@ -708,4 +704,4 @@ exec_elf_fixup(p, epp)
free((char *) interp, M_TEMP);
return error;
}
-#endif /* NATIVE_EXEC_ELF || EXEC_ELF */
+#endif /* _KERN_DO_ELF */
diff --git a/sys/kern/exec_subr.c b/sys/kern/exec_subr.c
index 2bc891accaa..e8810979a6d 100644
--- a/sys/kern/exec_subr.c
+++ b/sys/kern/exec_subr.c
@@ -38,6 +38,7 @@
#include <sys/filedesc.h>
#include <sys/exec.h>
#include <sys/mman.h>
+#include <sys/resourcevar.h>
#include <vm/vm.h>
@@ -194,3 +195,47 @@ vmcmd_map_zero(p, cmd)
return vm_map_protect(&p->p_vmspace->vm_map, trunc_page(cmd->ev_addr),
round_page(cmd->ev_addr + cmd->ev_len), cmd->ev_prot, FALSE);
}
+
+/*
+ * exec_setup_stack(): Set up the stack segment for an a.out
+ * executable.
+ *
+ * Note that the ep_ssize parameter must be set to be the current stack
+ * limit; this is adjusted in the body of execve() to yield the
+ * appropriate stack segment usage once the argument length is
+ * calculated.
+ *
+ * This function returns an int for uniformity with other (future) formats'
+ * stack setup functions. They might have errors to return.
+ */
+
+int
+exec_setup_stack(p, epp)
+ struct proc *p;
+ struct exec_package *epp;
+{
+
+ epp->ep_maxsaddr = USRSTACK - MAXSSIZ;
+ epp->ep_minsaddr = USRSTACK;
+ epp->ep_ssize = p->p_rlimit[RLIMIT_STACK].rlim_cur;
+
+ /*
+ * set up commands for stack. note that this takes *two*, one to
+ * map the part of the stack which we can access, and one to map
+ * the part which we can't.
+ *
+ * arguably, it could be made into one, but that would require the
+ * addition of another mapping proc, which is unnecessary
+ *
+ * note that in memory, things assumed to be: 0 ....... ep_maxsaddr
+ * <stack> ep_minsaddr
+ */
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero,
+ ((epp->ep_minsaddr - epp->ep_ssize) - epp->ep_maxsaddr),
+ epp->ep_maxsaddr, NULLVP, 0, VM_PROT_NONE);
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, epp->ep_ssize,
+ (epp->ep_minsaddr - epp->ep_ssize), NULLVP, 0,
+ VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
+
+ return 0;
+}