diff mbox series

[RFC,2/3] glibc: dlopen RTLD_NOLOAD optimization

Message ID 20200626193228.1953-3-danielwa@cisco.com
State New
Headers show
Series implement dlmopen hooks for gdb | expand

Commit Message

Daniel Walker June 26, 2020, 7:32 p.m. UTC
From: Conan C Huang <conhuang@cisco.com>

This is a fix for GLIBC Bugzilla #25615: dlopen RTLD_NOLOAD

When dlopen with RTLD_NOLOAD flag, loader should simply return the
link_map or NULL and promote flags like RTLD_GLOBAL and RTLD_NODELETE.

Loader shouldn't need to process any dependencies. In dl_open_worker,
loader should avoid calling _dl_map_object_deps. _dl_map_object_deps
is very time consuming on low-end platforms with lots of library

Loader retrains the same functionality during flag promotions:

 elf/dl-open.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series


diff --git a/elf/dl-open.c b/elf/dl-open.c
index 9b3606c491..cfef39ec53 100644
--- a/elf/dl-open.c
+++ b/elf/dl-open.c
@@ -542,7 +542,9 @@  dl_open_worker (void *a)
   /* It was already open.  */
-  if (__glibc_unlikely (new->l_searchlist.r_list != NULL))
+  if (__glibc_unlikely (new->l_searchlist.r_list != NULL) ||
+      (__glibc_unlikely (mode & RTLD_NOLOAD) &&
+       __glibc_unlikely (!(mode & RTLD_GLOBAL))))
       /* Let the user know about the opencount.  */
       if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_FILES))