aboutsummaryrefslogtreecommitdiff
path: root/gdb/solib-target.c
diff options
context:
space:
mode:
authorGuinevere Larsen <guinevere@redhat.com>2025-04-23 16:47:34 -0300
committerGuinevere Larsen <guinevere@redhat.com>2025-04-28 09:37:51 -0300
commit4b49754a483ffcc35ed537c5b91b9a365750df37 (patch)
tree7cd58380d382e8cb467ad2217132c6c86869fd91 /gdb/solib-target.c
parent0dd7ddbea74f09ae483ceaaf657a44df1a8ddbc4 (diff)
downloadbinutils-users/guinevere/symbol_in_linker_namespace.zip
binutils-users/guinevere/symbol_in_linker_namespace.tar.gz
binutils-users/guinevere/symbol_in_linker_namespace.tar.bz2
gdb: make gdb_bfd cache aware of linker namespacesusers/guinevere/symbol_in_linker_namespace
In an attempt to improve GDB's speed, GDB has implemented a cache for BFD objects to a file. This works great in most cases, however, when using linker namespaces, it is possible to load the exact same file many times, which the gdb_bfd_cache would reuse the object. The problem comes because in different namespaces, variables may have different addresses, but if the address can be determined at read time, the variable will be marked with address class LOC_STATIC, and that address will only be correct for one of the namespaces (whichever was expanded first). This patch attempts to fix that by adding a new parameter to the gdb_bfd_cache, the linker namespace where the objfile is being loaded. By default, this value will be -1, but in systems that support linker namespaces, it will be correctly set. To manage that, a small refactor to solib_ops::bfd_open was necessary. Having only the file's full path is not sufficient to determine the linker namespace, specifically because the same file can be loaded multiple times. So instead, solib_ops::bfd_open has been changed to take a reference to the solib being read, instead of just the file name. This leads to the next problem, as solib_bfd_open is used to read the interpreter, which has no solib value at that point and must be opened by the file name alone. This final problem is solved by introducing solib_bfd_open_from_solib, a new helper that will be the default behavior of solib_ops::bfd_open, and solib_bfd_open is left untouched, so that other readers can still use it to read the interpreter. WIP: the only remaining problem is that if an objfile has separate debug info, reading the separate debuginfo objfile has no information for linker namespace (yet).
Diffstat (limited to 'gdb/solib-target.c')
-rw-r--r--gdb/solib-target.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/gdb/solib-target.c b/gdb/solib-target.c
index f304431..2833f54 100644
--- a/gdb/solib-target.c
+++ b/gdb/solib-target.c
@@ -408,7 +408,7 @@ const solib_ops solib_target_so_ops =
solib_target_current_sos,
solib_target_open_symbol_file_object,
solib_target_in_dynsym_resolve_code,
- solib_bfd_open,
+ solib_bfd_open_from_solib,
nullptr,
nullptr,
nullptr,