summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2010-04-22 05:53:43 +0000
committerAustin Foxley <austinf@cetoncorp.com>2010-04-22 08:56:16 -0700
commitcfa1d49e87eae4d46e0f0d568627b210383534f3 (patch)
tree78e988ad9850c5e7a3e2e7026ffe34f793666efa
parent279c728ee62e53eb055227695bc6fafb31a3a5f1 (diff)
nptl: fix dynamic initialization of libpthread
If libpthread get's pulled in via dlopen(), we need to do libpthread initialization in dlopen(). Achieve this by making initializer function out of __pthread_initialize_minimal_internal. Add the proper linker flags and make it callable multiple times. Add also nodelete flag which ensures that libpthread will not get unmapped after it's been loading. Though, ld.so does not yet support this. Signed-off-by: Timo Teräs <timo.teras@iki.fi> Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
-rw-r--r--libpthread/nptl/Makefile.in2
-rw-r--r--libpthread/nptl/init.c6
2 files changed, 7 insertions, 1 deletions
diff --git a/libpthread/nptl/Makefile.in b/libpthread/nptl/Makefile.in
index d33656532..1e9f98cea 100644
--- a/libpthread/nptl/Makefile.in
+++ b/libpthread/nptl/Makefile.in
@@ -220,7 +220,7 @@ else
LDFLAGS-libpthread.so := $(LDFLAGS)
endif
-LDFLAGS-libpthread.so += $(top_builddir)lib/$(UCLIBC_LDSO_NAME)-$(VERSION).so $(top_builddir)lib/libdl-$(VERSION).so
+LDFLAGS-libpthread.so += $(top_builddir)lib/$(UCLIBC_LDSO_NAME)-$(VERSION).so $(top_builddir)lib/libdl-$(VERSION).so -Wl,-z,nodelete,-z,initfirst,-init=__pthread_initialize_minimal_internal
LIBS-libpthread.so := $(LIBS)
diff --git a/libpthread/nptl/init.c b/libpthread/nptl/init.c
index 44f2c86f1..b70de84fd 100644
--- a/libpthread/nptl/init.c
+++ b/libpthread/nptl/init.c
@@ -260,6 +260,12 @@ static bool __nptl_initial_report_events __attribute_used__;
void
__pthread_initialize_minimal_internal (void)
{
+ static int initialized = 0;
+
+ if (initialized)
+ return;
+ initialized = 1;
+
#ifndef SHARED
/* Unlike in the dynamically linked case the dynamic linker has not
taken care of initializing the TLS data structures. */