From 863fb82e76eba16742cab87c085dd7b08639bcb9 Mon Sep 17 00:00:00 2001 From: "\"Steven J. Hill\"" Date: Tue, 30 Aug 2005 04:42:13 +0000 Subject: Add in calls needed for TLS setup for statically linked applications. A call is made to '_dl_aux_init' which is defined in 'dl-support.c' to set up TLS variables before '__uClibc_init' gets called. --- libc/misc/internals/__uClibc_main.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'libc/misc/internals/__uClibc_main.c') diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c index 6f74e39e8..5c1560d1b 100644 --- a/libc/misc/internals/__uClibc_main.c +++ b/libc/misc/internals/__uClibc_main.c @@ -42,6 +42,7 @@ extern void weak_function _locale_init(void); #endif #ifdef __UCLIBC_HAS_THREADS__ extern void weak_function __pthread_initialize_minimal(void); +extern void weak_function _dl_aux_init(ElfW(auxv_t) *); #endif @@ -175,10 +176,6 @@ __uClibc_main(int (*main)(int, char **, char **), int argc, ElfW(auxv_t) auxvt[AT_EGID + 1]; #endif __libc_stack_end = stack_end; - /* We need to initialize uClibc. If we are dynamically linked this - * may have already been completed by the shared lib loader. We call - * __uClibc_init() regardless, to be sure the right thing happens. */ - __uClibc_init(); __rtld_fini = rtld_fini; @@ -207,6 +204,20 @@ __uClibc_main(int (*main)(int, char **, char **), int argc, aux_dat += 2; } +#ifdef __UCLIBC_HAS_THREADS__ + /* + * Before we can make any pthread calls, we have to do some + * some TLS setup. This call may do more in the future. + */ + if (likely(_dl_aux_init != NULL)) + _dl_aux_init(auxvt); +#endif + + /* We need to initialize uClibc. If we are dynamically linked this + * may have already been completed by the shared lib loader. We call + * __uClibc_init() regardless, to be sure the right thing happens. */ + __uClibc_init(); + /* Make certain getpagesize() gives the correct answer */ __pagesize = (auxvt[AT_PAGESZ].a_un.a_val)? auxvt[AT_PAGESZ].a_un.a_val : PAGE_SIZE; -- cgit v1.2.3