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 (danielwa) 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
optimization

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
dependencies.

Loader retrains the same functionality during flag promotions:
RTLD_GLOBAL
RTLD_NODELETE

https://sourceware.org/bugzilla/show_bug.cgi?id=25615
---
 elf/dl-open.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

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)
   ++new->l_direct_opencount;
 
   /* 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))