Bernhard, I sent the following patch to uClibc mailing list, according to your previous suggestion. Please let me know if there's problem.
>From 0a0ff0a2528e08cce4179c6c3a2f6ee751d84c83 Mon Sep 17 00:00:00 2001 From: Vincent Wen <[email protected]> Date: Mon, 1 Apr 2013 09:57:00 -0700 Subject: [PATCH] libdl.c: Static link fails on MIPS platform. When build statically linked applications for MIPS platform, sometimes the linker fails with following errors: undefined reference to TLS_DTPREL_VALUE undefined reference to TLS_TPREL_VALUE The include of dl-tls.h is only in code guarded by SHARED, Removing the SHARED compilation option to cover static link too. Signed-off-by: Vincent Wen <[email protected]> --- ldso/libdl/libdl.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/ldso/libdl/libdl.c b/ldso/libdl/libdl.c index 4630a59..565c241 100644 --- a/ldso/libdl/libdl.c +++ b/ldso/libdl/libdl.c @@ -42,6 +42,7 @@ #if defined(USE_TLS) && USE_TLS #include <ldsodefs.h> +# include <dl-tls.h> extern void _dl_add_to_slotinfo(struct link_map *l); #endif @@ -51,7 +52,6 @@ __UCLIBC_MUTEX_STATIC(_dl_mutex, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP); #ifdef SHARED # if defined(USE_TLS) && USE_TLS -# include <dl-tls.h> extern struct link_map *_dl_update_slotinfo(unsigned long int req_modid); # endif -- 1.7.9.1.g8d994 Thanks, Vincent On Fri, Mar 29, 2013 at 10:56 AM, Vincent Wen <[email protected]> wrote: > I am not sure what mean legitimately use DTPREL. When we build static > link on our application, the linker breaks due to this undefined > reference. > > I can re-submit the patch as you suggest as following. > > Thanks, > > Vincent > > > diff --git a/ldso/libdl/libdl.c b/ldso/libdl/libdl.c > index 71ade1f..385500a 100644 > --- a/ldso/libdl/libdl.c > +++ b/ldso/libdl/libdl.c > @@ -41,8 +41,9 @@ > #endif > > #if defined(USE_TLS) && USE_TLS > -#include <ldsodefs.h> > +# include <ldsodefs.h> > extern void _dl_add_to_slotinfo(struct link_map *l); > +# include <dl-tls.h> > #endif > > /* TODO: get rid of global lock and use more finegrained locking, or > @@ -51,7 +52,6 @@ __UCLIBC_MUTEX_STATIC(_dl_ > mutex, > PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP); > > #ifdef SHARED > # if defined(USE_TLS) && USE_TLS > -# include <dl-tls.h> > extern struct link_map *_dl_update_slotinfo(unsigned long int req_modid); > # endif > > > On Fri, Mar 29, 2013 at 4:52 AM, Bernhard Reutner-Fischer > <[email protected]> wrote: >> On 23 February 2013 10:48, Bernhard Reutner-Fischer >> <[email protected]> wrote: >>> On Fri, Feb 22, 2013 at 02:06:43PM -0800, Vincent Wen wrote: >>>>When build statically linked applications for MIPS platform, >>>>sometimes the linker fails with following errors: >>>>undefined reference to TLS_DTPREL_VALUE >>>>undefined reference to TLS_TPREL_VALUE >>> >>> I still suspect that these uses may need a SHARED guard, no? >> >> Would any static linkage legitimately use DTPREL? >>> >>>>The include of dl-tls.h is defined for shared library build. >>>>Removing the SHARED compilation option to cover static link too. >>> >>> Otherwise this would be ok, yes. >>> Can you have a look, please? >> >> If anything, this should be >> >> diff --git a/ldso/libdl/libdl.c b/ldso/libdl/libdl.c >> index 71ade1f..385500a 100644 >> --- a/ldso/libdl/libdl.c >> +++ b/ldso/libdl/libdl.c >> @@ -41,8 +41,9 @@ >> #endif >> >> #if defined(USE_TLS) && USE_TLS >> -#include <ldsodefs.h> >> +# include <ldsodefs.h> >> extern void _dl_add_to_slotinfo(struct link_map *l); >> +# include <dl-tls.h> >> #endif >> >> /* TODO: get rid of global lock and use more finegrained locking, or >> @@ -51,7 +52,6 @@ __UCLIBC_MUTEX_STATIC(_dl_mutex, >> PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP); >> >> #ifdef SHARED >> # if defined(USE_TLS) && USE_TLS >> -# include <dl-tls.h> >> extern struct link_map *_dl_update_slotinfo(unsigned long int req_modid); >> # endif >> >> thanks, >>> TIA, >>>> >>>>Signed-off-by: Vincent Wen <[email protected]> >>>>--- >>>> ldso/libdl/libdl.c | 5 ++++- >>>> 1 files changed, 4 insertions(+), 1 deletions(-) >>>> >>>>diff --git a/ldso/libdl/libdl.c b/ldso/libdl/libdl.c >>>>index 2337223..5172754 100644 >>>>--- a/ldso/libdl/libdl.c >>>>+++ b/ldso/libdl/libdl.c >>>>@@ -49,9 +49,12 @@ extern void _dl_add_to_slotinfo(struct link_map *l); >>>> * perhaps RCU for the global structures */ >>>> __UCLIBC_MUTEX_STATIC(_dl_mutex, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP); >>>> >>>>-#ifdef SHARED >>>> # if defined(USE_TLS) && USE_TLS >>>> # include <dl-tls.h> >>>>+# endif >>>>+ >>>>+#ifdef SHARED >>>>+# if defined(USE_TLS) && USE_TLS >>>> extern struct link_map *_dl_update_slotinfo(unsigned long int req_modid); >>>> # endif >>>> >>>>-- >>>>1.7.9.1.g8d994 >>>> >>>> >>>>_______________________________________________ >>>>uClibc mailing list >>>>[email protected] >>>>http://lists.busybox.net/mailman/listinfo/uclibc _______________________________________________ uClibc mailing list [email protected] http://lists.busybox.net/mailman/listinfo/uclibc
