aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_exec.c
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2018-04-19 16:00:34 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2018-04-19 16:00:34 +0000
commit73c8686e91350bb6a16ed918886fade28735a1ed (patch)
tree5f33436176d46381ab978c175471b6dc8ad70b35 /sys/kern/kern_exec.c
parentb3e85e7a7993946dc9408e949911692f3d8a565f (diff)
downloadsrc-73c8686e91350bb6a16ed918886fade28735a1ed.tar.gz
src-73c8686e91350bb6a16ed918886fade28735a1ed.zip
Simplify the code to allocate stack for auxv, argv[], and environment vectors.
Remove auxarg_size as it was only used once right after a confusing assignment in each of the variants of exec_copyout_strings(). Reviewed by: emaste MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D15123
Notes
Notes: svn path=/head/; revision=332782
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;