This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug dynamic-link/22277] __dl_iterate_phdr dlpi_subs computation off


https://sourceware.org/bugzilla/show_bug.cgi?id=22277

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schwab at sourceware dot org

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Note that

+         /* There must be exactly one DSO for the range of the virtual
+            memory.  Otherwise something is really broken.  */
+         ns = cnt;

misses the obvious optimization of not needing to continue iteration, like
the following.  Though the comment was removed at some point.

diff --git a/elf/dl-iteratephdr.c b/elf/dl-iteratephdr.c
index 88473e790b..c33f6e14f2 100644
--- a/elf/dl-iteratephdr.c
+++ b/elf/dl-iteratephdr.c
@@ -47,17 +47,20 @@ __dl_iterate_phdr (int (*callback) (struct dl_phdr_info
*info,
 #ifdef SHARED
   const void *caller = RETURN_ADDRESS (0);
   for (Lmid_t cnt = GL(dl_nns) - 1; cnt > 0; --cnt)
-    for (struct link_map *l = GL(dl_ns)[cnt]._ns_loaded; l; l = l->l_next)
-      {
-       /* We have to count the total number of loaded objects.  */
-       nloaded += GL(dl_ns)[cnt]._ns_nloaded;
-
-       if (caller >= (const void *) l->l_map_start
-           && caller < (const void *) l->l_map_end
-           && (l->l_contiguous
-               || _dl_addr_inside_object (l, (ElfW(Addr)) caller)))
-         ns = cnt;
-      }
+    {
+      /* We have to count the total number of loaded objects.  */
+      nloaded += GL(dl_ns)[cnt]._ns_nloaded;
+      if (ns == 0)
+       for (struct link_map *l = GL(dl_ns)[cnt]._ns_loaded; l; l = l->l_next)
+         if (caller >= (const void *) l->l_map_start
+             && caller < (const void *) l->l_map_end
+             && (l->l_contiguous
+                 || _dl_addr_inside_object (l, (ElfW(Addr)) caller)))
+           {
+             ns = cnt;
+             break;
+           }
+    }
 #endif

   for (l = GL(dl_ns)[ns]._ns_loaded; l != NULL; l = l->l_next)

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]