[v2,29/32] elf: Use _dl_find_object instead of _dl_find_dso_for_object in dlopen

Message ID 73af1f724be496a366d2edd680124c1fdbd8c32e.1688741159.git.fweimer@redhat.com
State Superseded
Headers
Series RELRO link maps |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 fail Testing failed
linaro-tcwg-bot/tcwg_glibc_check--master-arm fail Testing failed
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Testing passed

Commit Message

Florian Weimer July 7, 2023, 6:49 p.m. UTC
  The _dl_find_object uses a binary search and is faster if there are many
objects.
---
 elf/dl-open.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
  

Patch

diff --git a/elf/dl-open.c b/elf/dl-open.c
index 9f9407341e..9bd48826f9 100644
--- a/elf/dl-open.c
+++ b/elf/dl-open.c
@@ -894,8 +894,10 @@  no more namespaces available for dlmopen()"));
   if (nsid == __LM_ID_CALLER || strchr (file, '$') != NULL
       || strchr (file, '/') == NULL)
     {
-      args.caller_map = _dl_find_dso_for_object ((ElfW(Addr)) caller_dlopen);
-      if (args.caller_map == NULL)
+      struct dl_find_object dlfo;
+      if (_dl_find_object ((void *) caller_dlopen, &dlfo) == 0)
+	args.caller_map = l_private (dlfo.dlfo_link_map);
+      else
 	/* By default we assume this is the main application.  */
 	args.caller_map = GL(dl_ns)[LM_ID_BASE]._ns_loaded;
       if (args.nsid == __LM_ID_CALLER)