unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: "Daniel Walker \(danielwa\) via Libc-alpha" <libc-alpha@sourceware.org>
To: "Carlos O'Donell" <carlos@redhat.com>
Cc: Florian Weimer <fweimer@redhat.com>,
	Pedro Alves <palves@redhat.com>,
	"libc-alpha@sourceware.org" <libc-alpha@sourceware.org>,
	"Jeremy Stenglein \(jstengle\)" <jstengle@cisco.com>,
	"xe-linux-external\(mailer list\)" <xe-linux-external@cisco.com>
Subject: Re: [RFC PATCH 0/3] implement dlmopen hooks for gdb
Date: Thu, 23 Jul 2020 18:40:55 +0000	[thread overview]
Message-ID: <20200723184054.GD9875@zorba> (raw)
In-Reply-To: <0f791d3a-20bc-4524-54eb-ce6df108fbff@redhat.com>

On Fri, Jun 26, 2020 at 05:17:17PM -0400, Carlos O'Donell wrote:
> On 6/26/20 3:32 PM, Daniel Walker via Libc-alpha wrote:
> > Cisco System, Inc. has a need to have dlmopen support in gdb, which
> > required glibc changes. I think it was known when glibc implemented
> > dlmopen that gdb would not work with it.
> > 
> > Since 2015 Cisco has had these patches in our inventor to fix issues in
> > glibc which prevented this type of gdb usage.
> > 
> > This RFC is mainly to get guidance on this implementation. We have some
> > individuals who have signed the copyright assignment for glibc, and we
> > will submit these (or different patches) formally thru those channels if
> > no one has issues with the implementation.
> > 
> > Also included in this are a couple of fixes which went along with the
> > original implementation.
> > 
> > Please provide any comments you might have.
> > 
> > Conan C Huang (3):
> >   Segfault when dlopen with RTLD_GLOBAL in dlmopened library
> >   glibc: dlopen RTLD_NOLOAD optimization
> >   add r_debug multiple namespaces support
> > 
> >  elf/dl-close.c |  7 ++++++-
> >  elf/dl-debug.c | 13 ++++++++++---
> >  elf/dl-open.c  |  8 +++++++-
> >  elf/link.h     |  4 ++++
> >  4 files changed, 27 insertions(+), 5 deletions(-)
> > 
> 
> Thanks for looking at this. It is something the community would
> absolutely like to see. I'll comment quickly to provide direction.
> 
> Florian Weimer, Pedro Alves, and I were talking about this as
> recently as April where we tried to agree to just adding a
> _r_debug_dlmopen with a new ABI for the debugger to use.
> 


Here's another RFC I suppose. It's basic code I've only compile tested. It's
based on the comments, and the threads you provided. It just abstracts out the
next link into another structure. Let me know if this is in the ballpark of the
discussions.


---
 elf/dl-debug.c             | 19 +++++++++++++++++--
 elf/link.h                 |  6 ++++++
 sysdeps/generic/ldsodefs.h |  1 +
 3 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/elf/dl-debug.c b/elf/dl-debug.c
index 4b3d3ad6ba..d0009744f8 100644
--- a/elf/dl-debug.c
+++ b/elf/dl-debug.c
@@ -35,6 +35,7 @@ extern const int verify_link_map_members[(VERIFY_MEMBER (l_addr)
    a statically-linked program there is no dynamic section for the debugger
    to examine and it looks for this particular symbol name.  */
 struct r_debug _r_debug;
+struct r_debug_dlmopen _r_debug_dlmopen;
 
 
 /* Initialize _r_debug if it has not already been done.  The argument is
@@ -45,11 +46,22 @@ struct r_debug *
 _dl_debug_initialize (ElfW(Addr) ldbase, Lmid_t ns)
 {
   struct r_debug *r;
+  struct r_debug_dlmopen *r_ns, *rp_ns;
 
   if (ns == LM_ID_BASE)
-    r = &_r_debug;
+    {
+      r = &_r_debug;
+      r_ns = &_r_debug_dlmopen;
+    }
   else
-    r = &GL(dl_ns)[ns]._ns_debug;
+    {
+      r = &GL(dl_ns)[ns]._ns_debug;
+      r_ns = &GL(dl_ns)[ns]._ns_debug_dlmopen;
+      rp_ns = &GL(dl_ns)[ns - 1]._ns_debug_dlmopen;
+      rp_ns->next = r_ns;
+      if (ns - 1 == LM_ID_BASE)
+        _r_debug_dlmopen.next = r_ns;
+    }
 
   if (r->r_map == NULL || ldbase != 0)
     {
@@ -58,6 +70,9 @@ _dl_debug_initialize (ElfW(Addr) ldbase, Lmid_t ns)
       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_ns->r_debug = r;
+      r_ns->next = NULL;
+
     }
 
   return r;
diff --git a/elf/link.h b/elf/link.h
index 0048ad5d4d..c81945b671 100644
--- a/elf/link.h
+++ b/elf/link.h
@@ -63,8 +63,14 @@ struct r_debug
     ElfW(Addr) r_ldbase;	/* Base address the linker is loaded at.  */
   };
 
+struct r_debug_dlmopen
+  {
+    struct r_debug *r_debug;
+    struct r_debug_dlmopen *next;
+  };
 /* This is the instance of that structure used by the dynamic linker.  */
 extern struct r_debug _r_debug;
+extern struct r_debug_dlmopen _r_debug_dlmopen;
 
 /* This symbol refers to the "dynamic structure" in the `.dynamic' section
    of whatever module refers to `_DYNAMIC'.  So, to find its own
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
index ba114ab4b1..d9794bc7a0 100644
--- a/sysdeps/generic/ldsodefs.h
+++ b/sysdeps/generic/ldsodefs.h
@@ -357,6 +357,7 @@ struct rtld_global
     } _ns_unique_sym_table;
     /* Keep track of changes to each namespace' list.  */
     struct r_debug _ns_debug;
+    struct r_debug_dlmopen _ns_debug_dlmopen;
   } _dl_ns[DL_NNS];
   /* One higher than index of last used namespace.  */
   EXTERN size_t _dl_nns;
-- 
2.17.1

  reply	other threads:[~2020-07-23 18:41 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-26 19:32 [RFC PATCH 0/3] implement dlmopen hooks for gdb Daniel Walker via Libc-alpha
2020-06-26 21:17 ` Carlos O'Donell via Libc-alpha
2020-07-23 18:40   ` Daniel Walker (danielwa) via Libc-alpha [this message]
2020-07-23 21:20     ` Carlos O'Donell via Libc-alpha
2020-09-16 16:18       ` Daniel Walker (danielwa) via Libc-alpha
2020-09-17 12:52         ` Carlos O'Donell via Libc-alpha
2020-09-17 12:59           ` Florian Weimer via Libc-alpha
2020-09-17 13:53             ` Carlos O'Donell via Libc-alpha
2020-09-18 15:35               ` Daniel Walker (danielwa) via Libc-alpha
2020-09-18 15:40                 ` Florian Weimer via Libc-alpha
2020-09-21 20:02                   ` Daniel Walker (danielwa) via Libc-alpha
2021-07-28 18:33                   ` Daniel Walker via Libc-alpha
2021-07-28 18:48                     ` H.J. Lu via Libc-alpha
2020-09-17 13:52           ` Carlos O'Donell via Libc-alpha
2020-09-22 17:06       ` Florian Weimer via Libc-alpha
2020-09-22 17:28         ` Carlos O'Donell via Libc-alpha
2020-09-22 17:37           ` Florian Weimer via Libc-alpha
2020-09-22 17:59             ` Carlos O'Donell via Libc-alpha
2020-09-22 18:04               ` Florian Weimer via Libc-alpha
2020-09-22 18:41                 ` Carlos O'Donell via Libc-alpha
2020-09-22 18:44                   ` Florian Weimer via Libc-alpha
2020-09-22 18:46                     ` Carlos O'Donell via Libc-alpha
2020-09-22 18:17               ` Andreas Schwab
2020-09-22 19:13                 ` Carlos O'Donell via Libc-alpha
2020-06-26 21:30 ` Florian Weimer via Libc-alpha
2020-06-27  1:10   ` Daniel Walker (danielwa) via Libc-alpha
2020-07-02 13:54     ` Conan Huang (conhuang) via Libc-alpha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200723184054.GD9875@zorba \
    --to=libc-alpha@sourceware.org \
    --cc=carlos@redhat.com \
    --cc=danielwa@cisco.com \
    --cc=fweimer@redhat.com \
    --cc=jstengle@cisco.com \
    --cc=palves@redhat.com \
    --cc=xe-linux-external@cisco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).