summaryrefslogtreecommitdiff
path: root/libc/misc
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@uclibc-ng.org>2015-10-12 16:21:54 +0200
committerWaldemar Brodkorb <wbx@uclibc-ng.org>2015-10-12 16:29:26 +0200
commit13a6cfff31774dd06b861f1f4a9b0e36fa5ac01d (patch)
tree0653e0759429bd709e0a3800183438327c6d0b42 /libc/misc
parent4d8e5484afb4978f672a8568ddd12e628fb02724 (diff)
fix static binaries linked with pthread and compiled with ssp
Move TLS initialization for static builds up to the calling function as suggested by Daniel Fahlgren. Reported-By: Daniel Fahlgren <daniel@fahlgren.se>
Diffstat (limited to 'libc/misc')
-rw-r--r--libc/misc/internals/__uClibc_main.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c
index 1f1e601e8..632a2528e 100644
--- a/libc/misc/internals/__uClibc_main.c
+++ b/libc/misc/internals/__uClibc_main.c
@@ -32,6 +32,7 @@
#include <pthread-functions.h>
#include <not-cancel.h>
#include <atomic.h>
+#include <tls.h>
#endif
#ifdef __UCLIBC_HAS_THREADS__
#include <pthread.h>
@@ -132,6 +133,10 @@ extern void __pthread_initialize_minimal(void);
#endif
#endif
+#ifndef SHARED
+extern void __libc_setup_tls (size_t tcbsize, size_t tcbalign);
+#endif
+
/* If __UCLIBC_FORMAT_SHARED_FLAT__, all array initialisation and finalisation
* is handled by the routines passed to __uClibc_main(). */
#if defined (__UCLIBC_CTOR_DTOR__) && !defined (__UCLIBC_FORMAT_SHARED_FLAT__)
@@ -243,6 +248,13 @@ void __uClibc_init(void)
__pagesize = PAGE_SIZE;
#ifdef __UCLIBC_HAS_THREADS__
+
+#if defined (__UCLIBC_HAS_THREADS_NATIVE__) && !defined (SHARED)
+ /* Unlike in the dynamically linked case the dynamic linker has not
+ taken care of initializing the TLS data structures. */
+ __libc_setup_tls (TLS_TCB_SIZE, TLS_TCB_ALIGN);
+#endif
+
/* Before we start initializing uClibc we have to call
* __pthread_initialize_minimal so we can use pthread_locks
* whenever they are needed.