diff options
author | 2002-10-06 22:39:25 +0000 | |
---|---|---|
committer | 2002-10-06 22:39:25 +0000 | |
commit | 1e04e3513f8bb50132d4eeb2d323415375d65772 (patch) | |
tree | 0fc3b171cf1ba1b65d63bd93bc2482de8265bc22 | |
parent | No more need to initialize the result list before uvm_pglistalloc. (diff) | |
download | wireguard-openbsd-1e04e3513f8bb50132d4eeb2d323415375d65772.tar.xz wireguard-openbsd-1e04e3513f8bb50132d4eeb2d323415375d65772.zip |
Move out the execution of vmcmds into a separate function.
-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 | ||||
-rw-r--r-- | sys/sys/exec.h | 3 |
4 files changed, 44 insertions, 48 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) diff --git a/sys/sys/exec.h b/sys/sys/exec.h index b9bf179ca84..76e134c4fc4 100644 --- a/sys/sys/exec.h +++ b/sys/sys/exec.h @@ -1,4 +1,4 @@ -/* $OpenBSD: exec.h,v 1.17 2002/09/23 01:41:09 art Exp $ */ +/* $OpenBSD: exec.h,v 1.18 2002/10/06 22:39:25 art Exp $ */ /* $NetBSD: exec.h,v 1.59 1996/02/09 18:25:09 christos Exp $ */ /*- @@ -191,6 +191,7 @@ void setregs(struct proc *, struct exec_package *, u_long, register_t *); int check_exec(struct proc *, struct exec_package *); int exec_setup_stack(struct proc *, struct exec_package *); +int exec_process_vmcmds(struct proc *, struct exec_package *); #ifdef DEBUG void new_vmcmd(struct exec_vmcmd_set *evsp, |