about summary refs log tree commit diff
path: root/sysdeps/generic/libc-start.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2002-07-23 23:12:01 +0000
committerUlrich Drepper <drepper@redhat.com>2002-07-23 23:12:01 +0000
commit8a30f00fe8ea30054c2df183d34ef3ad8a522cc5 (patch)
tree4b34500fac3e847c4f98bec8ca6c0ab96f7704ba /sysdeps/generic/libc-start.c
parentfcda29e2604e941cbe9a9eb30c56b8b8fa607836 (diff)
downloadglibc-8a30f00fe8ea30054c2df183d34ef3ad8a522cc5.tar.gz
glibc-8a30f00fe8ea30054c2df183d34ef3ad8a522cc5.tar.xz
glibc-8a30f00fe8ea30054c2df183d34ef3ad8a522cc5.zip
Update.
2002-07-23  Ulrich Drepper  <drepper@redhat.com>

	* sysdeps/generic/libc-tls.c: New file.
	* csu/Makefile (routines): Add libc-tls.
	(static-only-routines): Add libc-tls.
	* elf/dl-support.c (_dl_phdr): New variable.
	(_dl_phnum): New variable.
	(_dl_aux_init): Initialize _dl_phdr and _dl_phnum from aux vector.
	* sysdeps/generic/libc-start.c (__libc_start_main): Reorganize code
	for !SHARED.  First look through auxiliary vector.  If TLS always
	call __pthread_initialize_minimal.

	* sysdeps/generic/dl-tls.c (_dl_allocate_tls): Make sure size argument
	in mmap call is never zero.
Diffstat (limited to 'sysdeps/generic/libc-start.c')
-rw-r--r--sysdeps/generic/libc-start.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/sysdeps/generic/libc-start.c b/sysdeps/generic/libc-start.c
index 4d1748614e..600136dae5 100644
--- a/sysdeps/generic/libc-start.c
+++ b/sysdeps/generic/libc-start.c
@@ -77,10 +77,23 @@ BP_SYM (__libc_start_main) (int (*main) (int, char **, char **),
   __libc_stack_end = stack_end;
 
 #ifndef SHARED
+# ifdef HAVE_AUX_VECTOR
+  /* First process the auxiliary vector since we need to find the
+     program header to locate an eventually present PT_TLS entry.  */
+  for (auxvec = (void *__unbounded *__unbounded) ubp_ev;
+       *auxvec != NULL; ++auxvec);
+  ++auxvec;
+  _dl_aux_init ((ElfW(auxv_t) *) auxvec);
+# endif
+
   /* Initialize the thread library at least a bit since the libgcc
      functions are using thread functions if these are available and
-     we need to setup errno.  */
+     we need to setup errno.  If there is no thread library and we
+     handle TLS the function is defined in the libc to initialized the
+     TLS handling.  */
+# ifndef TLS
   if (__pthread_initialize_minimal)
+# endif
     __pthread_initialize_minimal ();
 
   /* Some security at this point.  Prevent starting a SUID binary where
@@ -89,13 +102,6 @@ BP_SYM (__libc_start_main) (int (*main) (int, char **, char **),
      loader did the work already.  */
   if (__builtin_expect (__libc_enable_secure, 0))
     __libc_check_standard_fds ();
-
-# ifdef HAVE_AUX_VECTOR
-  for (auxvec = (void *__unbounded *__unbounded) ubp_ev;
-       *auxvec != NULL; ++auxvec);
-  ++auxvec;
-  _dl_aux_init ((ElfW(auxv_t) *) auxvec);
-# endif
 #endif
 
   /* Register the destructor of the dynamic linker if there is any.  */