]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/solib-svr4: update solib when an inferior is not being executed (e.g. core files)
authorSébastien Darche <sdarche@efficios.com>
Tue, 30 Sep 2025 18:54:29 +0000 (14:54 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Fri, 9 Jan 2026 19:54:47 +0000 (14:54 -0500)
Loading a core file currently generates a warning when enabling `set
verbose on`:

    $ ./gdb -nx -q --data-directory=data-directory a.out -ex "set verbose on" -ex "core core.151894" -batch
    ...
    warning: platform-specific solib_create_inferior_hook did not load initial shared libraries.

The warning comes from infcmd.c:post_create_inferior() which initializes
the solib_ops.  The latter is in charge of calling solib_add() in its
implementation of solib_ops::create_inferior_hook.  The svr4_solib_ops
class, however, does not call solib_add (through enable_break) if the
inferior is not being executed.

This patch moves the call to solib_add() outside of the conditional
nested call.  No user-visible change should be expected, except for fact
that the warning will no longer be shown.

Change-Id: I5488dc166fdc985669422a0f1c0c2f43158cd8c4
Reviewed-By: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdb/solib-svr4.c

index 127e51a5dc85d59d3e4f0f77abb17db394e3de5f..8beb545fd9a7eea23b88d41c027039cba04fae92 100644 (file)
@@ -2527,8 +2527,6 @@ svr4_solib_ops::enable_break (svr4_info *info, int from_tty) const
      mean r_brk has already been relocated.  Assume the dynamic linker
      is the object containing r_brk.  */
 
-  solib_add (NULL, from_tty, auto_solib_add);
-
   CORE_ADDR sym_addr = 0;
   CORE_ADDR default_debug_base = this->default_debug_base (info);
 
@@ -3341,6 +3339,11 @@ svr4_solib_ops::create_inferior_hook (int from_tty) const
   /* Relocate the main executable if necessary.  */
   svr4_relocate_main_executable ();
 
+  /* Read the initial library list at this point.  Even if the target
+     is not being executed (e.g. loading a core file), we can load the
+     symbols from our sos.  */
+  solib_add (nullptr, from_tty, auto_solib_add);
+
   /* No point setting a breakpoint in the dynamic linker if we can't
      hit it (e.g., a core file, or a trace file).  */
   if (!target_has_execution ())