diff mbox series

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

Message ID 46bd211cba668b2b5cda6ccb5f7a1e3cfdc33a4f.1701944612.git.fweimer@redhat.com
State New
Headers show
Series RELRO linkmaps | expand

Commit Message

Florian Weimer Dec. 7, 2023, 10:32 a.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(-)

Comments

Joseph Myers Feb. 28, 2024, 7:27 p.m. UTC | #1
On Thu, 7 Dec 2023, Florian Weimer wrote:

> The _dl_find_object uses a binary search and is faster if there are many
> objects.

OK.
diff mbox series

Patch

diff --git a/elf/dl-open.c b/elf/dl-open.c
index a8c9945f2b..47638128dc 100644
--- a/elf/dl-open.c
+++ b/elf/dl-open.c
@@ -913,8 +913,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)