diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 2002-10-06 22:39:26 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 2002-10-06 22:39:26 +0000 |
commit | 44b633232be6963a2c75e1d9716f0037d16c3e1c (patch) | |
tree | 01bc33c8b5d00e096f0cc5ae3358181628fa2306 /sys/kern | |
parent | a7af6223a39ac404f0b0fc2508b0edb25083a166 (diff) |
Move out the execution of vmcmds into a separate function.
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/exec_elf.c | 25 | ||||
-rw-r--r-- | sys/kern/exec_subr.c | 39 | ||||
-rw-r--r-- | sys/kern/kern_exec.c | 25 |
3 files changed, 42 insertions, 47 deletions
diff --git a/sys/kern/exec_elf.c b/sys/kern/exec_elf.c index 7ecba4b234b..d86ef335654 100644 --- a/sys/kern/exec_elf.c +++ b/sys/kern/exec_elf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_elf.c,v 1.41 2002/09/23 01:41:09 art Exp $ */ +/* $OpenBSD: exec_elf.c,v 1.42 2002/10/06 22:39:25 art Exp $ */ /* * Copyright (c) 1996 Per Fogelstrom @@ -661,13 +661,12 @@ int ELFNAME2(exec,fixup)(struct proc *p, struct exec_package *epp) { char *interp; - int error, i; + int error; struct elf_args *ap; AuxInfo ai[ELF_AUX_ENTRIES], *a; Elf_Addr pos = epp->ep_interp_pos; - struct exec_vmcmd *base_vc; - if (epp->ep_interp == 0) { + if (epp->ep_interp == NULL) { return (0); } @@ -683,23 +682,7 @@ ELFNAME2(exec,fixup)(struct proc *p, struct exec_package *epp) /* * We have to do this ourselves... */ - base_vc = NULL; - for (i = 0; i < epp->ep_vmcmds.evs_used && !error; i++) { - struct exec_vmcmd *vcp; - vcp = &epp->ep_vmcmds.evs_cmds[i]; - - if (vcp->ev_flags & VMCMD_RELATIVE) { -#ifdef DIAGNOSTIC - if (base_vc == NULL) - panic("sys_execve: RELATIVE without base"); -#endif - vcp->ev_addr += base_vc->ev_addr; - } - error = (*vcp->ev_proc)(p, vcp); - if (vcp->ev_flags & VMCMD_BASE) - base_vc = vcp; - } - kill_vmcmds(&epp->ep_vmcmds); + error = exec_process_vmcmds(p, epp); /* * Push extra arguments on the stack needed by dynamically diff --git a/sys/kern/exec_subr.c b/sys/kern/exec_subr.c index a76ffdf3ad2..57e87626bb8 100644 --- a/sys/kern/exec_subr.c +++ b/sys/kern/exec_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_subr.c,v 1.20 2002/10/02 23:56:32 mickey Exp $ */ +/* $OpenBSD: exec_subr.c,v 1.21 2002/10/06 22:39:25 art Exp $ */ /* $NetBSD: exec_subr.c,v 1.9 1994/12/04 03:10:42 mycroft Exp $ */ /* @@ -107,8 +107,7 @@ vmcmdset_extend(evsp) } void -kill_vmcmds(evsp) - struct exec_vmcmd_set *evsp; +kill_vmcmds(struct exec_vmcmd_set *evsp) { struct exec_vmcmd *vcp; int i; @@ -129,6 +128,40 @@ kill_vmcmds(evsp) evsp->evs_cnt = EXEC_DEFAULT_VMCMD_SETSIZE; } +int +exec_process_vmcmds(struct proc *p, struct exec_package *epp) +{ + struct exec_vmcmd *base_vc = NULL; + int error = 0; + int i; + + for (i = 0; i < epp->ep_vmcmds.evs_used && !error; i++) { + struct exec_vmcmd *vcp; + + vcp = &epp->ep_vmcmds.evs_cmds[i]; + + if (vcp->ev_flags & VMCMD_RELATIVE) { +#ifdef DIAGNOSTIC + if (base_vc == NULL) + panic("exec_process_vmcmds: RELATIVE no base"); +#endif + vcp->ev_addr += base_vc->ev_addr; + } + error = (*vcp->ev_proc)(p, vcp); + if (vcp->ev_flags & VMCMD_BASE) { +#ifdef DIAGNOSTIC + if (base_vc != NULL) + panic("exec_process_vmcmds: multiple BASE"); +#endif + base_vc = vcp; + } + } + + kill_vmcmds(&epp->ep_vmcmds); + + return (error); +} + /* * vmcmd_map_pagedvn(): * handle vmcmd which specifies that a vnode should be mmap'd. diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 7d332543464..dd1daf29d58 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_exec.c,v 1.71 2002/09/23 01:41:09 art Exp $ */ +/* $OpenBSD: kern_exec.c,v 1.72 2002/10/06 22:39:25 art Exp $ */ /* $NetBSD: kern_exec.c,v 1.75 1996/02/09 18:59:28 christos Exp $ */ /*- @@ -252,7 +252,6 @@ sys_execve(p, v, retval) struct vmspace *vm = p->p_vmspace; char **tmpfap; extern struct emul emul_native; - struct exec_vmcmd *base_vc; /* * Cheap solution to complicated problems. @@ -407,27 +406,7 @@ sys_execve(p, v, retval) if (pack.ep_vmcmds.evs_used == 0) panic("execve: no vmcmds"); #endif - base_vc = NULL; - for (i = 0; i < pack.ep_vmcmds.evs_used && !error; i++) { - struct exec_vmcmd *vcp; - - vcp = &pack.ep_vmcmds.evs_cmds[i]; - - if (vcp->ev_flags & VMCMD_RELATIVE) { -#ifdef DIAGNOSTIC - if (base_vc == NULL) - panic("sys_execve: RELATIVE without base"); -#endif - vcp->ev_addr += base_vc->ev_addr; - } - - error = (*vcp->ev_proc)(p, vcp); - if (vcp->ev_flags & VMCMD_BASE) - base_vc = vcp; - } - - /* free the vmspace-creation commands, and release their references */ - kill_vmcmds(&pack.ep_vmcmds); + error = exec_process_vmcmds(p, &pack); /* if an error happened, deallocate and punt */ if (error) |