far reaching but relatively minor cleanup and slight reorg of exec code
This commit is contained in:
parent
91b246d5be
commit
957ce06f24
|
@ -37,7 +37,7 @@
|
|||
*
|
||||
* from: Utah Hdr: machdep.c 1.63 91/04/24
|
||||
* from: @(#)machdep.c 7.16 (Berkeley) 6/3/91
|
||||
* $Id: machdep.c,v 1.19 1994/01/08 06:34:01 mycroft Exp $
|
||||
* $Id: machdep.c,v 1.20 1994/01/08 07:14:24 cgd Exp $
|
||||
*/
|
||||
|
||||
#include "param.h"
|
||||
|
@ -1519,7 +1519,6 @@ cpu_exec_aout_prep_oldzmagic(p, epp)
|
|||
struct exec_package *epp;
|
||||
{
|
||||
struct exec *execp = epp->ep_execp;
|
||||
struct exec_vmcmd *ccmdp;
|
||||
|
||||
epp->ep_taddr = 0;
|
||||
epp->ep_tsize = execp->a_text;
|
||||
|
@ -1537,39 +1536,25 @@ cpu_exec_aout_prep_oldzmagic(p, epp)
|
|||
if (epp->ep_vp->v_flag & VTEXT)
|
||||
panic("exec: a VTEXT vnode has writecount != 0\n");
|
||||
#endif
|
||||
epp->ep_vcp = NULL;
|
||||
return ETXTBSY;
|
||||
}
|
||||
epp->ep_vp->v_flag |= VTEXT;
|
||||
|
||||
/* set up command for text segment */
|
||||
epp->ep_vcp = new_vmcmd(vmcmd_map_pagedvn,
|
||||
execp->a_text,
|
||||
epp->ep_taddr,
|
||||
epp->ep_vp,
|
||||
NBPG, /* should this be CLBYTES? */
|
||||
NEW_VMCMD(vmcmd_map_pagedvn, execp->a_text, epp->ep_taddr, epp->ep_vp,
|
||||
NBPG, /* XXX - should NBPG be CLBYTES? */
|
||||
VM_PROT_READ|VM_PROT_EXECUTE);
|
||||
ccmdp = epp->ep_vcp;
|
||||
|
||||
/* set up command for data segment */
|
||||
ccmdp->ev_next = new_vmcmd(vmcmd_map_pagedvn,
|
||||
execp->a_data,
|
||||
epp->ep_daddr,
|
||||
epp->ep_vp,
|
||||
execp->a_text + NBPG, /* should be CLBYTES? */
|
||||
NEW_VMCMD(vmcmd_map_pagedvn, execp->a_data, epp->ep_daddr, epp->ep_vp,
|
||||
execp->a_text + NBPG, /* XXX - should NBPG be CLBYTES? */
|
||||
VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
|
||||
ccmdp = ccmdp->ev_next;
|
||||
|
||||
/* set up command for bss segment */
|
||||
ccmdp->ev_next = new_vmcmd(vmcmd_map_zero,
|
||||
execp->a_bss,
|
||||
epp->ep_daddr + execp->a_data,
|
||||
0,
|
||||
0,
|
||||
VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE);
|
||||
ccmdp = ccmdp->ev_next;
|
||||
NEW_VMCMD(vmcmd_map_zero, execp->a_bss, epp->ep_daddr + execp->a_data,
|
||||
0, 0, VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
|
||||
|
||||
return exec_aout_setup_stack(p, epp, ccmdp);
|
||||
return exec_aout_setup_stack(p, epp);
|
||||
}
|
||||
#endif /* COMPAT_NOMID */
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include <sys/proc.h>
|
||||
#include <sys/user.h>
|
||||
#include <sys/exec.h>
|
||||
#include <sys/exec_aout.h>
|
||||
#include <sys/buf.h>
|
||||
#include <sys/reboot.h>
|
||||
#include <sys/conf.h>
|
||||
|
@ -1191,39 +1192,27 @@ cpu_exec_aout_prep_oldzmagic(p, epp)
|
|||
if (epp->ep_vp->v_flag & VTEXT)
|
||||
panic("exec: a VTEXT vnode has writecount != 0\n");
|
||||
#endif
|
||||
epp->ep_vcp = NULL;
|
||||
return ETXTBSY;
|
||||
}
|
||||
epp->ep_vp->v_flag |= VTEXT;
|
||||
|
||||
/* set up command for text segment */
|
||||
epp->ep_vcp = new_vmcmd(vmcmd_map_pagedvn,
|
||||
execp->a_text,
|
||||
epp->ep_taddr,
|
||||
epp->ep_vp,
|
||||
NBPG, /* XXX should be CLBYTES? */
|
||||
NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_pagedvn, execp->a_text,
|
||||
epp->ep_taddr, epp->ep_vp, NBPG, /* XXX should NBPG be CLBYTES? */
|
||||
VM_PROT_READ|VM_PROT_EXECUTE);
|
||||
ccmdp = epp->ep_vcp;
|
||||
|
||||
/* set up command for data segment */
|
||||
ccmdp->ev_next = new_vmcmd(vmcmd_map_pagedvn,
|
||||
execp->a_data,
|
||||
epp->ep_daddr,
|
||||
epp->ep_vp,
|
||||
execp->a_text + NBPG, /* XXX should be CLBYTES? */
|
||||
NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_pagedvn, execp->a_data,
|
||||
epp->ep_daddr, epp->ep_vp,
|
||||
execp->a_text + NBPG, /* XXX should NBPG be CLBYTES? */
|
||||
VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
|
||||
ccmdp = ccmdp->ev_next;
|
||||
|
||||
/* set up command for bss segment */
|
||||
ccmdp->ev_next = new_vmcmd(vmcmd_map_zero,
|
||||
execp->a_bss,
|
||||
epp->ep_daddr + execp->a_data,
|
||||
0,
|
||||
0,
|
||||
NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, execp->a_bss,
|
||||
epp->ep_daddr + execp->a_data, 0, 0,
|
||||
VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
|
||||
ccmdp = ccmdp->ev_next;
|
||||
|
||||
return exec_aout_setup_stack(p, epp, ccmdp);
|
||||
return exec_aout_setup_stack(p, epp);
|
||||
}
|
||||
#endif /* COMPAT_NOMID */
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $Id: files,v 1.33 1993/12/22 12:48:25 cgd Exp $
|
||||
# $Id: files,v 1.34 1994/01/08 07:14:47 cgd Exp $
|
||||
#
|
||||
ddb/db_access.c optional ddb
|
||||
ddb/db_aout.c optional ddb
|
||||
|
@ -25,6 +25,7 @@ isofs/isofs_util.c optional isofs
|
|||
isofs/isofs_vfsops.c optional isofs
|
||||
isofs/isofs_vnops.c optional isofs
|
||||
kern/exec_aout.c standard
|
||||
kern/exec_subr.c standard
|
||||
kern/init_main.c standard
|
||||
kern/init_sysent.c standard
|
||||
kern/kern_acct.c standard
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $Id: files.oldconf,v 1.33 1993/12/22 12:48:25 cgd Exp $
|
||||
# $Id: files.oldconf,v 1.34 1994/01/08 07:14:47 cgd Exp $
|
||||
#
|
||||
ddb/db_access.c optional ddb
|
||||
ddb/db_aout.c optional ddb
|
||||
|
@ -25,6 +25,7 @@ isofs/isofs_util.c optional isofs
|
|||
isofs/isofs_vfsops.c optional isofs
|
||||
isofs/isofs_vnops.c optional isofs
|
||||
kern/exec_aout.c standard
|
||||
kern/exec_subr.c standard
|
||||
kern/init_main.c standard
|
||||
kern/init_sysent.c standard
|
||||
kern/kern_acct.c standard
|
||||
|
|
|
@ -27,32 +27,19 @@
|
|||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: exec_aout.c,v 1.2 1993/12/12 19:26:18 deraadt Exp $
|
||||
* $Id: exec_aout.c,v 1.3 1994/01/08 07:14:58 cgd Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/filedesc.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/namei.h>
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/exec.h>
|
||||
#include <sys/resourcevar.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include <vm/vm.h>
|
||||
#include <vm/vm_param.h>
|
||||
#include <vm/vm_map.h>
|
||||
#include <vm/vm_kern.h>
|
||||
#include <vm/vm_pager.h>
|
||||
|
||||
#include <machine/cpu.h>
|
||||
#include <machine/reg.h>
|
||||
#include <sys/exec_aout.h>
|
||||
#include <machine/exec.h>
|
||||
|
||||
/*
|
||||
|
@ -101,8 +88,8 @@ exec_aout_makecmds(p, epp)
|
|||
error = cpu_exec_aout_makecmds(p, epp);
|
||||
}
|
||||
|
||||
if (error && epp->ep_vcp)
|
||||
kill_vmcmd(&epp->ep_vcp);
|
||||
if (error)
|
||||
KILL_VMCMDS(&epp->ep_vmcmds);
|
||||
|
||||
bad:
|
||||
|
||||
|
@ -128,7 +115,6 @@ exec_aout_prep_zmagic(p, epp)
|
|||
struct exec_package *epp;
|
||||
{
|
||||
struct exec *execp = epp->ep_execp;
|
||||
struct exec_vmcmd *ccmdp;
|
||||
|
||||
epp->ep_taddr = USRTEXT;
|
||||
epp->ep_tsize = execp->a_text;
|
||||
|
@ -147,39 +133,25 @@ exec_aout_prep_zmagic(p, epp)
|
|||
if (epp->ep_vp->v_flag & VTEXT)
|
||||
panic("exec: a VTEXT vnode has writecount != 0\n");
|
||||
#endif
|
||||
epp->ep_vcp = NULL;
|
||||
return ETXTBSY;
|
||||
}
|
||||
epp->ep_vp->v_flag |= VTEXT;
|
||||
|
||||
/* set up command for text segment */
|
||||
epp->ep_vcp = new_vmcmd(vmcmd_map_pagedvn,
|
||||
execp->a_text,
|
||||
epp->ep_taddr,
|
||||
epp->ep_vp,
|
||||
0,
|
||||
VM_PROT_READ | VM_PROT_EXECUTE);
|
||||
ccmdp = epp->ep_vcp;
|
||||
NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_pagedvn, execp->a_text,
|
||||
epp->ep_taddr, epp->ep_vp, 0, VM_PROT_READ|VM_PROT_EXECUTE);
|
||||
|
||||
/* set up command for data segment */
|
||||
ccmdp->ev_next = new_vmcmd(vmcmd_map_pagedvn,
|
||||
execp->a_data,
|
||||
epp->ep_daddr,
|
||||
epp->ep_vp,
|
||||
execp->a_text,
|
||||
NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_pagedvn, execp->a_data,
|
||||
epp->ep_daddr, epp->ep_vp, execp->a_text,
|
||||
VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
|
||||
ccmdp = ccmdp->ev_next;
|
||||
|
||||
/* set up command for bss segment */
|
||||
ccmdp->ev_next = new_vmcmd(vmcmd_map_zero,
|
||||
execp->a_bss,
|
||||
epp->ep_daddr + execp->a_data,
|
||||
0,
|
||||
0,
|
||||
NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, execp->a_bss,
|
||||
epp->ep_daddr + execp->a_data, 0, 0,
|
||||
VM_PROT_READ|VM_PROT_WRITE |VM_PROT_EXECUTE);
|
||||
ccmdp = ccmdp->ev_next;
|
||||
|
||||
return exec_aout_setup_stack(p, epp, ccmdp);
|
||||
return exec_aout_setup_stack(p, epp);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -192,7 +164,6 @@ exec_aout_prep_nmagic(p, epp)
|
|||
struct exec_package *epp;
|
||||
{
|
||||
struct exec *execp = epp->ep_execp;
|
||||
struct exec_vmcmd *ccmdp;
|
||||
long bsize, baddr;
|
||||
|
||||
epp->ep_taddr = USRTEXT;
|
||||
|
@ -202,33 +173,23 @@ exec_aout_prep_nmagic(p, epp)
|
|||
epp->ep_entry = execp->a_entry;
|
||||
|
||||
/* set up command for text segment */
|
||||
epp->ep_vcp = new_vmcmd(vmcmd_map_readvn,
|
||||
execp->a_text,
|
||||
epp->ep_taddr,
|
||||
epp->ep_vp,
|
||||
sizeof(struct exec),
|
||||
NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn, execp->a_text,
|
||||
epp->ep_taddr, epp->ep_vp, sizeof(struct exec),
|
||||
VM_PROT_READ|VM_PROT_EXECUTE);
|
||||
ccmdp = epp->ep_vcp;
|
||||
|
||||
/* set up command for data segment */
|
||||
ccmdp->ev_next = new_vmcmd(vmcmd_map_readvn,
|
||||
execp->a_data,
|
||||
epp->ep_daddr,
|
||||
epp->ep_vp,
|
||||
execp->a_text + sizeof(struct exec),
|
||||
NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn, execp->a_data,
|
||||
epp->ep_daddr, epp->ep_vp, execp->a_text + sizeof(struct exec),
|
||||
VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
|
||||
ccmdp = ccmdp->ev_next;
|
||||
|
||||
/* set up command for bss segment */
|
||||
baddr = roundup(epp->ep_daddr + execp->a_data, NBPG);
|
||||
bsize = epp->ep_daddr + epp->ep_dsize - baddr;
|
||||
if (bsize > 0) {
|
||||
ccmdp->ev_next = new_vmcmd(vmcmd_map_zero, bsize, baddr,
|
||||
if (bsize > 0)
|
||||
NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, bsize, baddr,
|
||||
0, 0, VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE);
|
||||
ccmdp = ccmdp->ev_next;
|
||||
}
|
||||
|
||||
return exec_aout_setup_stack(p, epp, ccmdp);
|
||||
return exec_aout_setup_stack(p, epp);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -241,7 +202,6 @@ exec_aout_prep_omagic(p, epp)
|
|||
struct exec_package *epp;
|
||||
{
|
||||
struct exec *execp = epp->ep_execp;
|
||||
struct exec_vmcmd *ccmdp;
|
||||
long bsize, baddr;
|
||||
|
||||
epp->ep_taddr = USRTEXT;
|
||||
|
@ -251,24 +211,18 @@ exec_aout_prep_omagic(p, epp)
|
|||
epp->ep_entry = execp->a_entry;
|
||||
|
||||
/* set up command for text and data segments */
|
||||
epp->ep_vcp = new_vmcmd(vmcmd_map_readvn,
|
||||
execp->a_text + execp->a_data,
|
||||
epp->ep_taddr,
|
||||
epp->ep_vp,
|
||||
sizeof(struct exec),
|
||||
VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE);
|
||||
ccmdp = epp->ep_vcp;
|
||||
NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn,
|
||||
execp->a_text + execp->a_data, epp->ep_taddr, epp->ep_vp,
|
||||
sizeof(struct exec), VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
|
||||
|
||||
/* set up command for bss segment */
|
||||
baddr = roundup(epp->ep_daddr + execp->a_data, NBPG);
|
||||
bsize = epp->ep_daddr + epp->ep_dsize - baddr;
|
||||
if (bsize > 0) {
|
||||
ccmdp->ev_next = new_vmcmd(vmcmd_map_zero, bsize, baddr,
|
||||
if (bsize > 0)
|
||||
NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, bsize, baddr,
|
||||
0, 0, VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
|
||||
ccmdp = ccmdp->ev_next;
|
||||
}
|
||||
|
||||
return exec_aout_setup_stack(p, epp, ccmdp);
|
||||
return exec_aout_setup_stack(p, epp);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -279,13 +233,15 @@ exec_aout_prep_omagic(p, epp)
|
|||
* 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, ccmdp)
|
||||
exec_aout_setup_stack(p, epp)
|
||||
struct proc *p;
|
||||
struct exec_package *epp;
|
||||
struct exec_vmcmd *ccmdp;
|
||||
{
|
||||
|
||||
epp->ep_maxsaddr = USRSTACK - MAXSSIZ;
|
||||
|
@ -303,18 +259,11 @@ exec_aout_setup_stack(p, epp, ccmdp)
|
|||
* note that in memory, things assumed to be: 0 ....... ep_maxsaddr
|
||||
* <stack> ep_minsaddr
|
||||
*/
|
||||
ccmdp->ev_next = new_vmcmd(vmcmd_map_zero,
|
||||
NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero,
|
||||
((epp->ep_minsaddr - epp->ep_ssize) - epp->ep_maxsaddr),
|
||||
epp->ep_maxsaddr,
|
||||
0,
|
||||
0,
|
||||
VM_PROT_NONE);
|
||||
ccmdp = ccmdp->ev_next;
|
||||
ccmdp->ev_next = new_vmcmd(vmcmd_map_zero,
|
||||
epp->ep_ssize,
|
||||
(epp->ep_minsaddr - epp->ep_ssize),
|
||||
0,
|
||||
0,
|
||||
epp->ep_maxsaddr, 0, 0, VM_PROT_NONE);
|
||||
NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, epp->ep_ssize,
|
||||
(epp->ep_minsaddr - epp->ep_ssize), 0, 0,
|
||||
VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -0,0 +1,212 @@
|
|||
/*
|
||||
* Copyright (c) 1993 Christopher G. Demetriou
|
||||
* 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. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Christopher G. Demetriou.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software withough 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.
|
||||
*
|
||||
* $Id: exec_subr.c,v 1.1 1994/01/08 07:15:02 cgd Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/exec.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include <vm/vm.h>
|
||||
#include <vm/vm_user.h>
|
||||
|
||||
#ifdef EXEC_DEBUG
|
||||
/*
|
||||
* new_vmcmd():
|
||||
* create a new vmcmd structure and fill in its fields based
|
||||
* on function call arguments. make sure objects ref'd by
|
||||
* the vmcmd are 'held'.
|
||||
*
|
||||
* If not debugging, this is a macro, so it's expanded inline.
|
||||
*/
|
||||
|
||||
void
|
||||
new_vmcmd(evsp, proc, len, addr, vp, offset, prot)
|
||||
struct exec_vmcmd_set *evsp;
|
||||
int (*proc) __P((struct proc * p, struct exec_vmcmd *));
|
||||
u_long len;
|
||||
u_long addr;
|
||||
struct vnode *vp;
|
||||
u_long offset;
|
||||
u_int prot;
|
||||
{
|
||||
struct exec_vmcmd *vcp;
|
||||
|
||||
if (evsp->evs_used >= evsp->evs_cnt)
|
||||
vmcmdset_extend(evsp);
|
||||
vcp = &evsp->evs_cmds[evsp->evs_used++];
|
||||
vcp->ev_proc = proc;
|
||||
vcp->ev_len = len;
|
||||
vcp->ev_addr = addr;
|
||||
if ((vcp->ev_vp = vp) != NULL)
|
||||
vref(vp);
|
||||
vcp->ev_offset = offset;
|
||||
vcp->ev_prot = prot;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
vmcmdset_extend(evsp)
|
||||
struct exec_vmcmd_set *evsp;
|
||||
{
|
||||
struct exec_vmcmd *nvcp;
|
||||
u_int ocnt;
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
if (evsp->evs_used < evsp->evs_cnt)
|
||||
panic("vmcmdset_extend: not necessary");
|
||||
#endif
|
||||
|
||||
/* figure out number of entries in new set */
|
||||
ocnt = evsp->evs_cnt;
|
||||
evsp->evs_cnt += ocnt ? ocnt : EXEC_DEFAULT_VMCMD_SETSIZE;
|
||||
|
||||
/* allocate it */
|
||||
MALLOC(nvcp, struct exec_vmcmd *,
|
||||
(evsp->evs_cnt * sizeof(struct exec_vmcmd)), M_EXEC, M_WAITOK);
|
||||
|
||||
/* free the old struct, if there was one, and record the new one */
|
||||
if (ocnt) {
|
||||
bcopy(evsp->evs_cmds, nvcp, (ocnt * sizeof(struct exec_vmcmd)));
|
||||
FREE(evsp->evs_cmds, M_EXEC);
|
||||
}
|
||||
evsp->evs_cmds = nvcp;
|
||||
}
|
||||
|
||||
#ifdef EXEC_DEBUG
|
||||
void
|
||||
kill_vmcmds(evsp)
|
||||
struct exec_vmcmd_set *evsp;
|
||||
{
|
||||
struct exec_vmcmd *vcp;
|
||||
int i;
|
||||
|
||||
if (evsp->evs_cnt == 0)
|
||||
return;
|
||||
|
||||
for (i = 0; i < evsp->evs_used; i++) {
|
||||
vcp = &evsp->evs_cmds[i];
|
||||
if (vcp->ev_vp != NULLVP)
|
||||
vrele(vcp->ev_vp);
|
||||
}
|
||||
evsp->evs_used = evsp->evs_cnt = 0;
|
||||
FREE(evsp->evs_cmds, M_EXEC);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* vmcmd_map_pagedvn():
|
||||
* handle vmcmd which specifies that a vnode should be mmap'd.
|
||||
* appropriate for handling demand-paged text and data segments.
|
||||
*/
|
||||
|
||||
int
|
||||
vmcmd_map_pagedvn(p, cmd)
|
||||
struct proc *p;
|
||||
struct exec_vmcmd *cmd;
|
||||
{
|
||||
/*
|
||||
* note that if you're going to map part of an process as being
|
||||
* paged from a vnode, that vnode had damn well better be marked as
|
||||
* VTEXT. that's handled in the routine which sets up the vmcmd to
|
||||
* call this routine.
|
||||
*/
|
||||
#ifdef EXEC_DEBUG
|
||||
printf("vmcmd_map_pagedvn: mapping file %x+%x into mem %x+%x (%x/%x)\n",
|
||||
cmd->ev_offset, cmd->ev_len, cmd->ev_addr, cmd->ev_len,
|
||||
cmd->ev_prot, VM_PROT_ALL);
|
||||
#endif
|
||||
return vm_mmap(&p->p_vmspace->vm_map, &cmd->ev_addr, cmd->ev_len,
|
||||
cmd->ev_prot, VM_PROT_ALL, MAP_FIXED|MAP_FILE|MAP_COPY,
|
||||
cmd->ev_vp, cmd->ev_offset);
|
||||
}
|
||||
|
||||
/*
|
||||
* vmcmd_map_readvn():
|
||||
* handle vmcmd which specifies that a vnode should be read from.
|
||||
* appropriate for non-demand-paged text/data segments, i.e. impure
|
||||
* objects (a la OMAGIC and NMAGIC).
|
||||
*/
|
||||
int
|
||||
vmcmd_map_readvn(p, cmd)
|
||||
struct proc *p;
|
||||
struct exec_vmcmd *cmd;
|
||||
{
|
||||
int error;
|
||||
|
||||
#ifdef EXEC_DEBUG
|
||||
printf("vmcmd_map_readdvn: reading file %x+%x into mem %x+%x (%x/%x)\n",
|
||||
cmd->ev_offset, cmd->ev_len, cmd->ev_addr, cmd->ev_len,
|
||||
cmd->ev_prot, VM_PROT_ALL);
|
||||
#endif
|
||||
error = vm_allocate(&p->p_vmspace->vm_map, &cmd->ev_addr,
|
||||
cmd->ev_len, 0);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
error = vn_rdwr(UIO_READ, cmd->ev_vp, (caddr_t)cmd->ev_addr,
|
||||
cmd->ev_len, cmd->ev_offset, UIO_USERSPACE, IO_UNIT|IO_NODELOCKED,
|
||||
p->p_ucred, (int *)0, p);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
return vm_protect(&p->p_vmspace->vm_map, cmd->ev_addr, cmd->ev_len,
|
||||
FALSE, cmd->ev_prot);
|
||||
}
|
||||
|
||||
/*
|
||||
* vmcmd_map_zero():
|
||||
* handle vmcmd which specifies a zero-filled address space region. The
|
||||
* address range must be first allocated, then protected appropriately.
|
||||
*/
|
||||
|
||||
int
|
||||
vmcmd_map_zero(p, cmd)
|
||||
struct proc *p;
|
||||
struct exec_vmcmd *cmd;
|
||||
{
|
||||
int error;
|
||||
|
||||
#ifdef EXEC_DEBUG
|
||||
printf("vmcmd_map_zero: mapping into addr %x for len %x (%x/%x)\n",
|
||||
cmd->ev_addr, cmd->ev_len, cmd->ev_prot, VM_PROT_ALL);
|
||||
#endif
|
||||
error = vm_allocate(&p->p_vmspace->vm_map, &cmd->ev_addr,
|
||||
cmd->ev_len, 0);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
return vm_protect(&p->p_vmspace->vm_map, cmd->ev_addr, cmd->ev_len,
|
||||
FALSE, cmd->ev_prot);
|
||||
}
|
|
@ -1 +1 @@
|
|||
revision 1.34 intentionally removed
|
||||
revision 1.35 intentionally removed
|
||||
|
|
|
@ -1 +1 @@
|
|||
revision 1.21 intentionally removed
|
||||
revision 1.22 intentionally removed
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (c) 1993 Christopher G. Demetriou
|
||||
* 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. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Christopher G. Demetriou.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software withough 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.
|
||||
*
|
||||
* $Id: exec_aout.h,v 1.1 1994/01/08 07:15:25 cgd Exp $
|
||||
*/
|
||||
|
||||
#ifndef _SYS_EXEC_AOUT_H_
|
||||
#define _SYS_EXEC_AOUT_H_
|
||||
|
||||
#ifdef KERNEL
|
||||
|
||||
/* the "a.out" format's entry in the exec switch */
|
||||
int exec_aout_makecmds __P((struct proc *, struct exec_package *));
|
||||
|
||||
/* functions which prepare various a.out executable types */
|
||||
int exec_aout_prep_zmagic __P((struct proc *, struct exec_package *));
|
||||
int exec_aout_prep_nmagic __P((struct proc *, struct exec_package *));
|
||||
int exec_aout_prep_omagic __P((struct proc *, struct exec_package *));
|
||||
int exec_aout_setup_stack __P((struct proc *, struct exec_package *));
|
||||
|
||||
#endif /* KERNEL */
|
||||
#endif /* !_SYS_EXEC_AOUT_H_ */
|
Loading…
Reference in New Issue