]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - elf/pldd-xx.c
install.texi: Build was tested with binutils 2.41 (just released)
[thirdparty/glibc.git] / elf / pldd-xx.c
index 1cdfb49c539937fb1ee39a30a26cf9a770f02924..36fcaff2fb513218a55531d8eb7fc44fb5d81506 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011-2022 Free Software Foundation, Inc.
+/* Copyright (C) 2011-2023 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -22,6 +22,8 @@
 #define EW_(e, w, t) EW__(e, w, _##t)
 #define EW__(e, w, t) e##w##t
 
+#include <dl-r_debug.h>
+
 struct E(link_map)
 {
   EW(Addr) l_addr;
@@ -126,21 +128,25 @@ E(find_maps) (const char *exe, int memfd, pid_t pid, void *auxv,
            != p[i].p_filesz)
          error (EXIT_FAILURE, 0, gettext ("cannot read dynamic section"));
 
-       /* Search for the DT_DEBUG entry.  */
+       /* Search for the struct r_debug.  */
        for (unsigned int j = 0; j < p[i].p_filesz / sizeof (EW(Dyn)); ++j)
-         if (dyn[j].d_tag == DT_DEBUG && dyn[j].d_un.d_ptr != 0)
-           {
-             struct E(r_debug) r;
-             if (pread (memfd, &r, sizeof (r), dyn[j].d_un.d_ptr)
-                 != sizeof (r))
-               error (EXIT_FAILURE, 0, gettext ("cannot read r_debug"));
-
-             if (r.r_map != 0)
-               {
-                 list = r.r_map;
-                 break;
-               }
-           }
+         {
+           EW(Addr) off = offset + p[i].p_vaddr + sizeof (EW(Dyn)) * j;
+           off = E(r_debug_offset) (&dyn[j], memfd, off);
+           if (off != 0)
+             {
+               struct E(r_debug) r;
+               if (pread (memfd, &r, sizeof (r), off)
+                   != sizeof (r))
+                 error (EXIT_FAILURE, 0, gettext ("cannot read r_debug"));
+
+               if (r.r_map != 0)
+                 {
+                   list = r.r_map;
+                   break;
+                 }
+             }
+         }
 
        free (dyn);
        break;