Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: "Metzger, Markus T" <markus.t.metzger@intel.com>,
	"hjl.tools@gmail.com" <hjl.tools@gmail.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [PATCH v5 03/15] gdb, gdbserver: support dlmopen()
Date: Tue, 22 Jul 2025 10:58:51 -0400	[thread overview]
Message-ID: <3bec817b-1660-44df-b20d-64b75e1726fa@simark.ca> (raw)
In-Reply-To: <DM8PR11MB57490560B179CB369995196EDE5CA@DM8PR11MB5749.namprd11.prod.outlook.com>

On 7/22/25 3:07 AM, Metzger, Markus T wrote:
> Hello Simon,
> 
> This concept of the debug object moving is much older.  See for example:
> 
> commit 60d09f0a0d8000359b8f1dd14b51e7f013ea9e5c
> Author: Markus Metzger <markus.t.metzger@intel.com>
> Date:   Fri Mar 11 06:46:15 2022 +0100
> 
>     gdb, solib-svr4: remove locate_base()
>     
>     Whenever we call locate_base(), we clear info->debug_base directly before
>     the call.  Thus, we never cache the base location as locate_base() had
>     intended.
>     
>     Move the svr4_have_link_map_offsets() check into elf_locate_base(), inline
>     locate_base() at all call sites, and remove it.
> 
> 
> This patch removes some caching of the debug base that had been intentionally
> disabled on every call to locate_base(), which was supposed to find the debug
> object once and then cache its address for further use.
> 
> A typical hunk in this patch is:
> 
> @@ -1839,8 +1799,8 @@ svr4_handle_solib_event (void)
>        return;
>  
>      /* Always locate the debug struct, in case it moved.  */
> -    info->debug_base = 0;
> -    if (locate_base (info) == 0)
> +    info->debug_base = elf_locate_base ();
> +    if (info->debug_base == 0)
>        {
>         /* It's possible for the reloc_complete probe to be triggered before
>            the linker has set the DT_DEBUG pointer (for example, when the
> 
> Maybe H.J. has more information on this; a concrete example, maybe?

Thanks for the pointer to the patch.  I understand how this code was
indeed dead before your patch.  If H.J. knows concrete examples, it
would be very nice.

The 2008 patch from Daniel Jacobowitz I pointed to in my other email
[1], that I think started this pattern, which probably then spread by
copy-paste, was about having a custom dynamic loader interposing itself
between the kernel and the libc dynamic loader:

    They are motivated by a custom dynamic linker I've been working with
    for the last few weeks.  It is an intermediate stage between the
    kernel ELF loader and the C library's normal runtime loader, which
    adjusts a couple of things in the new binary before it starts.  I
    have made it as transparent to the debugger as possible, but there
    are still a few quirks that seem impossible to eliminate (they bump
    up against the userspace/kernelspace security boundary).

My understanding is that his binary was using a custom dynamic loader
(INTERP), which was doing some stuff, then handed control over to the
real libc dynamic loader.

My question is basically: do we need to support this use case?  If this
was to support an experiment that someone was doing 20 years ago and
nothing else, then perhaps we can simplify the code today, which will
then make subsequent changes easier.

Right now I'm leaning towards not having to support that kind of use
case, until proven otherwise.

Simon

[1] https://pi.simark.ca/gdb-patches/20080221014732.GA27568@caradoc.them.org/T/#mb8a42f0b940333583bb4f7fffc3ea71dd75180de

  reply	other threads:[~2025-07-22 15:01 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-02 13:24 [PATCH v5 00/15] basic linker namespace support Markus Metzger via Gdb-patches
2022-06-02 13:25 ` [PATCH v5 01/15] gdb, testsuite: extend gdb_test_multiple checks Markus Metzger via Gdb-patches
2022-06-13  1:28   ` Kevin Buettner via Gdb-patches
2022-06-02 13:25 ` [PATCH v5 02/15] gdb, solib-svr4: remove locate_base() Markus Metzger via Gdb-patches
2022-06-02 23:04   ` Kevin Buettner via Gdb-patches
2022-06-02 13:25 ` [PATCH v5 03/15] gdb, gdbserver: support dlmopen() Markus Metzger via Gdb-patches
2022-06-19  4:02   ` Kevin Buettner via Gdb-patches
2022-06-27 12:55     ` Metzger, Markus T via Gdb-patches
2022-06-30 22:35       ` Kevin Buettner via Gdb-patches
2025-07-21 20:41   ` Simon Marchi
2025-07-22  7:07     ` Metzger, Markus T
2025-07-22 14:58       ` Simon Marchi [this message]
2022-06-02 13:25 ` [PATCH v5 04/15] gdbserver: move main_lm handling into caller Markus Metzger via Gdb-patches
2022-06-19  4:22   ` Kevin Buettner via Gdb-patches
2022-06-02 13:25 ` [PATCH v5 05/15] gdb, gdbserver: extend RSP to support namespaces Markus Metzger via Gdb-patches
2022-06-02 16:09   ` Eli Zaretskii via Gdb-patches
2022-06-19  4:32   ` Kevin Buettner via Gdb-patches
2022-06-02 13:25 ` [PATCH v5 06/15] gdb, compile: unlink objfile stored in module Markus Metzger via Gdb-patches
2022-06-23 17:20   ` Kevin Buettner via Gdb-patches
2022-06-02 13:25 ` [PATCH v5 07/15] gdb, python: use gdbarch_iterate_over_objfiles_in_search_order Markus Metzger via Gdb-patches
2022-06-24 17:18   ` Kevin Buettner via Gdb-patches
2022-06-02 13:25 ` [PATCH v5 08/15] gdb, ada: collect standard exceptions in all objfiles Markus Metzger via Gdb-patches
2022-06-24 17:26   ` Kevin Buettner via Gdb-patches
2022-07-18 16:49     ` Tom Tromey
2022-07-18  5:35   ` Metzger, Markus T via Gdb-patches
2022-09-14  8:19     ` Metzger, Markus T via Gdb-patches
2022-09-14  8:37       ` Joel Brobecker via Gdb-patches
2022-09-14  8:45         ` Metzger, Markus T via Gdb-patches
2022-06-02 13:25 ` [PATCH v5 09/15] gdb, ada: update ada_lookup_simple_minsym Markus Metzger via Gdb-patches
2022-06-24 23:42   ` Kevin Buettner via Gdb-patches
2022-07-18 17:02   ` Tom Tromey
2022-07-19  7:14     ` Metzger, Markus T via Gdb-patches
2022-09-14  8:19       ` Metzger, Markus T via Gdb-patches
2022-09-21 16:11         ` Tom Tromey
2022-06-02 13:25 ` [PATCH v5 10/15] gdb, ada: update ada_add_all_symbols Markus Metzger via Gdb-patches
2022-06-24 23:53   ` Kevin Buettner via Gdb-patches
2022-07-18  5:36   ` Metzger, Markus T via Gdb-patches
2022-07-18 16:56   ` Tom Tromey via Gdb-patches
2022-07-19  7:13     ` Metzger, Markus T via Gdb-patches
2022-07-19 12:23       ` Tom Tromey via Gdb-patches
2022-07-19 13:49         ` Metzger, Markus T via Gdb-patches
2022-06-02 13:25 ` [PATCH v5 11/15] gdb, cp: update add_symbol_overload_list_qualified Markus Metzger via Gdb-patches
2022-06-24 23:59   ` Kevin Buettner via Gdb-patches
2022-06-02 13:25 ` [PATCH v5 12/15] gdb, hppa: remove unused hppa_lookup_stub_minimal_symbol Markus Metzger via Gdb-patches
2022-06-25  0:01   ` Kevin Buettner via Gdb-patches
2022-06-02 13:25 ` [PATCH v5 13/15] gdb, symtab: inline find_quick_global_symbol_language Markus Metzger via Gdb-patches
2022-06-25  0:16   ` Kevin Buettner via Gdb-patches
2022-06-02 13:25 ` [PATCH v5 14/15] gdb: update gnu ifunc resolve Markus Metzger via Gdb-patches
2022-06-25  0:34   ` Kevin Buettner via Gdb-patches
2022-06-02 13:25 ` [PATCH v5 15/15] gdb, solib-svr4: support namespaces in DSO iteration Markus Metzger via Gdb-patches
2022-06-25  0:42   ` Kevin Buettner via Gdb-patches
2022-07-15 10:30 ` [PATCH v5 00/15] basic linker namespace support Metzger, Markus T via Gdb-patches
2022-07-16  0:04   ` Kevin Buettner via Gdb-patches
2022-07-18  5:33     ` Metzger, Markus T via Gdb-patches
2022-10-05 11:16       ` Metzger, Markus T via Gdb-patches

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

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

  git send-email \
    --in-reply-to=3bec817b-1660-44df-b20d-64b75e1726fa@simark.ca \
    --to=simark@simark.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=hjl.tools@gmail.com \
    --cc=markus.t.metzger@intel.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