aboutsummaryrefslogtreecommitdiff
path: root/gdb/solib-frv.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/solib-frv.c')
-rw-r--r--gdb/solib-frv.c97
1 files changed, 46 insertions, 51 deletions
diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c
index 39508fa..b48efe5 100644
--- a/gdb/solib-frv.c
+++ b/gdb/solib-frv.c
@@ -1,5 +1,5 @@
/* Handle FR-V (FDPIC) shared libraries for GDB, the GNU Debugger.
- Copyright (C) 2004-2024 Free Software Foundation, Inc.
+ Copyright (C) 2004-2025 Free Software Foundation, Inc.
This file is part of GDB.
@@ -18,15 +18,33 @@
#include "extract-store-integer.h"
-#include "gdbcore.h"
#include "solib.h"
-#include "solist.h"
#include "frv-tdep.h"
#include "objfiles.h"
#include "symtab.h"
#include "elf/frv.h"
#include "gdb_bfd.h"
#include "inferior.h"
+#include "solib-frv.h"
+
+/* solib_ops for FR-V systems. */
+
+struct frv_solib_ops : public 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 in_dynsym_resolve_code (CORE_ADDR pc) const override;
+};
+
+/* See solib-frv.h. */
+
+solib_ops_up
+make_frv_solib_ops ()
+{
+ return std::make_unique<frv_solib_ops> ();
+}
/* FR-V pointers are four bytes wide. */
enum { FRV_PTR_SIZE = 4 };
@@ -194,7 +212,7 @@ struct ext_link_map
ext_ptr l_next, l_prev; /* struct link_map *l_next, *l_prev; */
};
-/* Link map info to include in an allocated so_list entry. */
+/* Link map info to include in an allocated solib entry. */
struct lm_info_frv final : public lm_info
{
@@ -237,15 +255,6 @@ static void frv_relocate_main_executable (void);
static CORE_ADDR main_got (void);
static int enable_break2 (void);
-/* Implement the "open_symbol_file_object" solib_ops method. */
-
-static int
-open_symbol_file_object (int from_tty)
-{
- /* Unimplemented. */
- return 0;
-}
-
/* Cached value for lm_base(), below. */
static CORE_ADDR lm_base_cache = 0;
@@ -264,7 +273,6 @@ static CORE_ADDR
lm_base (void)
{
bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ());
- struct bound_minimal_symbol got_sym;
CORE_ADDR addr;
gdb_byte buf[FRV_PTR_SIZE];
@@ -280,8 +288,9 @@ lm_base (void)
if (lm_base_cache)
return lm_base_cache;
- got_sym = lookup_minimal_symbol ("_GLOBAL_OFFSET_TABLE_", NULL,
- current_program_space->symfile_object_file);
+ bound_minimal_symbol got_sym
+ = lookup_minimal_symbol (current_program_space, "_GLOBAL_OFFSET_TABLE_",
+ current_program_space->symfile_object_file);
if (got_sym.minsym == 0)
{
solib_debug_printf ("_GLOBAL_OFFSET_TABLE_ not found.");
@@ -303,15 +312,12 @@ lm_base (void)
return lm_base_cache;
}
-
-/* Implement the "current_sos" solib_ops method. */
-
-static intrusive_list<solib>
-frv_current_sos ()
+owning_intrusive_list<solib>
+frv_solib_ops::current_sos () const
{
bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ());
CORE_ADDR lm_addr, mgot;
- intrusive_list<solib> sos;
+ owning_intrusive_list<solib> sos;
/* Make sure that the main executable has been relocated. This is
required in order to find the address of the global offset table,
@@ -377,11 +383,13 @@ frv_current_sos ()
break;
}
- solib *sop = new solib;
+ auto &sop = sos.emplace_back (*this);
auto li = std::make_unique<lm_info_frv> ();
li->map = loadmap;
li->got_value = got_addr;
li->lm_addr = lm_addr;
+ sop.lm_info = std::move (li);
+
/* Fetch the name. */
addr = extract_unsigned_integer (lm_buf.l_name,
sizeof (lm_buf.l_name),
@@ -395,11 +403,9 @@ frv_current_sos ()
warning (_("Can't read pathname for link map entry."));
else
{
- sop->so_name = name_buf.get ();
- sop->so_original_name = sop->so_name;
+ sop.name = name_buf.get ();
+ sop.original_name = sop.name;
}
-
- sos.push_back (*sop);
}
else
{
@@ -424,8 +430,8 @@ static CORE_ADDR interp_text_sect_high;
static CORE_ADDR interp_plt_sect_low;
static CORE_ADDR interp_plt_sect_high;
-static int
-frv_in_dynsym_resolve_code (CORE_ADDR pc)
+bool
+frv_solib_ops::in_dynsym_resolve_code (CORE_ADDR pc) const
{
return ((pc >= interp_text_sect_low && pc < interp_text_sect_high)
|| (pc >= interp_plt_sect_low && pc < interp_plt_sect_high)
@@ -687,7 +693,7 @@ enable_break (void)
return 0;
}
- if (!entry_point_address_query (&entry_point))
+ if (!entry_point_address_query (current_program_space, &entry_point))
{
solib_debug_printf ("Symbol file has no entry point.");
return 0;
@@ -786,8 +792,8 @@ frv_relocate_main_executable (void)
to be relocated. The shared library breakpoints also need to be
enabled. */
-static void
-frv_solib_create_inferior_hook (int from_tty)
+void
+frv_solib_ops::create_inferior_hook (int from_tty) const
{
/* Relocate main executable. */
frv_relocate_main_executable ();
@@ -800,8 +806,8 @@ frv_solib_create_inferior_hook (int from_tty)
}
}
-static void
-frv_clear_solib (program_space *pspace)
+void
+frv_solib_ops::clear_solib (program_space *pspace) const
{
lm_base_cache = 0;
enable_break2_done = 0;
@@ -811,8 +817,9 @@ frv_clear_solib (program_space *pspace)
main_executable_lm_info = NULL;
}
-static void
-frv_relocate_section_addresses (solib &so, target_section *sec)
+void
+frv_solib_ops::relocate_section_addresses (solib &so,
+ target_section *sec) const
{
int seg;
auto *li = gdb::checked_static_cast<lm_info_frv *> (so.lm_info.get ());
@@ -838,10 +845,10 @@ frv_relocate_section_addresses (solib &so, target_section *sec)
static CORE_ADDR
main_got (void)
{
- struct bound_minimal_symbol got_sym;
-
objfile *objf = current_program_space->symfile_object_file;
- got_sym = lookup_minimal_symbol ("_GLOBAL_OFFSET_TABLE_", NULL, objf);
+ bound_minimal_symbol got_sym
+ = lookup_minimal_symbol (current_program_space, "_GLOBAL_OFFSET_TABLE_",
+ objf);
if (got_sym.minsym == 0)
return 0;
@@ -1073,15 +1080,3 @@ frv_fetch_objfile_link_map (struct objfile *objfile)
/* Not found! */
return 0;
}
-
-const solib_ops frv_so_ops =
-{
- frv_relocate_section_addresses,
- nullptr,
- frv_clear_solib,
- frv_solib_create_inferior_hook,
- frv_current_sos,
- open_symbol_file_object,
- frv_in_dynsym_resolve_code,
- solib_bfd_open,
-};