about summary refs log tree commit diff
path: root/elf
diff options
context:
space:
mode:
Diffstat (limited to 'elf')
-rw-r--r--elf/dl-error.c12
-rw-r--r--elf/dl-tsd.c20
-rw-r--r--elf/rtld.c4
3 files changed, 25 insertions, 11 deletions
diff --git a/elf/dl-error.c b/elf/dl-error.c
index e8f2f3e208..df91088843 100644
--- a/elf/dl-error.c
+++ b/elf/dl-error.c
@@ -57,6 +57,12 @@ INTVARDEF(_dl_out_of_memory)
    global variable.  */
 static receiver_fct receiver;
 
+#ifdef _LIBC_REENTRANT
+# define CATCH_HOOK	(*(struct catch **) (*GL(dl_error_catch_tsd)) ())
+#else
+static struct catch *catch_hook;
+# define CATCH_HOOK	catch_hook
+#endif
 
 void
 internal_function
@@ -68,7 +74,7 @@ _dl_signal_error (int errcode, const char *objname, const char *occation,
   if (! errstring)
     errstring = N_("DYNAMIC LINKER BUG!!!");
 
-  lcatch = *((*GL(dl_error_catch_tsd)) ());
+  lcatch = CATCH_HOOK;
   if (objname == NULL)
     objname = "";
   if (lcatch != NULL)
@@ -147,7 +153,7 @@ _dl_catch_error (const char **objname, const char **errstring,
      inefficient.  So we initialize `c' by hand.  */
   c.errstring = NULL;
 
-  void **catchp = (*GL(dl_error_catch_tsd)) ();
+  struct catch **const catchp = &CATCH_HOOK;
   old = *catchp;
   errcode = setjmp (c.env);
   if (__builtin_expect (errcode, 0) == 0)
@@ -173,7 +179,7 @@ void
 internal_function
 _dl_receive_error (receiver_fct fct, void (*operate) (void *), void *args)
 {
-  void **catchp = (*GL(dl_error_catch_tsd)) ();
+  struct catch **const catchp = &CATCH_HOOK;
   struct catch *old_catch;
   receiver_fct old_receiver;
 
diff --git a/elf/dl-tsd.c b/elf/dl-tsd.c
index aa290a7961..c60cd1a760 100644
--- a/elf/dl-tsd.c
+++ b/elf/dl-tsd.c
@@ -17,10 +17,12 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
-#include <ldsodefs.h>
-#include <tls.h>
+#ifdef _LIBC_REENTRANT
 
-#ifndef SHARED
+# include <ldsodefs.h>
+# include <tls.h>
+
+# ifndef SHARED
 
 /* _dl_error_catch_tsd points to this for the single-threaded case.
    It's reset by the thread library for multithreaded programs
@@ -28,17 +30,17 @@
 static void ** __attribute__ ((const))
 startup_error_tsd (void)
 {
-#if USE___THREAD
+#  if USE___THREAD
   static __thread void *data;
-#else
+#  else
   static void *data;
-#endif
+#  endif
   return &data;
 }
 void **(*_dl_error_catch_tsd) (void) __attribute__ ((const))
      = &startup_error_tsd;
 
-#elif USE___THREAD
+# elif USE___THREAD
 
 /* libpthread sets _dl_error_catch_tsd to point to this function.
    We define it here instead of in libpthread so that it doesn't
@@ -51,4 +53,6 @@ __libc_dl_error_tsd (void)
   return &data;
 }
 
-#endif
+# endif	/* SHARED */
+
+#endif /* _LIBC_REENTRANT */
diff --git a/elf/rtld.c b/elf/rtld.c
index 3a64ca74f7..350cc700b5 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -560,6 +560,7 @@ match_version (const char *string, struct link_map *map)
   return 0;
 }
 
+#ifdef _LIBC_REENTRANT
 /* _dl_error_catch_tsd points to this for the single-threaded case.
    It's reset by the thread library for multithreaded programs.  */
 static void ** __attribute__ ((const))
@@ -568,6 +569,7 @@ startup_error_tsd (void)
   static void *data;
   return &data;
 }
+#endif
 
 static const char *library_path;	/* The library search path.  */
 static const char *preloadlist;		/* The list preloaded objects.  */
@@ -598,8 +600,10 @@ dl_main (const ElfW(Phdr) *phdr,
   void *tcbp;
 #endif
 
+#ifdef _LIBC_REENTRANT
   /* Explicit initialization since the reloc would just be more work.  */
   GL(dl_error_catch_tsd) = &startup_error_tsd;
+#endif
 
   /* Process the environment variable which control the behaviour.  */
   process_envvars (&mode);