]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit - gdbserver/linux-low.cc
gdb, gdbserver: support dlmopen()
authorMarkus Metzger <markus.t.metzger@intel.com>
Mon, 4 Oct 2021 08:24:35 +0000 (10:24 +0200)
committerMarkus Metzger <markus.t.metzger@intel.com>
Tue, 18 Oct 2022 12:16:08 +0000 (14:16 +0200)
commit8d56636a0ecbe6c38bf52b0683326ee21693c548
treed31ea425eab963a5849039435427ea2880dba1c2
parent60d09f0a0d8000359b8f1dd14b51e7f013ea9e5c
gdb, gdbserver: support dlmopen()

In glibc, the r_debug structure contains (amongst others) the following
fields:

  int r_version:
    Version number for this protocol.  It should be greater than 0.

If r_version is 2, struct r_debug is extended to struct r_debug_extended
with one additional field:

  struct r_debug_extended *r_next;
    Link to the next r_debug_extended structure.  Each r_debug_extended
    structure represents a different namespace.  The first r_debug_extended
    structure is for the default namespace.

1. Change solib_svr4_r_map argument to take the debug base.
2. Add solib_svr4_r_next to find the link map in the next namespace from
the r_next field.
3. Update svr4_current_sos_direct to get the link map in the next namespace
from the r_next field.
4. Don't check shared libraries in other namespaces when updating shared
libraries in a new namespace.
5. Update svr4_same to check the load offset in addition to the name
6. Update svr4_default_sos to also set l_addr_inferior
7. Change the flat solib_list into a per-namespace list using the
namespace's r_debug address to identify the namespace.

Add gdb.base/dlmopen.exp to test this.

To remain backwards compatible with older gdbserver, we reserve the
namespace zero for a flat list of solibs from all namespaces.  Subsequent
patches will extend RSP to allow listing libraries grouped by namespace.

This fixes PR 11839.

Co-authored-by: Lu, Hongjiu <hongjiu.lu@intel.com>
gdb/linux-tdep.c
gdb/mips-fbsd-tdep.c
gdb/mips-netbsd-tdep.c
gdb/solib-svr4.c
gdb/solib-svr4.h
gdb/testsuite/gdb.base/dlmopen-lib.c [new file with mode: 0644]
gdb/testsuite/gdb.base/dlmopen.c [new file with mode: 0644]
gdb/testsuite/gdb.base/dlmopen.exp [new file with mode: 0644]
gdb/testsuite/lib/gdb.exp
gdbserver/linux-low.cc