]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Remove section_offsets typedef
authorTom Tromey <tom@tromey.com>
Wed, 19 Nov 2025 18:09:35 +0000 (11:09 -0700)
committerTom Tromey <tom@tromey.com>
Wed, 19 Nov 2025 22:43:30 +0000 (15:43 -0700)
This patch removes the section_offsets typedef, in favor of using
either std::vector or gdb::array_view as appropriate.

v2: preserve const-ness when creating views

Regression tested on x86-64 Fedora 40.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
16 files changed:
gdb/block.c
gdb/block.h
gdb/defs.h
gdb/mdebugread.c
gdb/objfiles.c
gdb/objfiles.h
gdb/remote.c
gdb/solib-aix.c
gdb/solib-dsbt.c
gdb/solib-frv.c
gdb/solib-svr4.c
gdb/solib-target.c
gdb/symfile.c
gdb/symfile.h
gdb/symtab.c
gdb/symtab.h

index 4d7f2124f39b06b2680d9edb47fb51c9187e2865..98088aa38075e6574ef412b6178d7954a55d5d01 100644 (file)
@@ -369,7 +369,8 @@ block::static_link () const
 /* See block.h.  */
 
 void
-block::relocate (struct objfile *objfile, const section_offsets &offsets)
+block::relocate (struct objfile *objfile,
+                gdb::array_view<const CORE_ADDR> offsets)
 {
   int block_line_section = SECT_OFF_TEXT (objfile);
 
@@ -889,7 +890,7 @@ blockvector::~blockvector ()
 
 void
 blockvector::relocate (struct objfile *objfile,
-                      const section_offsets &offsets)
+                      gdb::array_view<const CORE_ADDR> offsets)
 {
   int block_line_section = SECT_OFF_TEXT (objfile);
 
index ceff97d79e303c45f08219dcaac0459eb99a31a9..b199663273cee0b7ea7649be1de4db71b3051531 100644 (file)
@@ -318,7 +318,8 @@ struct block : public allocate_on_obstack<block>
   /* Relocate this block and all contained blocks.  OBJFILE is the
      objfile holding this block, and OFFSETS is the relocation offsets
      to use.  */
-  void relocate (struct objfile *objfile, const section_offsets &offsets);
+  void relocate (struct objfile *objfile,
+                gdb::array_view<const CORE_ADDR> offsets);
 
 private:
 
@@ -517,7 +518,8 @@ struct blockvector
   /* Relocate this blockvector and all contained blocks.  OBJFILE is
      the objfile holding this blockvector, and OFFSETS is the
      relocation offsets to use.  */
-  void relocate (struct objfile *objfile, const section_offsets &offsets);
+  void relocate (struct objfile *objfile,
+                gdb::array_view<const CORE_ADDR> offsets);
 
 private:
   /* An address map mapping addresses to blocks in this blockvector.
index bb047d9cb4ce3456d36768b839565fe3e60c9f88..8bf9d3dcbda875e56da1c1b09ca4a18582f92f85 100644 (file)
@@ -411,8 +411,4 @@ DEF_ENUM_FLAGS_TYPE (enum user_selected_what_flag, user_selected_what);
   extern void _initialize_ ## NAME (); \
   void _initialize_ ## NAME ()
 
-/* How to relocate the symbols from each section in a symbol file.
-   This is indexed by section numbers.  */
-typedef std::vector<CORE_ADDR> section_offsets;
-
 #endif /* GDB_DEFS_H */
index 10c4133e6c2378f7f4b6f0ef27450c6620f9eb5f..e7c526a84ed4e61f932dbf1b60875c1759c60342 100644 (file)
@@ -640,7 +640,8 @@ add_data_symbol (SYMR *sh, union aux_ext *ax, int bigend,
 
 static int
 parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
-             const section_offsets &section_offsets, struct objfile *objfile)
+             gdb::array_view<const CORE_ADDR> section_offsets,
+             struct objfile *objfile)
 {
   struct gdbarch *gdbarch = objfile->arch ();
   const bfd_size_type external_sym_size = debug_swap->external_sym_size;
@@ -2125,7 +2126,8 @@ parse_procedure (PDR *pr, struct compunit_symtab *search_symtab,
    This routine clobbers top_stack->cur_block and ->cur_st.  */
 
 static void
-parse_external (EXTR *es, int bigend, const section_offsets &section_offsets,
+parse_external (EXTR *es, int bigend,
+               gdb::array_view<const CORE_ADDR> section_offsets,
                struct objfile *objfile)
 {
   union aux_ext *ax;
@@ -3193,7 +3195,7 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile)
   FDR *fh;
   struct linetable *lines;
   CORE_ADDR lowest_pdr_addr = 0;
-  const section_offsets &section_offsets = objfile->section_offsets;
+  gdb::array_view<const CORE_ADDR> section_offsets (objfile->section_offsets);
 
   if (pst->readin)
     return;
index 658b01e5955c3d20ec64e7d5bfb0bd6cff12832a..0d166ceec4c3c3ddd4d8326a04a06926feb40963 100644 (file)
@@ -514,9 +514,9 @@ objfile::~objfile ()
 
 static int
 objfile_relocate1 (struct objfile *objfile,
-                  const section_offsets &new_offsets)
+                  gdb::array_view<const CORE_ADDR> new_offsets)
 {
-  section_offsets delta (objfile->section_offsets.size ());
+  std::vector<CORE_ADDR> delta (objfile->section_offsets.size ());
 
   int something_changed = 0;
 
@@ -567,7 +567,7 @@ objfile_relocate1 (struct objfile *objfile,
 
 void
 objfile_relocate (struct objfile *objfile,
-                 const section_offsets &new_offsets)
+                 gdb::array_view<const CORE_ADDR> new_offsets)
 {
   int changed = 0;
 
@@ -588,7 +588,7 @@ objfile_relocate (struct objfile *objfile,
 
       gdb_assert (debug_objfile->section_offsets.size ()
                  == gdb_bfd_count_sections (debug_objfile->obfd.get ()));
-      section_offsets new_debug_offsets
+      std::vector<CORE_ADDR> new_debug_offsets
        (debug_objfile->section_offsets.size ());
       relative_addr_info_to_section_offsets (new_debug_offsets, objfile_addrs);
 
@@ -607,7 +607,7 @@ objfile_relocate (struct objfile *objfile,
 static int
 objfile_rebase1 (struct objfile *objfile, CORE_ADDR slide)
 {
-  section_offsets new_offsets (objfile->section_offsets.size (), slide);
+  std::vector<CORE_ADDR> new_offsets (objfile->section_offsets.size (), slide);
   return objfile_relocate1 (objfile, new_offsets);
 }
 
index 31651c4ee57643acf902f4ac18d17ef431c14ca3..0dd3fafac0377a2dc4313fba0c6bb06d84b0627e 100644 (file)
@@ -772,7 +772,7 @@ public:
      minimal symbols) which have been read have been relocated by this
      much.  Symbols which are yet to be read need to be relocated by it.  */
 
-  ::section_offsets section_offsets;
+  std::vector<CORE_ADDR> section_offsets;
 
   /* Indexes in the section_offsets array.  These are initialized by the
      *_symfile_offsets() family of functions (som_symfile_offsets,
@@ -918,7 +918,8 @@ extern void build_objfile_section_table (struct objfile *);
 
 extern void free_objfile_separate_debug (struct objfile *);
 
-extern void objfile_relocate (struct objfile *, const section_offsets &);
+extern void objfile_relocate (struct objfile *,
+                             gdb::array_view<const CORE_ADDR>);
 extern void objfile_rebase (struct objfile *, CORE_ADDR);
 
 /* Return true if any objfile of PSPACE has partial symbols.  */
index da44b22a259bd294ad96f2315e4de22dd10801d0..fd80b6ddb59e3ce18ee7ff41692613ea7a810bca 100644 (file)
@@ -4930,7 +4930,7 @@ remote_target::get_offsets ()
     warning (_("Target reported unsupported offsets: %s"), buf);
 
   objfile *objf = current_program_space->symfile_object_file;
-  section_offsets offs = objf->section_offsets;
+  std::vector<CORE_ADDR> offs = objf->section_offsets;
 
   symfile_segment_data_up data = get_symfile_segment_data (objf->obfd.get ());
   do_segments = (data != NULL);
index 308ff80c38caf8ad3a95fcc844b8bb158eed0a48..5076d7e2f063135e73401a5866dd270dbd612106 100644 (file)
@@ -380,13 +380,13 @@ aix_solib_ops::relocate_section_addresses (solib &so,
 /* Compute and return the OBJFILE's section_offset array, using
    the associated loader info (INFO).  */
 
-static section_offsets
+static std::vector<CORE_ADDR>
 solib_aix_get_section_offsets (struct objfile *objfile,
                               lm_info_aix *info)
 {
   bfd *abfd = objfile->obfd.get ();
 
-  section_offsets offsets (objfile->section_offsets.size ());
+  std::vector<CORE_ADDR> offsets (objfile->section_offsets.size ());
 
   /* .text */
 
@@ -451,8 +451,8 @@ aix_solib_ops::create_inferior_hook (int from_tty) const
   if (current_program_space->symfile_object_file != NULL)
     {
       objfile *objf = current_program_space->symfile_object_file;
-      section_offsets offsets = solib_aix_get_section_offsets (objf,
-                                                              &exec_info);
+      std::vector<CORE_ADDR> offsets
+       = solib_aix_get_section_offsets (objf, &exec_info);
 
       objfile_relocate (objf, offsets);
     }
index 883164eda0445ec9013a450578a6b865438e4ac7..23042b4158e9e17296c61404e2122896627ff192 100644 (file)
@@ -816,7 +816,7 @@ dsbt_relocate_main_executable (void)
   info->main_executable_lm_info = new lm_info_dsbt (ldm);
 
   objfile *objf = current_program_space->symfile_object_file;
-  section_offsets new_offsets (objf->section_offsets.size ());
+  std::vector<CORE_ADDR> new_offsets (objf->section_offsets.size ());
   changed = 0;
 
   for (obj_section &osect : objf->sections ())
index 1cb063f7673712bbe98427374674f3f83535aae1..9d36b0fd4edf5b0f5a22d4aee02ef755df82803e 100644 (file)
@@ -748,7 +748,7 @@ frv_relocate_main_executable (void)
   main_executable_lm_info = new lm_info_frv (ldm, 0, 0);
 
   objfile *objf = current_program_space->symfile_object_file;
-  section_offsets new_offsets (objf->section_offsets.size ());
+  std::vector<CORE_ADDR> new_offsets (objf->section_offsets.size ());
   changed = 0;
 
   for (obj_section &osect : objf->sections ())
index 2d15e7dfd8a5dc5c46e9fa0d1b4ca13287bc6751..7c4a8b274c4e8ccbc8567450f134b7cfc79dd4f6 100644 (file)
@@ -3291,8 +3291,8 @@ svr4_relocate_main_executable (void)
   objfile *objf = current_program_space->symfile_object_file;
   if (objf)
     {
-      section_offsets new_offsets (objf->section_offsets.size (),
-                                  displacement);
+      std::vector<CORE_ADDR> new_offsets (objf->section_offsets.size (),
+                                         displacement);
       objfile_relocate (objf, new_offsets);
     }
   else if (current_program_space->exec_bfd ())
index 2ae25a8f3aea06a94d4f6c767456303d3a3b0f4f..36654a76fc3ebe1480431b71d40cf2bb253941f2 100644 (file)
@@ -42,7 +42,7 @@ struct lm_info_target final : public lm_info
 
   /* The cached offsets for each section of this shared library,
      determined from SEGMENT_BASES, or SECTION_BASES.  */
-  section_offsets offsets;
+  std::vector<CORE_ADDR> offsets;
 };
 
 using lm_info_target_up = std::unique_ptr<lm_info_target>;
index d2c9bb1950dfe049a802ee11c39637475ea202ae..11388772ff5f4e8bb3fbce696296d47893f3901e 100644 (file)
@@ -327,7 +327,7 @@ init_objfile_sect_indices (struct objfile *objfile)
    the user did not provide an offset.  */
 
 static void
-place_section (bfd *abfd, asection *sect, section_offsets &offsets,
+place_section (bfd *abfd, asection *sect, std::vector<CORE_ADDR> &offsets,
               CORE_ADDR &lowest)
 {
   CORE_ADDR start_addr;
@@ -391,7 +391,7 @@ place_section (bfd *abfd, asection *sect, section_offsets &offsets,
    filled-in) by addr_info_make_relative into SECTION_OFFSETS.  */
 
 void
-relative_addr_info_to_section_offsets (section_offsets &section_offsets,
+relative_addr_info_to_section_offsets (std::vector<CORE_ADDR> &section_offsets,
                                       const section_addr_info &addrs)
 {
   int i;
@@ -636,7 +636,7 @@ default_symfile_offsets (struct objfile *objfile,
 
       if (cur_sec == NULL)
        {
-         section_offsets &offsets = objfile->section_offsets;
+         std::vector<CORE_ADDR> &offsets = objfile->section_offsets;
 
          /* Pick non-overlapping offsets for sections the user did not
             place explicitly.  */
@@ -2135,7 +2135,7 @@ set_objfile_default_section_offset (struct objfile *objf,
                                    CORE_ADDR offset)
 {
   /* Add OFFSET to all sections by default.  */
-  section_offsets offsets (objf->section_offsets.size (), offset);
+  std::vector<CORE_ADDR> offsets (objf->section_offsets.size (), offset);
 
   /* Create sorted lists of all sections in ADDRS as well as all
      sections in OBJF.  */
@@ -3643,7 +3643,7 @@ get_symfile_segment_data (bfd *abfd)
 int
 symfile_map_offsets_to_segments (bfd *abfd,
                                 const struct symfile_segment_data *data,
-                                section_offsets &offsets,
+                                std::vector<CORE_ADDR> &offsets,
                                 int num_segment_bases,
                                 const CORE_ADDR *segment_bases)
 {
index 418e0847df4c6dc3b63c12d85b57bb9e328589b5..cc2e8c94aff78fca84f9ad917211837414924677 100644 (file)
@@ -178,7 +178,7 @@ extern section_addr_info
   build_section_addr_info_from_objfile (const struct objfile *objfile);
 
 extern void relative_addr_info_to_section_offsets
-  (section_offsets &section_offsets, const section_addr_info &addrs);
+  (std::vector<CORE_ADDR> &section_offsets, const section_addr_info &addrs);
 
 extern void addr_info_make_relative (section_addr_info *addrs,
                                     bfd *abfd);
@@ -338,7 +338,7 @@ extern bfd_byte *symfile_relocate_debug_section (struct objfile *, asection *,
 
 extern int symfile_map_offsets_to_segments (bfd *,
                                            const struct symfile_segment_data *,
-                                           section_offsets &,
+                                           std::vector<CORE_ADDR> &,
                                            int, const CORE_ADDR *);
 symfile_segment_data_up get_symfile_segment_data (bfd *abfd);
 
index 0100bc4704c510b504c2f9a2df6dfe2fdffe3ef6..701aa5d0007042486f283b8e366265bfdc24288a 100644 (file)
@@ -6611,7 +6611,7 @@ symbol::value_block () const
 /* See symtab.h.  */
 
 void
-symbol::relocate (const section_offsets &delta)
+symbol::relocate (gdb::array_view<const CORE_ADDR> delta)
 {
   if ((loc_class () == LOC_LABEL || loc_class () == LOC_STATIC)
       && section_index () >= 0)
index 708eaf2c329cf8b45d986a3e042131acbd246ae3..33cf0a6c229f4d24dfca2d68da38a0959569eebb 100644 (file)
@@ -1460,7 +1460,7 @@ struct symbol : public general_symbol_info, public allocate_on_obstack<symbol>
 
   /* Relocate this symbol.  OFFSETS is the relocation offsets to use.  */
 
-  void relocate (const section_offsets &offsets);
+  void relocate (gdb::array_view<const CORE_ADDR> offsets);
 
   /* Data type of value */