diff options
author | 1996-12-23 02:42:22 +0000 | |
---|---|---|
committer | 1996-12-23 02:42:22 +0000 | |
commit | a398dccb526cb5e3d7d355b866168fa6717962fe (patch) | |
tree | d8a7eda8278953debcb543f4e475588f1841866e /sys/kern/exec_subr.c | |
parent | Import of Openfirmware device drivers for PowerPC port. (diff) | |
download | wireguard-openbsd-a398dccb526cb5e3d7d355b866168fa6717962fe.tar.xz wireguard-openbsd-a398dccb526cb5e3d7d355b866168fa6717962fe.zip |
use _{NLIST,KERN}_DO_{AOUT,ELF,ECOFF} to select binary types
Diffstat (limited to 'sys/kern/exec_subr.c')
-rw-r--r-- | sys/kern/exec_subr.c | 45 |
1 files changed, 45 insertions, 0 deletions
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; +} |