about summary refs log tree commit diff
path: root/sysdeps/generic
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2022-11-03 09:39:31 +0100
committerFlorian Weimer <fweimer@redhat.com>2022-11-03 09:39:31 +0100
commitee1ada1bdb8074de6e1bdc956ab19aef7b6a7872 (patch)
tree4e70dfcb1c076da10542c08d7e0b3900a0a34adc /sysdeps/generic
parentf4ce325dfc50e13cf8240424fa0561fca78e72e7 (diff)
downloadglibc-ee1ada1bdb8074de6e1bdc956ab19aef7b6a7872.tar.gz
glibc-ee1ada1bdb8074de6e1bdc956ab19aef7b6a7872.tar.xz
glibc-ee1ada1bdb8074de6e1bdc956ab19aef7b6a7872.zip
elf: Rework exception handling in the dynamic loader [BZ #25486]
The old exception handling implementation used function interposition
to replace the dynamic loader implementation (no TLS support) with the
libc implementation (TLS support).  This results in problems if the
link order between the dynamic loader and libc is reversed (bug 25486).

The new implementation moves the entire implementation of the
exception handling functions back into the dynamic loader, using
THREAD_GETMEM and THREAD_SETMEM for thread-local data support.
These depends on Hurd support for these macros, added in commit
b65a82e4e757c1e6cb7073916 ("hurd: Add THREAD_GET/SETMEM/_NC").

One small obstacle is that the exception handling facilities are used
before the TCB has been set up, so a check is needed if the TCB is
available.  If not, a regular global variable is used to store the
exception handling information.

Also rename dl-error.c to dl-catch.c, to avoid confusion with the
dlerror function.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Diffstat (limited to 'sysdeps/generic')
-rw-r--r--sysdeps/generic/ldsodefs.h12
-rw-r--r--sysdeps/generic/localplt.data5
2 files changed, 4 insertions, 13 deletions
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
index 2747f88d0e..9dae72b1ed 100644
--- a/sysdeps/generic/ldsodefs.h
+++ b/sysdeps/generic/ldsodefs.h
@@ -848,13 +848,13 @@ rtld_hidden_proto (_dl_exception_free)
 void _dl_signal_exception (int errcode, struct dl_exception *,
 			   const char *occasion)
   __attribute__ ((__noreturn__));
-libc_hidden_proto (_dl_signal_exception)
+rtld_hidden_proto (_dl_signal_exception)
 
 /* Like _dl_signal_exception, but creates the exception first.  */
 extern void _dl_signal_error (int errcode, const char *object,
 			      const char *occasion, const char *errstring)
      __attribute__ ((__noreturn__));
-libc_hidden_proto (_dl_signal_error)
+rtld_hidden_proto (_dl_signal_error)
 
 /* Like _dl_signal_exception, but may return when called in the
    context of _dl_receive_error.  This is only used during ld.so
@@ -906,11 +906,7 @@ extern void _dl_receive_error (receiver_fct fct, void (*operate) (void *),
    the returned string is allocated using the libc's malloc.  */
 extern int _dl_catch_error (const char **objname, const char **errstring,
 			    bool *mallocedp, void (*operate) (void *),
-			    void *args);
-libc_hidden_proto (_dl_catch_error)
-
-/* Used for initializing GLRO (_dl_catch_error).  */
-extern __typeof__ (_dl_catch_error) _rtld_catch_error attribute_hidden;
+			    void *args) attribute_hidden;
 
 /* Call OPERATE (ARGS).  If no error occurs, set *EXCEPTION to zero.
    Otherwise, store a copy of the raised exception in *EXCEPTION,
@@ -919,7 +915,7 @@ extern __typeof__ (_dl_catch_error) _rtld_catch_error attribute_hidden;
    disabled (so that exceptions are fatal).  */
 int _dl_catch_exception (struct dl_exception *exception,
 			 void (*operate) (void *), void *args);
-libc_hidden_proto (_dl_catch_exception)
+rtld_hidden_proto (_dl_catch_exception)
 
 /* Open the shared object NAME and map in its segments.
    LOADER's DT_RPATH is used in searching for NAME.
diff --git a/sysdeps/generic/localplt.data b/sysdeps/generic/localplt.data
index 9b4f35786a..afa03b0de1 100644
--- a/sysdeps/generic/localplt.data
+++ b/sysdeps/generic/localplt.data
@@ -6,8 +6,3 @@ libc.so: free
 libc.so: malloc
 libc.so: realloc
 libm.so: matherr
-# The TLS-enabled version of these functions is interposed from libc.so.
-ld.so: _dl_signal_error
-ld.so: _dl_catch_error
-ld.so: _dl_signal_exception
-ld.so: _dl_catch_exception