about summary refs log tree commit diff
path: root/elf/rtld_static_init.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2021-06-03 08:26:04 +0200
committerFlorian Weimer <fweimer@redhat.com>2021-06-03 09:12:05 +0200
commit466c1ea15f461edb8e3ffaf5d86d708876343bbf (patch)
tree43d42d322ff24bd12c4124a9edafc4e0e4232f0a /elf/rtld_static_init.c
parent9c76debc983e1a16e2e723b36526826713a671af (diff)
downloadglibc-466c1ea15f461edb8e3ffaf5d86d708876343bbf.tar.gz
glibc-466c1ea15f461edb8e3ffaf5d86d708876343bbf.tar.xz
glibc-466c1ea15f461edb8e3ffaf5d86d708876343bbf.zip
dlfcn: Rework static dlopen hooks
Consolidate all hooks structures into a single one.  There are
no static dlopen ABI concerns because glibc 2.34 already comes
with substantial ABI-incompatible changes in this area.  (Static
dlopen requires the exact same dynamic glibc version that was used
for static linking.)

The new approach uses a pointer to the hooks structure into
_rtld_global_ro and initalizes it in __rtld_static_init.  This avoids
a back-and-forth with various callback functions.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Diffstat (limited to 'elf/rtld_static_init.c')
-rw-r--r--elf/rtld_static_init.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/elf/rtld_static_init.c b/elf/rtld_static_init.c
index 42efecfbff..3f8abb6800 100644
--- a/elf/rtld_static_init.c
+++ b/elf/rtld_static_init.c
@@ -25,6 +25,23 @@
 
 #include <rtld_static_init.h>
 
+static const struct dlfcn_hook _dlfcn_hook =
+  {
+    .dlopen = __dlopen,
+    .dlclose = __dlclose,
+    .dlsym = __dlsym,
+    .dlvsym = __dlvsym,
+    .dlerror = __dlerror,
+    .dladdr = __dladdr,
+    .dladdr1 = __dladdr1,
+    .dlinfo = __dlinfo,
+    .dlmopen = __dlmopen,
+    .libc_dlopen_mode = __libc_dlopen_mode,
+    .libc_dlsym = __libc_dlsym,
+    .libc_dlvsym = __libc_dlvsym,
+    .libc_dlclose = __libc_dlclose,
+  };
+
 void
 __rtld_static_init (struct link_map *map)
 {
@@ -45,6 +62,7 @@ __rtld_static_init (struct link_map *map)
   extern __typeof (dl->_dl_clktck) _dl_clktck attribute_hidden;
   dl->_dl_clktck = _dl_clktck;
 #endif
+  dl->_dl_dlfcn_hook = &_dlfcn_hook;
   extern __typeof (dl->_dl_hwcap) _dl_hwcap attribute_hidden;
   dl->_dl_hwcap = _dl_hwcap;
   extern __typeof (dl->_dl_hwcap2) _dl_hwcap2 attribute_hidden;