diff options
author | Neal H. Walfield <neal@gnu.org> | 2008-12-11 19:44:32 +0100 |
---|---|---|
committer | Neal H. Walfield <neal@gnu.org> | 2008-12-11 19:44:32 +0100 |
commit | 2ccb9282308fc6d72be23a043ad8e3396d97052e (patch) | |
tree | b0d26479a0b298435cb5ae3a0afd77e74677443a | |
parent | 704080f3e67bd2311508e5632f68ef1f41f91ac5 (diff) |
If running on an alternate stack, free the initial stack.
2008-12-11 Neal H. Walfield <neal@gnu.org>
* ia32-cmain.c: Include <hurd/storage.h>.
(finish): If the thread is not using the initial stack, free it.
(_pthread_init_routine): Add the weak attribute to the
declaration.
-rw-r--r-- | libc-parts/ChangeLog | 7 | ||||
-rw-r--r-- | libc-parts/ia32-cmain.c | 29 |
2 files changed, 34 insertions, 2 deletions
diff --git a/libc-parts/ChangeLog b/libc-parts/ChangeLog index 38a6c80..c1a37f0 100644 --- a/libc-parts/ChangeLog +++ b/libc-parts/ChangeLog @@ -1,5 +1,12 @@ 2008-12-11 Neal H. Walfield <neal@gnu.org> + * ia32-cmain.c: Include <hurd/storage.h>. + (finish): If the thread is not using the initial stack, free it. + (_pthread_init_routine): Add the weak attribute to the + declaration. + +2008-12-11 Neal H. Walfield <neal@gnu.org> + * backtrace.h: New file. 2008-12-11 Neal H. Walfield <neal@gnu.org> diff --git a/libc-parts/ia32-cmain.c b/libc-parts/ia32-cmain.c index f67937c..3f3fd2f 100644 --- a/libc-parts/ia32-cmain.c +++ b/libc-parts/ia32-cmain.c @@ -34,7 +34,7 @@ #include <hurd/startup.h> #include <hurd/mm.h> #include <hurd/stddef.h> - +#include <hurd/storage.h> /* Initialized by the machine-specific startup-code. */ extern struct hurd_startup_data *__hurd_startup_data; @@ -45,12 +45,37 @@ extern int main (int, char *[]); char *program_name = "in crt0"; +extern char _stack, _stack_end; + static void finish (void) { int argc = 0; char **argv = 0; + if (! ((void *) &_stack <= (void *) &argc + && (void *) &argc < (void *) &_stack_end)) + /* We are not running on the initial stack. Free it. */ + { + void *p; + for (p = &_stack; p < &_stack_end; p += PAGESIZE) + { + struct hurd_object_desc *desc; + int i; + for (i = 0, desc = &__hurd_startup_data->descs[0]; + i < __hurd_startup_data->desc_count; + i ++, desc ++) + { + if (ADDR_EQ (PTR_TO_PAGE (p), desc->object)) + { + storage_free (desc->storage, true); + break; + } + } + assert (i != __hurd_startup_data->desc_count); + } + } + if (__hurd_startup_data->argz_len) /* A command line was passed. We assume that it is in argz format. */ @@ -108,7 +133,7 @@ cmain (void) mm_init (__hurd_startup_data->activity); extern void (*_pthread_init_routine)(void (*entry) (void *), void *) - __attribute__ ((noreturn)); + __attribute__ ((noreturn, weak)); if (_pthread_init_routine) _pthread_init_routine (finish, NULL); else |