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] New: __dl_iterate_phdr dlpi_subs computation off


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

            Bug ID: 22277
           Summary: __dl_iterate_phdr dlpi_subs computation off
           Product: glibc
           Version: 2.28
            Status: NEW
          Severity: normal
          Priority: P2
         Component: dynamic-link
          Assignee: unassigned at sourceware dot org
          Reporter: rguenth at gcc dot gnu.org
  Target Milestone: ---

It looks like GL(dl_ns)[cnt]._ns_nloaded for cnt > 0 is accounted N times
instead of once.  Fix:

diff --git a/elf/dl-iteratephdr.c b/elf/dl-iteratephdr.c
index 88473e790b..bbbd8c1e8f 100644
--- a/elf/dl-iteratephdr.c
+++ b/elf/dl-iteratephdr.c
@@ -47,17 +47,16 @@ __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;
-
+    {
+      /* We have to count the total number of loaded objects.  */
+      nloaded += GL(dl_ns)[cnt]._ns_nloaded;
+      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;
-      }
+    }
 #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]