From: Sébastien Darche Date: Tue, 30 Sep 2025 18:54:29 +0000 (-0400) Subject: gdb/solib-svr4: update solib when an inferior is not being executed (e.g. core files) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=69e5ddaf799c08a66b2c4d87bdc729d8bbed3d02;p=thirdparty%2Fbinutils-gdb.git gdb/solib-svr4: update solib when an inferior is not being executed (e.g. core files) 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 Approved-By: Simon Marchi --- diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index 127e51a5dc8..8beb545fd9a 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -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 ())