The gdbarch registry patch introduced a regression that could cause a
crash when opening files in gdb. The bug is that, previously, the
solib ops would default to current_target_so_ops; but the patch
changed this code to default to nullptr. This patch fixes the bug by
reintroducing the earlier behavior. This is PR gdb/29449.
I managed to reproduce the bug with a riscv-elf build and then
verified that this fixes the problem.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29449
static const struct target_so_ops *
solib_ops (struct gdbarch *gdbarch)
{
- return solib_data.get (gdbarch);
+ const struct target_so_ops *result = solib_data.get (gdbarch);
+ if (result == nullptr)
+ {
+ result = current_target_so_ops;
+ set_solib_ops (gdbarch, current_target_so_ops);
+ }
+ return result;
}
/* Set the solib operations for GDBARCH to NEW_OPS. */