gdb: make gdb_bfd cache aware of linker namespaces
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).