Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern execve_runproc: Simplify &argc address calc. The s...
details: https://anonhg.NetBSD.org/src/rev/351021c7ea8e
branches: trunk
changeset: 328729:351021c7ea8e
user: uebayasi <uebayasi%NetBSD.org@localhost>
date: Tue Apr 15 16:13:04 2014 +0000
description:
execve_runproc: Simplify &argc address calc. The set of (argc, argv, ...)
is located just "behind" the initial SP. SHRINK, then ALLOC, and you get
&argc.
diffstat:
sys/kern/kern_exec.c | 32 ++++++++------------------------
1 files changed, 8 insertions(+), 24 deletions(-)
diffs (66 lines):
diff -r 719471f159ee -r 351021c7ea8e sys/kern/kern_exec.c
--- a/sys/kern/kern_exec.c Tue Apr 15 15:50:16 2014 +0000
+++ b/sys/kern/kern_exec.c Tue Apr 15 16:13:04 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_exec.c,v 1.396 2014/04/15 15:50:16 uebayasi Exp $ */
+/* $NetBSD: kern_exec.c,v 1.397 2014/04/15 16:13:04 uebayasi Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.396 2014/04/15 15:50:16 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.397 2014/04/15 16:13:04 uebayasi Exp $");
#include "opt_exec.h"
#include "opt_execfmt.h"
@@ -1065,28 +1065,13 @@
* in setregs().
*/
- const size_t sigcode_psstr_sz =
- data->ed_szsigcode + /* sigcode */
- data->ed_ps_strings_sz + /* ps_strings */
- STACK_PTHREADSPACE; /* pthread space */
-
- char *stack;
-
- /* Top of the stack address space. */
- stack = vm->vm_minsaddr;
+ char * const newstack = STACK_GROW(vm->vm_minsaddr, epp->ep_ssize);
- /* Skip pthread space, ps_strings, and sigcode. */
- stack = STACK_GROW(stack, sigcode_psstr_sz);
-
- /* Allocate the gap for _rtld() and arguments to be filled by copyargs(). */
- stack = STACK_ALLOC(stack, epp->ep_ssize - sigcode_psstr_sz);
+ char *newargs = STACK_ALLOC(
+ STACK_SHRINK(newstack, data->ed_argslen), data->ed_argslen);
- /* Skip a few words reserved for _rtld(). */
- stack = STACK_GROW(stack, RTLD_GAP);
-
- /* Now copy argc, args & environ to the new stack. */
error = (*epp->ep_esch->es_copyargs)(l, epp,
- &data->ed_arginfo, &stack, data->ed_argp);
+ &data->ed_arginfo, &newargs, data->ed_argp);
if (epp->ep_path) {
PNBUF_PUT(epp->ep_path);
@@ -1191,12 +1176,11 @@
* the end of arg/env strings. Userland guesses the address of argc
* via ps_strings::ps_argvstr.
*/
- const vaddr_t newstack = (vaddr_t)STACK_GROW(vm->vm_minsaddr, epp->ep_ssize);
/* Setup new registers and do misc. setup. */
- (*epp->ep_esch->es_emul->e_setregs)(l, epp, newstack);
+ (*epp->ep_esch->es_emul->e_setregs)(l, epp, (vaddr_t)newstack);
if (epp->ep_esch->es_setregs)
- (*epp->ep_esch->es_setregs)(l, epp, newstack);
+ (*epp->ep_esch->es_setregs)(l, epp, (vaddr_t)newstack);
/* Provide a consistent LWP private setting */
(void)lwp_setprivate(l, NULL);
Home |
Main Index |
Thread Index |
Old Index