summaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/generic/ldsodefs.h4
-rw-r--r--sysdeps/nptl/dl-tls_init_tp.c25
2 files changed, 27 insertions, 2 deletions
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
index 6d590d1335..ee851ac789 100644
--- a/sysdeps/generic/ldsodefs.h
+++ b/sysdeps/generic/ldsodefs.h
@@ -1165,6 +1165,10 @@ extern void _dl_determine_tlsoffset (void) attribute_hidden;
number of audit modules are loaded. */
void _dl_tls_static_surplus_init (size_t naudit) attribute_hidden;
+/* This function is called very early from dl_main to set up TLS and
+ other thread-related data structures. */
+void __tls_pre_init_tp (void) attribute_hidden;
+
/* This function is called after processor-specific initialization of
the TCB and thread pointer via TLS_INIT_TP, to complete very early
initialization of the thread library. */
diff --git a/sysdeps/nptl/dl-tls_init_tp.c b/sysdeps/nptl/dl-tls_init_tp.c
index 05d2b6cfcc..cb29222727 100644
--- a/sysdeps/nptl/dl-tls_init_tp.c
+++ b/sysdeps/nptl/dl-tls_init_tp.c
@@ -27,12 +27,33 @@ bool __nptl_set_robust_list_avail __attribute__ ((nocommon));
rtld_hidden_data_def (__nptl_set_robust_list_avail)
#endif
+#ifdef SHARED
+/* Dummy implementation. See __rtld_mutex_init. */
+static int
+rtld_mutex_dummy (pthread_mutex_t *lock)
+{
+ return 0;
+}
+#endif
+
void
-__tls_init_tp (void)
+__tls_pre_init_tp (void)
{
- /* Set up thread stack list management. */
+ /* The list data structures are not consistent until
+ initialized. */
INIT_LIST_HEAD (&GL (dl_stack_used));
INIT_LIST_HEAD (&GL (dl_stack_user));
+
+#ifdef SHARED
+ ___rtld_mutex_lock = rtld_mutex_dummy;
+ ___rtld_mutex_unlock = rtld_mutex_dummy;
+#endif
+}
+
+void
+__tls_init_tp (void)
+{
+ /* Set up thread stack list management. */
list_add (&THREAD_SELF->list, &GL (dl_stack_user));
/* Early initialization of the TCB. */