unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [RFC PATCH 3/3] add r_debug multiple namespaces support
@ 2020-06-26 19:32 Daniel Walker via Libc-alpha
  2020-06-26 21:05 ` Florian Weimer via Libc-alpha
  0 siblings, 1 reply; 32+ messages in thread
From: Daniel Walker via Libc-alpha @ 2020-06-26 19:32 UTC (permalink / raw)
  To: libc-alpha; +Cc: Conan C Huang, Jeremy Stenglein, xe-linux-external

From: Conan C Huang <conhuang@cisco.com>

GLIBC Bugzilla: 15971
GDB Bugzilla: 11839

Glibc does not provide an interface for debugger to access libraries loaded in
multiple namespaces via dlmopen.

The current rtld-debugger interface is described in the file
elf/rtld-debugger-interface.txt under the "Standard debugger interface" heading.
This interface only provides access to the first link-map (LM_ID_BASE).

This solution converts r_debug into a linked-list, where each element correlates
to an unique namespace. Debugger (GDB) can traverse r_debug linked-list to
retrieve information for all loaded namespaces.
---
 elf/dl-debug.c | 13 ++++++++++---
 elf/link.h     |  4 ++++
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/elf/dl-debug.c b/elf/dl-debug.c
index 4b3d3ad6ba..7eba477fd3 100644
--- a/elf/dl-debug.c
+++ b/elf/dl-debug.c
@@ -44,20 +44,27 @@ struct r_debug _r_debug;
 struct r_debug *
 _dl_debug_initialize (ElfW(Addr) ldbase, Lmid_t ns)
 {
-  struct r_debug *r;
+  struct r_debug *r, *rp;
 
   if (ns == LM_ID_BASE)
     r = &_r_debug;
   else
-    r = &GL(dl_ns)[ns]._ns_debug;
+    {
+      r = &GL(dl_ns)[ns]._ns_debug;
+      rp = &GL(dl_ns)[ns - 1]._ns_debug;
+      rp->next = r;
+      if (ns - 1 == LM_ID_BASE)
+        _r_debug.next = r;
+    }
 
   if (r->r_map == NULL || ldbase != 0)
     {
       /* Tell the debugger where to find the map of loaded objects.  */
-      r->r_version = 1	/* R_DEBUG_VERSION XXX */;
+      r->r_version = 3  /* R_DEBUG_VERSION XXX */;
       r->r_ldbase = ldbase ?: _r_debug.r_ldbase;
       r->r_map = (void *) GL(dl_ns)[ns]._ns_loaded;
       r->r_brk = (ElfW(Addr)) &_dl_debug_state;
+      r->next = NULL;
     }
 
   return r;
diff --git a/elf/link.h b/elf/link.h
index 0048ad5d4d..5a42511636 100644
--- a/elf/link.h
+++ b/elf/link.h
@@ -61,6 +61,10 @@ struct r_debug
       } r_state;
 
     ElfW(Addr) r_ldbase;	/* Base address the linker is loaded at.  */
+
+    /* Link to next r_debug struct. Each r_debug struct represents a
+       different namespace.  The first r_debug struct is the default.  */
+    struct r_debug *next;
   };
 
 /* This is the instance of that structure used by the dynamic linker.  */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2021-08-17  1:12 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-26 19:32 [RFC PATCH 3/3] add r_debug multiple namespaces support Daniel Walker via Libc-alpha
2020-06-26 21:05 ` Florian Weimer via Libc-alpha
2020-06-26 21:19   ` Carlos O'Donell via Libc-alpha
2020-06-26 21:24     ` Florian Weimer via Libc-alpha
2020-06-26 21:44       ` Carlos O'Donell via Libc-alpha
2020-06-27  9:34         ` Florian Weimer
2020-06-28 12:34           ` Carlos O'Donell via Libc-alpha
2020-06-29  8:51             ` Florian Weimer via Libc-alpha
2021-07-23 23:38               ` H.J. Lu via Libc-alpha
2021-07-27 17:39                 ` Daniel Walker via Libc-alpha
2021-07-27 18:14                   ` H.J. Lu via Libc-alpha
2021-07-28 15:15                     ` H.J. Lu via Libc-alpha
2021-07-28 15:44                       ` Daniel Walker via Libc-alpha
2021-07-28 17:14                         ` H.J. Lu via Libc-alpha
2021-07-28 19:02                           ` Daniel Walker via Libc-alpha
2021-07-28 20:04                             ` H.J. Lu via Libc-alpha
2021-08-02  4:24                               ` RFC: Add DT_GNU_DEBUG H.J. Lu via Libc-alpha
2021-08-02  5:22                                 ` Florian Weimer via Libc-alpha
2021-08-02 13:10                                   ` H.J. Lu via Libc-alpha
2021-08-03 16:39                                     ` Daniel Walker via Libc-alpha
2021-08-03 18:08                                       ` H.J. Lu via Libc-alpha
2021-08-03 20:04                                         ` Daniel Walker via Libc-alpha
2021-08-03 18:12                                       ` Florian Weimer via Libc-alpha
2021-08-03 18:23                                         ` H.J. Lu via Libc-alpha
2021-08-03 20:13                                           ` Florian Weimer via Libc-alpha
2021-08-03 20:21                                             ` H.J. Lu via Libc-alpha
2021-08-09 14:32                                               ` RFC: 2 choices of DT_XXX for dlmopen H.J. Lu via Libc-alpha
2021-08-09 17:16                                                 ` Daniel Walker via Libc-alpha
2021-08-15  0:33                                                   ` [PATCH] Extend struct r_debug to support multiple namespaces H.J. Lu via Libc-alpha
2021-08-16 16:20                                                     ` Daniel Walker via Libc-alpha
2021-08-17  1:07                                                       ` H.J. Lu via Libc-alpha
2020-06-27  1:21       ` [RFC PATCH 3/3] add r_debug multiple namespaces support Daniel Walker (danielwa) via Libc-alpha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).