]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
elf: Use _dl_find_object instead of _dl_find_dso_for_object in dlopen
authorFlorian Weimer <fweimer@redhat.com>
Sun, 2 Feb 2025 19:10:09 +0000 (20:10 +0100)
committerFlorian Weimer <fweimer@redhat.com>
Sun, 2 Feb 2025 19:10:09 +0000 (20:10 +0100)
The _dl_find_object function uses a binary search and is faster if
there are many objects.

elf/dl-open.c

index ee420983cdc04333ddacda36320b08eb42bd2cda..60a1dce9de7d4e20fc22bf407f2210b260338e1c 100644 (file)
@@ -866,8 +866,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 = 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)