about summary refs log tree commit diff
path: root/include
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 /include
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 'include')
-rw-r--r--include/dlfcn.h31
1 files changed, 14 insertions, 17 deletions
diff --git a/include/dlfcn.h b/include/dlfcn.h
index 711bbb0f12..d4440c567e 100644
--- a/include/dlfcn.h
+++ b/include/dlfcn.h
@@ -91,8 +91,12 @@ libc_hidden_proto (_dl_vsym)
 extern int _dlerror_run (void (*operate) (void *), void *args);
 libc_hidden_proto (_dlerror_run)
 
+/* This structure is used to make the outer (statically linked)
+   implementation of dlopen and related functions to the inner libc
+   after static dlopen, via the GLRO (dl_dlfcn_hook) pointer.  */
 struct dlfcn_hook
 {
+  /* Public interfaces.  */
   void *(*dlopen) (const char *file, int mode, void *dl_caller);
   int (*dlclose) (void *handle);
   void *(*dlsym) (void *handle, const char *name, void *dl_caller);
@@ -104,15 +108,17 @@ struct dlfcn_hook
 		  void **extra_info, int flags);
   int (*dlinfo) (void *handle, int request, void *arg);
   void *(*dlmopen) (Lmid_t nsid, const char *file, int mode, void *dl_caller);
-  void *pad[4];
-};
 
-extern struct dlfcn_hook *_dlfcn_hook;
-libc_hidden_proto (_dlfcn_hook)
+  /* Internal interfaces.  */
+  void* (*libc_dlopen_mode)  (const char *__name, int __mode);
+  void* (*libc_dlsym)  (void *map, const char *name);
+  void* (*libc_dlvsym)  (void *map, const char *name, const char *version);
+  int   (*libc_dlclose) (void *map);
+};
 
-/* Note: These prototypes are for initializing _dflcn_hook in static
-   libraries.  Internal calls in glibc should use the __libc_dl*
-   functions defined in elf/dl-libc.c instead.  */
+/* Note: These prototypes are for initializing _dlfcn_hook in static
+   builds; see __rtld_static_init.  Internal calls in glibc should use
+   the __libc_dl* functions defined in elf/dl-libc.c instead.  */
 
 extern void *__dlopen (const char *file, int mode, void *caller);
 extern void *__dlmopen (Lmid_t nsid, const char *file, int mode,
@@ -125,16 +131,7 @@ extern int __dladdr (const void *address, Dl_info *info);
 extern int __dladdr1 (const void *address, Dl_info *info,
 		      void **extra_info, int flags);
 extern int __dlinfo (void *handle, int request, void *arg);
-
-#ifndef SHARED
-struct link_map;
-extern void * __libc_dlsym_private (struct link_map *map, const char *name)
-     attribute_hidden;
-extern void __libc_register_dl_open_hook (struct link_map *map)
-     attribute_hidden;
-extern void __libc_register_dlfcn_hook (struct link_map *map)
-     attribute_hidden;
-#endif
+extern char *__dlerror (void);
 
 #endif
 #endif