summary refs log tree commit diff
path: root/sysdeps/generic/libc-start.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2002-09-15 02:37:32 +0000
committerUlrich Drepper <drepper@redhat.com>2002-09-15 02:37:32 +0000
commit7ae4abe9af5d7c76c7ab01a72aebe307a06120e1 (patch)
tree18fca0dd7b02623bec5e7e8d1f39aae93f50c68a /sysdeps/generic/libc-start.c
parentdf17727a5efa1a5447e970e31cf9673a7f508fba (diff)
downloadglibc-7ae4abe9af5d7c76c7ab01a72aebe307a06120e1.tar.gz
glibc-7ae4abe9af5d7c76c7ab01a72aebe307a06120e1.tar.xz
glibc-7ae4abe9af5d7c76c7ab01a72aebe307a06120e1.zip
Update.
2002-09-14  Ulrich Drepper  <drepper@redhat.com>

	* include/unistd.h: Declare __exit_thread.
	* sysdeps/generic/libc-start.c: Remove dummy_addr.
	Wrap call to main in setjmp if HAVE_CANCELBUF is defined.
	* sysdeps/unix/sysv/linux/exit-thread.S: New file.
	* sysdeps/unix/sysv/linux/_exit.c: New file.
	* sysdeps/unix/sysv/linux/i386/_exit.S: New file.
	* sysdeps/unix/sysv/linux/Makefile [subdir==posix] (sysdep_routines):
	Add exit-thread.

	* configure.in: Add dl_iterate_phdr to test using -nostdlib.
Diffstat (limited to 'sysdeps/generic/libc-start.c')
-rw-r--r--sysdeps/generic/libc-start.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/sysdeps/generic/libc-start.c b/sysdeps/generic/libc-start.c
index 8d523e6836..c619341e56 100644
--- a/sysdeps/generic/libc-start.c
+++ b/sysdeps/generic/libc-start.c
@@ -29,8 +29,8 @@ weak_extern (_dl_starting_up)
 extern int __libc_multiple_libcs;
 extern void *__libc_stack_end;
 
+#include <tls.h>
 #ifndef SHARED
-# include <tls.h>
 extern void __pthread_initialize_minimal (void)
 # if !(USE_TLS - 0)
      __attribute__ ((weak))
@@ -63,17 +63,15 @@ BP_SYM (__libc_start_main) (int (*main) (int, char **, char **),
 # define argv ubp_av
 #endif
 
+  /* Result of the 'main' function.  */
+  int result;
+
 #ifndef SHARED
 # ifdef HAVE_AUX_VECTOR
   void *__unbounded *__unbounded auxvec;
 # endif
 
-  /* The next variable is only here to work around a bug in gcc <= 2.7.2.2.
-     If the address would be taken inside the expression the optimizer
-     would try to be too smart and throws it away.  Grrr.  */
-  int *dummy_addr = &_dl_starting_up;
-
-  __libc_multiple_libcs = dummy_addr && !_dl_starting_up;
+  __libc_multiple_libcs = &_dl_starting_up && !_dl_starting_up;
 #endif
 
   INIT_ARGV_and_ENVIRON;
@@ -137,5 +135,23 @@ BP_SYM (__libc_start_main) (int (*main) (int, char **, char **),
     _dl_debug_printf ("\ntransferring control: %s\n\n", argv[0]);
 #endif
 
-  exit ((*main) (argc, argv, __environ));
+#ifdef HAVE_CANCELBUF
+  if (setjmp (THREAD_SELF->cancelbuf) == 0)
+#endif
+    {
+      /* XXX This is where the try/finally handling must be used.  */
+
+      result = main (argc, argv, __environ);
+    }
+#ifdef HAVE_CANCELBUF
+  else
+    {
+      /* XXX We should free the thread-specific data.  */
+
+      /* Not much left to do but to exit the thread, not the process.  */
+      __exit_thread (0);
+    }
+#endif
+
+  exit (result);
 }