aboutsummaryrefslogtreecommitdiff
path: root/hurd
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1995-09-21 04:01:40 +0000
committerRoland McGrath <roland@gnu.org>1995-09-21 04:01:40 +0000
commit600927014b78e4247e36bbc554c188c7a3cca40e (patch)
treecf802f95fda74fadebc8683ac1b584b527f9fbaa /hurd
parentbf40c56f1a3f569780b99c8187aaa3f580de36d4 (diff)
downloadglibc-600927014b78e4247e36bbc554c188c7a3cca40e.zip
glibc-600927014b78e4247e36bbc554c188c7a3cca40e.tar.gz
glibc-600927014b78e4247e36bbc554c188c7a3cca40e.tar.bz2
Wed Sep 20 18:02:03 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* locale/locale.c: Include errno.h. * locale/localedef.c: Likewise. Tue Sep 19 00:02:06 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu> * Makefile (distclean-1): Remove config.cache, config.log, config.h. (parent-mostlyclean): Remove all flavors of the parent library. * misc/mntent.c (getmntent): Skip multiple whitespace chars between fields. * hurd/hurdstartup.c (_hurd_startup): If RPC returns EXEC_STACK_ARGS flag, get args from stack. If args on stack but have info from RPC, relocate args on stack to make space for struct hurd_startup_data. * elf/dl-object.c: Include errno.h. * posix/execvp.c: Likewise. * dirent/scandir.c: Likewise. * sysdeps/posix/system.c: Likewise. * sysdeps/generic/setenv.c: Likewise. * stdlib/msort.c: Likewise. * stdio/memstream.c: Likewise. * stdio/fclose.c: Likewise. * stdio/getdelim.c: Likewise. * stdio/setvbuf.c: Likewise. * sysdeps/ieee754/ldexp.c: Likewise. * locale/locfile-parse.c: Likewise. * stdlib/lcong48_r.c: Don't check for null argument; let it fault. * stdlib/seed48_r.c: Likewise. * stdlib/srand48_r.c: Likewise. * stdlib/jrand48_r.c: Likewise. * stdlib/nrand48_r.c: Likewise. * misc/search.h: Many decls for hsearch functions.
Diffstat (limited to 'hurd')
-rw-r--r--hurd/hurdstartup.c63
1 files changed, 42 insertions, 21 deletions
diff --git a/hurd/hurdstartup.c b/hurd/hurdstartup.c
index 61b8cdf..28ce40b 100644
--- a/hurd/hurdstartup.c
+++ b/hurd/hurdstartup.c
@@ -99,13 +99,13 @@ _hurd_startup (void **argptr, void (*main) (int *data))
__mach_port_deallocate (__mach_task_self (), in_bootstrap);
}
- if (err || in_bootstrap == MACH_PORT_NULL)
+ if (err || in_bootstrap == MACH_PORT_NULL || (data.flags & EXEC_STACK_ARGS))
{
/* Either we have no bootstrap port, or the RPC to the exec server
- failed. Try to snarf the args in the canonical Mach way.
+ failed, or whoever started us up passed the flag saying args are
+ on the stack. Try to snarf the args in the canonical Mach way.
Hopefully either they will be on the stack as expected, or the
- stack will be zeros so we don't crash. Set all our other
- variables to have empty information. */
+ stack will be zeros so we don't crash. */
argcptr = (int *) argptr;
argc = argcptr[0];
@@ -114,26 +114,12 @@ _hurd_startup (void **argptr, void (*main) (int *data))
envc = 0;
while (envp[envc])
++envc;
-
- data.flags = 0;
- args = env = NULL;
- argslen = envlen = 0;
- data.dtable = NULL;
- data.dtablesize = 0;
- data.portarray = NULL;
- data.portarraysize = 0;
- data.intarray = NULL;
- data.intarraysize = 0;
}
else
- argv = envp = NULL;
-
-
- /* Turn the block of null-separated strings we were passed for the
- arguments and environment into vectors of pointers to strings. */
-
- if (! argv)
{
+ /* Turn the block of null-separated strings we were passed for the
+ arguments and environment into vectors of pointers to strings. */
+
/* Count up the arguments so we can allocate ARGV. */
argc = _hurd_split_args (args, argslen, NULL);
/* Count up the environment variables so we can allocate ENVP. */
@@ -155,6 +141,41 @@ _hurd_startup (void **argptr, void (*main) (int *data))
_hurd_split_args (env, envlen, envp);
}
+ if (err || in_bootstrap == MACH_PORT_NULL)
+ {
+ /* Either we have no bootstrap port, or the RPC to the exec server
+ failed. Set all our other variables to have empty information. */
+
+ data.flags = 0;
+ args = env = NULL;
+ argslen = envlen = 0;
+ data.dtable = NULL;
+ data.dtablesize = 0;
+ data.portarray = NULL;
+ data.portarraysize = 0;
+ data.intarray = NULL;
+ data.intarraysize = 0;
+ }
+ else if ((void *) &envp[envc + 1] == argv[0])
+ {
+ /* The arguments arrived on the stack from the kernel, but our
+ protocol requires some space after them for a `struct
+ hurd_startup_data'. Move them. */
+ struct
+ {
+ int count;
+ char *argv[argc + 1];
+ char *envp[envc + 1];
+ struct hurd_startup_data data;
+ } *args = alloca (sizeof *args);
+ if ((void *) &args[1] == (void *) argcptr)
+ args = alloca (-((char *) &args->data - (char *) args));
+ memmove (args, argcptr, (char *) &args->data - (char *) args);
+ argcptr = (void *) args;
+ argv = args->argv;
+ envp = args->envp;
+ }
+
{
struct hurd_startup_data *d = (void *) &envp[envc + 1];