diff options
author | 2002-09-23 01:41:09 +0000 | |
---|---|---|
committer | 2002-09-23 01:41:09 +0000 | |
commit | ec0321757bf02223118d47afb18a3ccab877bf2d (patch) | |
tree | 70542062a23bf87b0f675f054a85232b55798c91 /sys/kern/kern_exec.c | |
parent | Activate exec-stack.h on m68k. This is not really necessary on this arch, (diff) | |
download | wireguard-openbsd-ec0321757bf02223118d47afb18a3ccab877bf2d.tar.xz wireguard-openbsd-ec0321757bf02223118d47afb18a3ccab877bf2d.zip |
Add support for vmcmds that load sections relative to a base section.
You mark one section with VMCMD_BASE and the rest are marked RELATIVE.
Use that to load ELF interpreter correctly in all cases.
Inspired by NetBSD. Great debugging help from drahn@
deraadt@ ok
Diffstat (limited to 'sys/kern/kern_exec.c')
-rw-r--r-- | sys/kern/kern_exec.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 2b0c25bc328..7d332543464 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_exec.c,v 1.70 2002/08/22 22:04:42 art Exp $ */ +/* $OpenBSD: kern_exec.c,v 1.71 2002/09/23 01:41:09 art Exp $ */ /* $NetBSD: kern_exec.c,v 1.75 1996/02/09 18:59:28 christos Exp $ */ /*- @@ -252,6 +252,7 @@ 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. @@ -406,11 +407,23 @@ 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 */ |