[PATCH 5/8] gdb: Update Haiku support for 17.x

Jérôme Duval
2026-03-12T17:27:11Z

---
gdb/amd64-haiku-nat.c | 4 +-
gdb/amd64-haiku-tdep.c | 4 +-
gdb/haiku-nat.c | 4 +-
gdb/haiku-tdep.c | 2 +-
gdb/i386-haiku-nat.c | 4 +-
gdb/i386-haiku-tdep.c | 4 +-
gdb/solib-haiku.c | 96 +++++++++++++++++++++++-------------------
gdb/solib-haiku.h | 6 ++-
8 files changed, 62 insertions(+), 62 deletions(-)

diff --git a/gdb/amd64-haiku-nat.c b/gdb/amd64-haiku-nat.c
index e622e660..6ce9fc7e 100644
--- a/gdb/amd64-haiku-nat.c
+++ b/gdb/amd64-haiku-nat.c
@@ -143,9 +143,7 @@ amd64_haiku_nat_target::store_registers (struct regcache *regcache, int regno)

static amd64_haiku_nat_target the_amd64_haiku_nat_target;

-void _initialize_amd64_haiku_nat ();
-void
-_initialize_amd64_haiku_nat ()
+INIT_GDB_FILE (amd64_haiku_nat)
{
haiku_target = &the_amd64_haiku_nat_target;

diff --git a/gdb/amd64-haiku-tdep.c b/gdb/amd64-haiku-tdep.c
index 086e6318..476d6db9 100644
--- a/gdb/amd64-haiku-tdep.c
+++ b/gdb/amd64-haiku-tdep.c
@@ -132,9 +132,7 @@ amd64_haiku_osabi_sniffer (bfd *abfd)
return GDB_OSABI_HAIKU;
}

-void _initialize_amd64_haiku_tdep ();
-void
-_initialize_amd64_haiku_tdep ()
+INIT_GDB_FILE (amd64_haiku_tdep)
{
gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_elf_flavour,
amd64_haiku_osabi_sniffer);
diff --git a/gdb/haiku-nat.c b/gdb/haiku-nat.c
index c1d768c9..4dcaf236 100644
--- a/gdb/haiku-nat.c
+++ b/gdb/haiku-nat.c
@@ -733,9 +733,7 @@ is_catching_syscalls_for (ptid_t ptid)

/* Initialization. */

-void _initialize_haiku_nat ();
-void
-_initialize_haiku_nat ()
+INIT_GDB_FILE (haiku_nat)
{
/* We cannot do this in target_op's own callbacks, since they are called too
early after attaching or an exec event. At that point, symfile_object_file
diff --git a/gdb/haiku-tdep.c b/gdb/haiku-tdep.c
index 3b866a58..f0fd1d2f 100644
--- a/gdb/haiku-tdep.c
+++ b/gdb/haiku-tdep.c
@@ -32,7 +32,7 @@
void
haiku_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
{
- set_gdbarch_so_ops (gdbarch, &haiku_so_ops);
+ set_gdbarch_make_solib_ops (gdbarch, make_haiku_solib_ops);
}

/* See haiku-tdep.h. */
diff --git a/gdb/i386-haiku-nat.c b/gdb/i386-haiku-nat.c
index b41fcca1..7f00e54b 100644
--- a/gdb/i386-haiku-nat.c
+++ b/gdb/i386-haiku-nat.c
@@ -29,9 +29,7 @@ struct i386_haiku_nat_target final : public haiku_nat_target

static i386_haiku_nat_target the_i386_haiku_nat_target;

-void _initialize_i386_haiku_nat ();
-void
-_initialize_i386_haiku_nat ()
+INIT_GDB_FILE (i386_haiku_nat)
{
haiku_target = &the_i386_haiku_nat_target;

diff --git a/gdb/i386-haiku-tdep.c b/gdb/i386-haiku-tdep.c
index fd8011f7..38ddefbb 100644
--- a/gdb/i386-haiku-tdep.c
+++ b/gdb/i386-haiku-tdep.c
@@ -49,9 +49,7 @@ i386_haiku_osabi_sniffer (bfd *abfd)
return GDB_OSABI_HAIKU;
}

-void _initialize_i386_haiku_tdep ();
-void
-_initialize_i386_haiku_tdep ()
+INIT_GDB_FILE (i386_haiku_tdep)
{
gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_elf_flavour,
i386_haiku_osabi_sniffer);
diff --git a/gdb/solib-haiku.c b/gdb/solib-haiku.c
index 0ec56b5c..588bbc0f 100644
--- a/gdb/solib-haiku.c
+++ b/gdb/solib-haiku.c
@@ -23,9 +23,34 @@
#include "haiku-tdep.h"
#include "inferior.h"
#include "objfiles.h"
+#include "solib.h"
#include "solib-haiku.h"
#include "solib-target.h"
-#include "solist.h"
+
+
+/* solib_ops for Haiku systems. */
+
+struct haiku_solib_ops : public target_solib_ops
+{
+ using target_solib_ops::target_solib_ops;
+
+ void relocate_section_addresses (solib &so, target_section *) const override;
+ void clear_solib (program_space *pspace) const override;
+ void create_inferior_hook (int from_tty) const override;
+ owning_intrusive_list<solib> current_sos () const override;
+ bool open_symbol_file_object (int from_tty) const override;
+ bool in_dynsym_resolve_code (CORE_ADDR pc) const override;
+ gdb_bfd_ref_ptr bfd_open (const char *pathname) const override;
+};
+
+/* See solib-haiku.h. */
+
+solib_ops_up
+make_haiku_solib_ops (program_space *pspace)
+{
+ return std::make_unique<haiku_solib_ops> (pspace);
+}
+

/* For other targets, the solib implementation usually reads hints from the
dynamic linker in the active address space, which could be anything from a
@@ -37,10 +62,10 @@

This is basically a wrapper around solib-target.c. */

-static void
-haiku_relocate_section_addresses (solib &so, struct target_section *sec)
+void
+haiku_solib_ops::relocate_section_addresses (solib &so, struct target_section *sec) const
{
- if (so.so_name == "commpage")
+ if (so.name == "commpage")
{
CORE_ADDR commpage_address = haiku_get_commpage_address ();
sec->addr = commpage_address;
@@ -49,72 +74,55 @@ haiku_relocate_section_addresses (solib &so, struct target_section *sec)
so.addr_low = commpage_address;
so.addr_high = commpage_address + HAIKU_COMMPAGE_SIZE;
}
- else
+ /*else
{
- solib_target_so_ops.relocate_section_addresses (so, sec);
- }
+ solib_target_so_ops::relocate_section_addresses (so, sec);
+ }*/
}

-static void
+/*static void
haiku_clear_so (const solib &so)
{
if (solib_target_so_ops.clear_so != nullptr)
solib_target_so_ops.clear_so (so);
-}
+}*/

-static void
-haiku_clear_solib (program_space *pspace)
+void
+haiku_solib_ops::clear_solib (program_space *pspace) const
{
- if (solib_target_so_ops.clear_solib != nullptr)
- solib_target_so_ops.clear_solib (pspace);
+ target_solib_ops::clear_solib (pspace);
}

-static void
-haiku_solib_create_inferior_hook (int from_tty)
+void
+haiku_solib_ops::create_inferior_hook (int from_tty) const
{
- solib_target_so_ops.solib_create_inferior_hook (from_tty);
+ target_solib_ops::create_inferior_hook (from_tty);
}

-static owning_intrusive_list<solib>
-haiku_current_sos ()
+owning_intrusive_list<solib>
+haiku_solib_ops::current_sos () const
{
- return solib_target_so_ops.current_sos ();
+ return target_solib_ops::current_sos ();
}

-static int
-haiku_open_symbol_file_object (int from_tty)
+bool
+haiku_solib_ops::open_symbol_file_object (int from_tty) const
{
- return solib_target_so_ops.open_symbol_file_object (from_tty);
+ return target_solib_ops::open_symbol_file_object (from_tty);
}

-static int
-haiku_in_dynsym_resolve_code (CORE_ADDR pc)
+bool
+haiku_solib_ops::in_dynsym_resolve_code (CORE_ADDR pc) const
{
/* No dynamic resolving implemented in Haiku yet.
Return what the generic code has to say. */
- return solib_target_so_ops.in_dynsym_resolve_code (pc);
+ return target_solib_ops::in_dynsym_resolve_code (pc);
}

-static gdb_bfd_ref_ptr
-haiku_bfd_open (const char *pathname)
+gdb_bfd_ref_ptr
+haiku_solib_ops::bfd_open (const char *pathname) const
{
if (strcmp (pathname, "commpage") == 0)
return haiku_bfd_open_commpage ();
- return solib_target_so_ops.bfd_open (pathname);
+ return target_solib_ops::bfd_open (pathname);
}
-
-const struct solib_ops haiku_so_ops = {
- .relocate_section_addresses = haiku_relocate_section_addresses,
- .clear_so = haiku_clear_so,
- .clear_solib = haiku_clear_solib,
- .solib_create_inferior_hook = haiku_solib_create_inferior_hook,
- .current_sos = haiku_current_sos,
- .open_symbol_file_object = haiku_open_symbol_file_object,
- .in_dynsym_resolve_code = haiku_in_dynsym_resolve_code,
- .bfd_open = haiku_bfd_open,
- nullptr,
- nullptr,
- nullptr,
- nullptr,
- default_find_solib_addr,
-};
diff --git a/gdb/solib-haiku.h b/gdb/solib-haiku.h
index bd023f5b..092b2c5b 100644
--- a/gdb/solib-haiku.h
+++ b/gdb/solib-haiku.h
@@ -20,8 +20,10 @@
#ifndef GDB_SOLIB_HAIKU_H
#define GDB_SOLIB_HAIKU_H

-struct solib_ops;
+#include "solib.h"

-extern const struct solib_ops haiku_so_ops;
+/* Return a new solib_ops for Haiku systems. */
+
+extern solib_ops_up make_haiku_solib_ops (program_space *pspace);

#endif /* GDB_SOLIB_HAIKU_H */
--
2.43.0