summaryrefslogtreecommitdiffstats
path: root/libc/misc/internals/__uClibc_main.c
diff options
context:
space:
mode:
authorCarmelo Amoroso <carmelo.amoroso@st.com>2007-11-20 10:09:16 +0000
committerCarmelo Amoroso <carmelo.amoroso@st.com>2007-11-20 10:09:16 +0000
commit244539cd0852bbcf8f21507d7ff866d8e7fcff18 (patch)
tree5a04e6a195814b645007e4ccecb128d8c7b31ee7 /libc/misc/internals/__uClibc_main.c
parent1cac0350028cc4a47715f63e61379d3318b0c965 (diff)
downloaduClibc-alpine-244539cd0852bbcf8f21507d7ff866d8e7fcff18.tar.bz2
uClibc-alpine-244539cd0852bbcf8f21507d7ff866d8e7fcff18.tar.xz
Fix Makefile.in and synch them with trunk. Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
Diffstat (limited to 'libc/misc/internals/__uClibc_main.c')
-rw-r--r--libc/misc/internals/__uClibc_main.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c
index 85f38c521..15544790a 100644
--- a/libc/misc/internals/__uClibc_main.c
+++ b/libc/misc/internals/__uClibc_main.c
@@ -15,8 +15,10 @@
* avoided in the static library case.
*/
-#define _ERRNO_H
#include <features.h>
+#ifndef __UCLIBC_HAS_THREADS_NATIVE__
+#define _ERRNO_H
+#endif
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
@@ -30,6 +32,7 @@
#include <sys/stat.h>
#include <sys/sysmacros.h>
#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <errno.h>
#include <pthread-functions.h>
#include <not-cancel.h>
#endif
@@ -54,6 +57,8 @@ extern __typeof(fcntl) __libc_fcntl;
libc_hidden_proto(__libc_fcntl)
#endif
+#include <pthreadP.h>
+
#ifndef SHARED
void *__libc_stack_end=NULL;
@@ -79,6 +84,11 @@ uintptr_t __guard attribute_relro;
# endif
# endif
+/*
+ * Needed to initialize _dl_phdr when statically linked;
+ */
+
+void internal_function _dl_aux_init (ElfW(auxv_t) *av);
#endif /* !SHARED */
/*
@@ -91,7 +101,11 @@ extern int *weak_const_function __h_errno_location(void);
extern void weak_function _locale_init(void) attribute_hidden;
#endif
#ifdef __UCLIBC_HAS_THREADS__
+#if !defined (__UCLIBC_HAS_THREADS_NATIVE__) || defined (SHARED)
extern void weak_function __pthread_initialize_minimal(void);
+#else
+extern void __pthread_initialize_minimal(void);
+#endif
#endif
#ifdef __UCLIBC_CTOR_DTOR__
@@ -119,12 +133,12 @@ strong_alias (__progname_full, program_invocation_name)
#endif
/*
- * Declare the __environ global variable and create a strong alias environ.
- * Note: Apparently we must initialize __environ to ensure that the strong
- * environ symbol is also included.
+ * Declare the __environ global variable and create a weak alias environ.
+ * This must be initialized; we cannot have a weak alias into bss.
*/
+
char **__environ = 0;
-strong_alias(__environ,environ)
+weak_alias(__environ,environ)
/* TODO: don't export __pagesize; we cant now because libpthread uses it */
size_t __pagesize = 0;
@@ -209,7 +223,9 @@ void __uClibc_init(void)
* __pthread_initialize_minimal so we can use pthread_locks
* whenever they are needed.
*/
+#if !defined (__UCLIBC_HAS_THREADS_NATIVE__) || defined (SHARED)
if (likely(__pthread_initialize_minimal!=NULL))
+#endif
__pthread_initialize_minimal();
#endif
@@ -324,6 +340,12 @@ void __uClibc_main(int (*main)(int, char **, char **), int argc,
}
aux_dat += 2;
}
+#ifndef SHARED
+ /* Get the program headers (_dl_phdr) from the aux vector
+ It will be used into __libc_setup_tls. */
+
+ _dl_aux_init (auxvt);
+#endif
#endif
/* We need to initialize uClibc. If we are dynamically linked this
@@ -444,7 +466,7 @@ void __uClibc_main(int (*main)(int, char **, char **), int argc,
if (! atomic_decrement_and_test (ptr))
/* Not much left to do but to exit the thread, not the process. */
- __exit_thread (0);
+ __exit_thread_inline (0);
}
exit (result);