aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2022-08-08 11:00:50 -0600
committerTom Tromey <tromey@adacore.com>2022-09-20 12:25:19 -0600
commit549dfc51b07c0c749ebde15a3fa855ab496ea18a (patch)
tree19524424c91615492c20104d1e6b880e4afa5fc4
parent9e468e953cd2f605a3f51d6ef6532e46b8fdd7b4 (diff)
downloadgdb-549dfc51b07c0c749ebde15a3fa855ab496ea18a.zip
gdb-549dfc51b07c0c749ebde15a3fa855ab496ea18a.tar.gz
gdb-549dfc51b07c0c749ebde15a3fa855ab496ea18a.tar.bz2
Constify some target_so_ops instances
This changes some target_so_ops instances to be const. This makes their use a little more obvious (they can't be mutated) and also allows for the removal of some initialization code.
-rw-r--r--gdb/frv-tdep.h2
-rw-r--r--gdb/solib-aix.c26
-rw-r--r--gdb/solib-aix.h2
-rw-r--r--gdb/solib-darwin.c26
-rw-r--r--gdb/solib-darwin.h2
-rw-r--r--gdb/solib-dsbt.c23
-rw-r--r--gdb/solib-dsbt.h28
-rw-r--r--gdb/solib-frv.c22
-rw-r--r--gdb/solib-svr4.c34
-rw-r--r--gdb/solib-svr4.h2
-rw-r--r--gdb/solib-target.c29
-rw-r--r--gdb/solib-target.h2
-rw-r--r--gdb/tic6x-linux-tdep.c2
13 files changed, 112 insertions, 88 deletions
diff --git a/gdb/frv-tdep.h b/gdb/frv-tdep.h
index 64052b8..037d81a 100644
--- a/gdb/frv-tdep.h
+++ b/gdb/frv-tdep.h
@@ -119,6 +119,6 @@ CORE_ADDR frv_fdpic_find_canonical_descriptor (CORE_ADDR entry_point);
CORE_ADDR frv_fetch_objfile_link_map (struct objfile *objfile);
struct target_so_ops;
-extern struct target_so_ops frv_so_ops;
+extern const struct target_so_ops frv_so_ops;
#endif /* FRV_TDEP_H */
diff --git a/gdb/solib-aix.c b/gdb/solib-aix.c
index 948bd0f..f483f54 100644
--- a/gdb/solib-aix.c
+++ b/gdb/solib-aix.c
@@ -718,25 +718,23 @@ show_solib_aix_debug (struct ui_file *file, int from_tty,
}
/* The target_so_ops for AIX targets. */
-struct target_so_ops solib_aix_so_ops;
+const struct target_so_ops solib_aix_so_ops =
+{
+ solib_aix_relocate_section_addresses,
+ solib_aix_free_so,
+ nullptr,
+ solib_aix_clear_solib,
+ solib_aix_solib_create_inferior_hook,
+ solib_aix_current_sos,
+ solib_aix_open_symbol_file_object,
+ solib_aix_in_dynsym_resolve_code,
+ solib_aix_bfd_open,
+};
void _initialize_solib_aix ();
void
_initialize_solib_aix ()
{
- solib_aix_so_ops.relocate_section_addresses
- = solib_aix_relocate_section_addresses;
- solib_aix_so_ops.free_so = solib_aix_free_so;
- solib_aix_so_ops.clear_solib = solib_aix_clear_solib;
- solib_aix_so_ops.solib_create_inferior_hook
- = solib_aix_solib_create_inferior_hook;
- solib_aix_so_ops.current_sos = solib_aix_current_sos;
- solib_aix_so_ops.open_symbol_file_object
- = solib_aix_open_symbol_file_object;
- solib_aix_so_ops.in_dynsym_resolve_code
- = solib_aix_in_dynsym_resolve_code;
- solib_aix_so_ops.bfd_open = solib_aix_bfd_open;
-
gdb::observers::normal_stop.attach (solib_aix_normal_stop_observer,
"solib-aix");
diff --git a/gdb/solib-aix.h b/gdb/solib-aix.h
index edb0b5a..24415f6 100644
--- a/gdb/solib-aix.h
+++ b/gdb/solib-aix.h
@@ -19,7 +19,7 @@
#define SOLIB_AIX_H
struct target_so_ops;
-extern struct target_so_ops solib_aix_so_ops;
+extern const struct target_so_ops solib_aix_so_ops;
extern CORE_ADDR solib_aix_get_toc_value (CORE_ADDR pc);
diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c
index e61ec0d..4eca080 100644
--- a/gdb/solib-darwin.c
+++ b/gdb/solib-darwin.c
@@ -33,6 +33,7 @@
#include "solist.h"
#include "solib.h"
#include "solib-svr4.h"
+#include "solib-darwin.h"
#include "bfd-target.h"
#include "elf-bfd.h"
@@ -674,18 +675,15 @@ darwin_bfd_open (const char *pathname)
return res;
}
-struct target_so_ops darwin_so_ops;
-
-void _initialize_darwin_solib ();
-void
-_initialize_darwin_solib ()
+const struct target_so_ops darwin_so_ops =
{
- darwin_so_ops.relocate_section_addresses = darwin_relocate_section_addresses;
- darwin_so_ops.free_so = darwin_free_so;
- darwin_so_ops.clear_solib = darwin_clear_solib;
- darwin_so_ops.solib_create_inferior_hook = darwin_solib_create_inferior_hook;
- darwin_so_ops.current_sos = darwin_current_sos;
- darwin_so_ops.open_symbol_file_object = open_symbol_file_object;
- darwin_so_ops.in_dynsym_resolve_code = darwin_in_dynsym_resolve_code;
- darwin_so_ops.bfd_open = darwin_bfd_open;
-}
+ darwin_relocate_section_addresses,
+ darwin_free_so,
+ nullptr,
+ darwin_clear_solib,
+ darwin_solib_create_inferior_hook,
+ darwin_current_sos,
+ open_symbol_file_object,
+ darwin_in_dynsym_resolve_code,
+ darwin_bfd_open,
+};
diff --git a/gdb/solib-darwin.h b/gdb/solib-darwin.h
index e920e7a..32e7c8d 100644
--- a/gdb/solib-darwin.h
+++ b/gdb/solib-darwin.h
@@ -23,6 +23,6 @@
struct objfile;
struct target_so_ops;
-extern struct target_so_ops darwin_so_ops;
+extern const struct target_so_ops darwin_so_ops;
#endif /* solib-darwin.h */
diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c
index b4cd163..b866a0b 100644
--- a/gdb/solib-dsbt.c
+++ b/gdb/solib-dsbt.c
@@ -29,6 +29,7 @@
#include "gdbcmd.h"
#include "elf-bfd.h"
#include "gdb_bfd.h"
+#include "solib-dsbt.h"
#define GOT_MODULE_OFFSET 4
@@ -924,21 +925,23 @@ show_dsbt_debug (struct ui_file *file, int from_tty,
gdb_printf (file, _("solib-dsbt debugging is %s.\n"), value);
}
-struct target_so_ops dsbt_so_ops;
+const struct target_so_ops dsbt_so_ops =
+{
+ dsbt_relocate_section_addresses,
+ dsbt_free_so,
+ nullptr,
+ dsbt_clear_solib,
+ dsbt_solib_create_inferior_hook,
+ dsbt_current_sos,
+ open_symbol_file_object,
+ dsbt_in_dynsym_resolve_code,
+ solib_bfd_open,
+};
void _initialize_dsbt_solib ();
void
_initialize_dsbt_solib ()
{
- dsbt_so_ops.relocate_section_addresses = dsbt_relocate_section_addresses;
- dsbt_so_ops.free_so = dsbt_free_so;
- dsbt_so_ops.clear_solib = dsbt_clear_solib;
- dsbt_so_ops.solib_create_inferior_hook = dsbt_solib_create_inferior_hook;
- dsbt_so_ops.current_sos = dsbt_current_sos;
- dsbt_so_ops.open_symbol_file_object = open_symbol_file_object;
- dsbt_so_ops.in_dynsym_resolve_code = dsbt_in_dynsym_resolve_code;
- dsbt_so_ops.bfd_open = solib_bfd_open;
-
/* Debug this file's internals. */
add_setshow_zuinteger_cmd ("solib-dsbt", class_maintenance,
&solib_dsbt_debug, _("\
diff --git a/gdb/solib-dsbt.h b/gdb/solib-dsbt.h
new file mode 100644
index 0000000..98c0a31
--- /dev/null
+++ b/gdb/solib-dsbt.h
@@ -0,0 +1,28 @@
+/* Handle shared libraries for GDB, the GNU Debugger.
+
+ Copyright (C) 2022 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef SOLIB_DSBT_H
+#define SOLIB_DSBT_H
+
+struct objfile;
+struct target_so_ops;
+
+extern const struct target_so_ops dsbt_so_ops;
+
+#endif /* solib-dsbt.h */
diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c
index df86b14..6ca303c 100644
--- a/gdb/solib-frv.c
+++ b/gdb/solib-frv.c
@@ -1129,21 +1129,23 @@ frv_fetch_objfile_link_map (struct objfile *objfile)
return 0;
}
-struct target_so_ops frv_so_ops;
+const struct target_so_ops frv_so_ops =
+{
+ frv_relocate_section_addresses,
+ frv_free_so,
+ nullptr,
+ frv_clear_solib,
+ frv_solib_create_inferior_hook,
+ frv_current_sos,
+ open_symbol_file_object,
+ frv_in_dynsym_resolve_code,
+ solib_bfd_open,
+};
void _initialize_frv_solib ();
void
_initialize_frv_solib ()
{
- frv_so_ops.relocate_section_addresses = frv_relocate_section_addresses;
- frv_so_ops.free_so = frv_free_so;
- frv_so_ops.clear_solib = frv_clear_solib;
- frv_so_ops.solib_create_inferior_hook = frv_solib_create_inferior_hook;
- frv_so_ops.current_sos = frv_current_sos;
- frv_so_ops.open_symbol_file_object = open_symbol_file_object;
- frv_so_ops.in_dynsym_resolve_code = frv_in_dynsym_resolve_code;
- frv_so_ops.bfd_open = solib_bfd_open;
-
/* Debug this file's internals. */
add_setshow_zuinteger_cmd ("solib-frv", class_maintenance,
&solib_frv_debug, _("\
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 893da86..bab76e2 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -3121,8 +3121,6 @@ svr4_lp64_fetch_link_map_offsets (void)
}
-struct target_so_ops svr4_so_ops;
-
/* Search order for ELF DSOs linked with -Bsymbolic. Those DSOs have a
different rule for symbol lookup. The lookup begins here in the DSO, not in
the main executable. */
@@ -3163,24 +3161,28 @@ svr4_iterate_over_objfiles_in_search_order
}
}
+const struct target_so_ops svr4_so_ops =
+{
+ svr4_relocate_section_addresses,
+ svr4_free_so,
+ svr4_clear_so,
+ svr4_clear_solib,
+ svr4_solib_create_inferior_hook,
+ svr4_current_sos,
+ open_symbol_file_object,
+ svr4_in_dynsym_resolve_code,
+ solib_bfd_open,
+ nullptr,
+ svr4_same,
+ svr4_keep_data_in_core,
+ svr4_update_solib_event_breakpoints,
+ svr4_handle_solib_event,
+};
+
void _initialize_svr4_solib ();
void
_initialize_svr4_solib ()
{
- svr4_so_ops.relocate_section_addresses = svr4_relocate_section_addresses;
- svr4_so_ops.free_so = svr4_free_so;
- svr4_so_ops.clear_so = svr4_clear_so;
- svr4_so_ops.clear_solib = svr4_clear_solib;
- svr4_so_ops.solib_create_inferior_hook = svr4_solib_create_inferior_hook;
- svr4_so_ops.current_sos = svr4_current_sos;
- svr4_so_ops.open_symbol_file_object = open_symbol_file_object;
- svr4_so_ops.in_dynsym_resolve_code = svr4_in_dynsym_resolve_code;
- svr4_so_ops.bfd_open = solib_bfd_open;
- svr4_so_ops.same = svr4_same;
- svr4_so_ops.keep_data_in_core = svr4_keep_data_in_core;
- svr4_so_ops.update_breakpoints = svr4_update_solib_event_breakpoints;
- svr4_so_ops.handle_event = svr4_handle_solib_event;
-
gdb::observers::free_objfile.attach (svr4_free_objfile_observer,
"solib-svr4");
}
diff --git a/gdb/solib-svr4.h b/gdb/solib-svr4.h
index 8b49685..4a68802 100644
--- a/gdb/solib-svr4.h
+++ b/gdb/solib-svr4.h
@@ -25,7 +25,7 @@
struct objfile;
struct target_so_ops;
-extern struct target_so_ops svr4_so_ops;
+extern const struct target_so_ops svr4_so_ops;
/* Link map info to include in an allocated so_list entry. */
diff --git a/gdb/solib-target.c b/gdb/solib-target.c
index 8def640..6eb0d17 100644
--- a/gdb/solib-target.c
+++ b/gdb/solib-target.c
@@ -435,22 +435,15 @@ solib_target_in_dynsym_resolve_code (CORE_ADDR pc)
return in_plt_section (pc);
}
-struct target_so_ops solib_target_so_ops;
-
-void _initialize_solib_target ();
-void
-_initialize_solib_target ()
+const struct target_so_ops solib_target_so_ops =
{
- solib_target_so_ops.relocate_section_addresses
- = solib_target_relocate_section_addresses;
- solib_target_so_ops.free_so = solib_target_free_so;
- solib_target_so_ops.clear_solib = solib_target_clear_solib;
- solib_target_so_ops.solib_create_inferior_hook
- = solib_target_solib_create_inferior_hook;
- solib_target_so_ops.current_sos = solib_target_current_sos;
- solib_target_so_ops.open_symbol_file_object
- = solib_target_open_symbol_file_object;
- solib_target_so_ops.in_dynsym_resolve_code
- = solib_target_in_dynsym_resolve_code;
- solib_target_so_ops.bfd_open = solib_bfd_open;
-}
+ solib_target_relocate_section_addresses,
+ solib_target_free_so,
+ nullptr,
+ solib_target_clear_solib,
+ solib_target_solib_create_inferior_hook,
+ solib_target_current_sos,
+ solib_target_open_symbol_file_object,
+ solib_target_in_dynsym_resolve_code,
+ solib_bfd_open,
+};
diff --git a/gdb/solib-target.h b/gdb/solib-target.h
index b202844..016a5fe 100644
--- a/gdb/solib-target.h
+++ b/gdb/solib-target.h
@@ -21,6 +21,6 @@
#define SOLIB_TARGET_H
struct target_so_ops;
-extern struct target_so_ops solib_target_so_ops;
+extern const struct target_so_ops solib_target_so_ops;
#endif /* solib-target.h */
diff --git a/gdb/tic6x-linux-tdep.c b/gdb/tic6x-linux-tdep.c
index b99cfc0..855eb30 100644
--- a/gdb/tic6x-linux-tdep.c
+++ b/gdb/tic6x-linux-tdep.c
@@ -27,6 +27,7 @@
#include "elf-bfd.h"
#include "elf/tic6x.h"
#include "gdbarch.h"
+#include "solib-dsbt.h"
/* The offset from rt_sigframe pointer to SP register. */
#define TIC6X_SP_RT_SIGFRAME 8
@@ -161,7 +162,6 @@ tic6x_linux_syscall_next_pc (struct frame_info *frame)
}
-extern struct target_so_ops dsbt_so_ops;
static void
tic6x_uclinux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
{