aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_exec.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern/kern_exec.c')
-rw-r--r--sys/kern/kern_exec.c34
1 files changed, 11 insertions, 23 deletions
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index c55851f5b420..29eae3967a68 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -1537,35 +1537,23 @@ exec_copyout_strings(struct image_params *imgp)
destp -= ARG_MAX - imgp->args->stringspace;
destp = rounddown2(destp, sizeof(void *));
- /*
- * If we have a valid auxargs ptr, prepare some room
- * on the stack.
- */
+ vectp = (char **)destp;
if (imgp->auxargs) {
/*
- * 'AT_COUNT*2' is size for the ELF Auxargs data. This is for
- * lower compatibility.
- */
- imgp->auxarg_size = (imgp->auxarg_size) ? imgp->auxarg_size :
- (AT_COUNT * 2);
- /*
- * The '+ 2' is for the null pointers at the end of each of
- * the arg and env vector sets,and imgp->auxarg_size is room
- * for argument of Runtime loader.
- */
- vectp = (char **)(destp - (imgp->args->argc +
- imgp->args->envc + 2 + imgp->auxarg_size)
- * sizeof(char *));
- } else {
- /*
- * The '+ 2' is for the null pointers at the end of each of
- * the arg and env vector sets
+ * Allocate room on the stack for the ELF auxargs
+ * array. It has up to AT_COUNT entries.
*/
- vectp = (char **)(destp - (imgp->args->argc + imgp->args->envc
- + 2) * sizeof(char *));
+ vectp -= howmany(AT_COUNT * sizeof(Elf_Auxinfo),
+ sizeof(*vectp));
}
/*
+ * Allocate room for the argv[] and env vectors including the
+ * terminating NULL pointers.
+ */
+ vectp -= imgp->args->argc + 1 + imgp->args->envc + 1;
+
+ /*
* vectp also becomes our initial stack base
*/
stack_base = (register_t *)vectp;