Merge branch 'master' into merge-job
authorJenkins as Icarus Sparry <icarus.sparry@amd.com>
Thu, 9 Jan 2020 03:58:14 +0000 (03:58 +0000)
committerJenkins as Icarus Sparry <icarus.sparry@amd.com>
Thu, 9 Jan 2020 03:58:14 +0000 (03:58 +0000)
48 files changed:
bfd/ChangeLog
bfd/elflink.c
bfd/version.h
gas/ChangeLog
gas/config/obj-elf.c
gas/config/tc-z8k.c
gas/doc/as.texi
gas/testsuite/gas/elf/elf.exp
gas/testsuite/gas/elf/pr14891.d [new file with mode: 0644]
gas/testsuite/gas/elf/pr14891.l [new file with mode: 0644]
gas/testsuite/gas/elf/pr14891.s [new file with mode: 0644]
gdb/ChangeLog
gdb/amd64-windows-tdep.c
gdb/coff-pe-read.c
gdb/coffread.c
gdb/ctfread.c
gdb/dbxread.c
gdb/dtrace-probe.c
gdb/dwarf2-frame.c
gdb/dwarf2read.c
gdb/hppa-bsd-tdep.c
gdb/hppa-tdep.c
gdb/ia64-tdep.c
gdb/machoread.c
gdb/mdebugread.c
gdb/mipsread.c
gdb/objfiles.c
gdb/objfiles.h
gdb/psympriv.h
gdb/psymtab.c
gdb/remote.c
gdb/solib-aix.c
gdb/solib-dsbt.c
gdb/solib-frv.c
gdb/solib-svr4.c
gdb/solib-target.c
gdb/stabsread.h
gdb/stap-probe.c
gdb/symfile.c
gdb/symfile.h
gdb/symmisc.c
gdb/symtab.c
gdb/symtab.h
gdb/xcoffread.c
opcodes/ChangeLog
opcodes/z8k-dis.c
opcodes/z8k-opc.h
opcodes/z8kgen.c

index da9260b10539a39c0ce3009270a814bed1cec426..306f2e651243f809f1522bfb8158a8bfd209fdd5 100644 (file)
@@ -1,3 +1,9 @@
+2020-01-08  Alan Modra  <amodra@gmail.com>
+
+       PR 25351
+       * elflink.c (bfd_elf_final_link): Call _bfd_fix_excluded_sec_syms
+       after removing sections.
+
 2020-01-06  Jim Wilson  <jimw@sifive.com>
 
        PR 25205
index 2f804dbe6e51f550794b5c9815b45864746ce9e1..300be3f7437fdd8dc84709521789edb109d759af 100644 (file)
@@ -11820,6 +11820,7 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
   bfd_vma attr_size = 0;
   const char *std_attrs_section;
   struct elf_link_hash_table *htab = elf_hash_table (info);
+  bfd_boolean sections_removed;
 
   if (!is_elf_hash_table (htab))
     return FALSE;
@@ -11866,6 +11867,7 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
   /* The object attributes have been merged.  Remove the input
      sections from the link, and set the contents of the output
      section.  */
+  sections_removed = FALSE;
   std_attrs_section = get_elf_backend_data (abfd)->obj_attrs_section;
   for (o = abfd->sections; o != NULL; o = o->next)
     {
@@ -11905,8 +11907,11 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
          o->flags |= SEC_EXCLUDE;
          bfd_section_list_remove (abfd, o);
          abfd->section_count--;
+         sections_removed = TRUE;
        }
     }
+  if (sections_removed)
+    _bfd_fix_excluded_sec_syms (abfd, info);
 
   /* Count up the number of relocations we will output for each output
      section, so that we know the sizes of the reloc sections.  We
index 909f006072c49e73a965cc20979b2842c7d1ff2c..36097cbc34190601ad0825ef72c3065b43409a68 100644 (file)
@@ -16,7 +16,7 @@
 
    In releases, the date is not included in either version strings or
    sonames.  */
-#define BFD_VERSION_DATE 20200108
+#define BFD_VERSION_DATE 20200109
 #define BFD_VERSION @bfd_version@
 #define BFD_VERSION_STRING  @bfd_version_package@ @bfd_version_string@
 #define REPORT_BUGS_TO @report_bugs_to@
index 1c61732fab3b7e693b2bf737dd4195b5c1548d41..bed8292aff09b558a2df09cf9babc183aefd6240 100644 (file)
@@ -1,3 +1,26 @@
+2020-01-08  Nick Clifton  <nickc@redhat.com>
+
+       PR 25284
+       * doc/as.texi (Align): Document the fact that all arguments can be
+       omitted.
+       (Balign): Likewise.
+       (P2align): Likewise.
+
+2020-01-08  Nick Clifton  <nickc@redhat.com>
+
+       PR 14891
+       * config/obj-elf.c (obj_elf_section): Fail if the section name is
+       already defined as a different symbol type.
+       * testsuite/gas/elf/pr14891.s: New test source file.
+       * testsuite/gas/elf/pr14891.d: New test driver.
+       * testsuite/gas/elf/pr14891.s: New test expected error output.
+       * testsuite/gas/elf/elf.exp: Run the new test.
+
+2020-01-08  Alan Modra  <amodra@gmail.com>
+
+       * config/tc-z8k.c (md_begin): Make idx unsigned.
+       (get_specific): Likewise for this_index.
+
 2020-01-07  Claudiu Zissulescu  <claziss@synopsys.com>
 
        * onfig/tc-arc.c (parse_reloc_symbol): New function.
index ffc5508532f43a03e46509324a09fc45811b0eba..7cf921c051f62b4cd73b867e7d203cc3fec284fe 100644 (file)
@@ -1039,6 +1039,18 @@ obj_elf_section (int push)
   name = obj_elf_section_name ();
   if (name == NULL)
     return;
+
+  symbolS * sym;
+  if ((sym = symbol_find (name)) != NULL
+      && ! symbol_section_p (sym)
+      && S_IS_DEFINED (sym)
+      && ! S_IS_VOLATILE (sym)
+      && ! S_CAN_BE_REDEFINED (sym))
+    {
+      as_bad (_("section name '%s' already defined as another symbol"), name);
+      ignore_rest_of_line ();
+      return;
+    }
   type = SHT_NULL;
   attr = 0;
   gnu_attr = 0;
index d61a51f4546a1d48da5138b8c648b7e134322689..ea4ee3a6b1f3be1d4944621b67eaa74008434199 100644 (file)
@@ -143,7 +143,7 @@ void
 md_begin (void)
 {
   const opcode_entry_type *opcode;
-  int idx = -1;
+  unsigned int idx = -1u;
 
   opcode_hash_control = hash_new ();
 
@@ -861,7 +861,7 @@ get_specific (opcode_entry_type *opcode, op_type *operands)
   int found = 0;
   unsigned int noperands = opcode->noperands;
 
-  int this_index = opcode->idx;
+  unsigned int this_index = opcode->idx;
 
   while (this_index == opcode->idx && !found)
     {
index 15b33fdf63cea1cdacf0c62dfb5610f74376b1dd..ab661a73dbe4087a367aa8ec65e719f9670e39e8 100644 (file)
@@ -4404,11 +4404,11 @@ Some machine configurations provide additional directives.
 * ABORT (COFF)::                @code{.ABORT}
 @end ifset
 
-* Align::                       @code{.align @var{abs-expr} , @var{abs-expr}}
+* Align::                       @code{.align [@var{abs-expr}[, @var{abs-expr}[, @var{abs-expr}]]]}
 * Altmacro::                    @code{.altmacro}
 * Ascii::                       @code{.ascii "@var{string}"}@dots{}
 * Asciz::                       @code{.asciz "@var{string}"}@dots{}
-* Balign::                      @code{.balign @var{abs-expr} , @var{abs-expr}}
+* Balign::                      @code{.balign [@var{abs-expr}[, @var{abs-expr}]]}
 * Bundle directives::           @code{.bundle_align_mode @var{abs-expr}}, etc
 * Byte::                        @code{.byte @var{expressions}}
 * CFI directives::             @code{.cfi_startproc [simple]}, @code{.cfi_endproc}, etc.
@@ -4496,7 +4496,7 @@ Some machine configurations provide additional directives.
 * Octa::                        @code{.octa @var{bignums}}
 * Offset::                     @code{.offset @var{loc}}
 * Org::                         @code{.org @var{new-lc}, @var{fill}}
-* P2align::                     @code{.p2align @var{abs-expr}, @var{abs-expr}, @var{abs-expr}}
+* P2align::                     @code{.p2align [@var{abs-expr}[, @var{abs-expr}[, @var{abs-expr}]]]}
 @ifset ELF
 * PopSection::                  @code{.popsection}
 * Previous::                    @code{.previous}
@@ -4607,13 +4607,14 @@ synonym for @samp{.abort}.
 @end ifset
 
 @node Align
-@section @code{.align @var{abs-expr}, @var{abs-expr}, @var{abs-expr}}
+@section @code{.align [@var{abs-expr}[, @var{abs-expr}[, @var{abs-expr}]]]}
 
 @cindex padding the location counter
 @cindex @code{align} directive
 Pad the location counter (in the current subsection) to a particular storage
 boundary.  The first expression (which must be absolute) is the alignment
-required, as described below.
+required, as described below.  If this expression is omitted then a default
+value of 0 is used, effectively disabling alignment requirements.
 
 The second expression (also absolute) gives the fill value to be stored in the
 padding bytes.  It (and the comma) may be omitted.  If it is omitted, the
@@ -4705,7 +4706,7 @@ trailing zero byte) into consecutive addresses.
 a zero byte.  The ``z'' in @samp{.asciz} stands for ``zero''.
 
 @node Balign
-@section @code{.balign[wl] @var{abs-expr}, @var{abs-expr}, @var{abs-expr}}
+@section @code{.balign[wl] [@var{abs-expr}[, @var{abs-expr}[, @var{abs-expr}]]]}
 
 @cindex padding the location counter given number of bytes
 @cindex @code{balign} directive
@@ -4713,7 +4714,8 @@ Pad the location counter (in the current subsection) to a particular
 storage boundary.  The first expression (which must be absolute) is the
 alignment request in bytes.  For example @samp{.balign 8} advances
 the location counter until it is a multiple of 8.  If the location counter
-is already a multiple of 8, no change is needed.
+is already a multiple of 8, no change is needed.  If the expression is omitted
+then a default value of 0 is used, effectively disabling alignment requirements.
 
 The second expression (also absolute) gives the fill value to be stored in the
 padding bytes.  It (and the comma) may be omitted.  If it is omitted, the
@@ -6258,7 +6260,7 @@ absolute expression.  If the comma and @var{fill} are omitted,
 @var{fill} defaults to zero.
 
 @node P2align
-@section @code{.p2align[wl] @var{abs-expr}, @var{abs-expr}, @var{abs-expr}}
+@section @code{.p2align[wl] [@var{abs-expr}[, @var{abs-expr}[, @var{abs-expr}]]]}
 
 @cindex padding the location counter given a power of two
 @cindex @code{p2align} directive
@@ -6267,7 +6269,8 @@ storage boundary.  The first expression (which must be absolute) is the
 number of low-order zero bits the location counter must have after
 advancement.  For example @samp{.p2align 3} advances the location
 counter until it is a multiple of 8.  If the location counter is already a
-multiple of 8, no change is needed.
+multiple of 8, no change is needed.  If the expression is omitted then a
+default value of 0 is used, effectively disabling alignment requirements.
 
 The second expression (also absolute) gives the fill value to be stored in the
 padding bytes.  It (and the comma) may be omitted.  If it is omitted, the
index 560071caffb5f59a6e84bcb2e83eedfdfb3ed84b..746ff7eea0ddb323a18ed64a5699e6734be890dc 100644 (file)
@@ -209,6 +209,7 @@ if { [is_elf_format] } then {
     }
     run_dump_test "symver"
     run_dump_test "pr21661"
+    run_dump_test "pr14891"
 
     # No indirect functions on non-GNU targets.
     # The Visium and MSP set the ELF header's OSABI field to ELFOSABI_STANDALONE.
diff --git a/gas/testsuite/gas/elf/pr14891.d b/gas/testsuite/gas/elf/pr14891.d
new file mode 100644 (file)
index 0000000..c15f28c
--- /dev/null
@@ -0,0 +1,2 @@
+#name: defining a section with the same name as a symbol
+#error_output: pr14891.l
diff --git a/gas/testsuite/gas/elf/pr14891.l b/gas/testsuite/gas/elf/pr14891.l
new file mode 100644 (file)
index 0000000..4013ec1
--- /dev/null
@@ -0,0 +1,3 @@
+[^:]*: Assembler messages:
+[^:]*:3: Error: section name 'foo' already defined as another symbol
+[^:]*:6: Error: symbol `bar' is already defined
diff --git a/gas/testsuite/gas/elf/pr14891.s b/gas/testsuite/gas/elf/pr14891.s
new file mode 100644 (file)
index 0000000..f8e1832
--- /dev/null
@@ -0,0 +1,6 @@
+
+foo:
+.section foo, "a"
+
+.section bar, "a"
+bar:
index 13099276a4b9702b8ffe9e6cecaae0a4877ad538..b10989a410d877aaf760780db55a7464b0ba0cb7 100644 (file)
@@ -1,3 +1,106 @@
+2020-01-08  Tom Tromey  <tromey@adacore.com>
+
+       * xcoffread.c (enter_line_range, read_xcoff_symtab)
+       (process_xcoff_symbol, xcoff_symfile_offsets): Update.
+       * symtab.h (MSYMBOL_VALUE_ADDRESS): Update.
+       (struct section_offsets, ANOFFSET, SIZEOF_N_SECTION_OFFSETS):
+       Remove.
+       (section_offsets): New typedef.
+       * symtab.c (fixup_section, get_msymbol_address): Update.
+       * symmisc.c (dump_msymbols): Update.
+       * symfile.h (relative_addr_info_to_section_offsets)
+       (symfile_map_offsets_to_segments): Update.
+       * symfile.c (build_section_addr_info_from_objfile)
+       (init_objfile_sect_indices): Update.
+       (struct place_section_arg): Change type of "offsets".
+       (place_section): Update.
+       (relative_addr_info_to_section_offsets): Change type of
+       "section_offsets".  Remove "num_sections" parameter.
+       (default_symfile_offsets, syms_from_objfile_1)
+       (set_objfile_default_section_offset): Update.
+       (reread_symbols): No need to preserve section offsets by hand.
+       (symfile_map_offsets_to_segments): Change type of "offsets".
+       * stap-probe.c (relocate_address): Update.
+       * stabsread.h (process_one_symbol): Update.
+       * solib-target.c (struct lm_info_target) <offsets>: Change type.
+       (solib_target_relocate_section_addresses): Update.
+       * solib-svr4.c (enable_break, svr4_relocate_main_executable):
+       Update.
+       * solib-frv.c (frv_relocate_main_executable): Update.
+       * solib-dsbt.c (dsbt_relocate_main_executable): Update.
+       * solib-aix.c (solib_aix_get_section_offsets): Change return
+       type.
+       (solib_aix_solib_create_inferior_hook): Update.
+       * remote.c (remote_target::get_offsets): Update.
+       * psymtab.c (find_pc_sect_psymtab): Update.
+       * psympriv.h (struct partial_symbol) <address, text_low,
+       text_high>: Update.
+       * objfiles.h (obj_section_offset): Update.
+       (struct objfile) <section_offsets>: Change type.
+       <num_sections>: Remove.
+       (objfile_relocate): Update.
+       * objfiles.c (entry_point_address_query): Update
+       (relocate_one_symbol): Change type of "section_offsets".
+       (objfile_relocate1, objfile_relocate1): Change type of
+       "new_offsets".
+       (objfile_rebase1): Update.
+       * mipsread.c (mipscoff_symfile_read): Update.
+       (read_alphacoff_dynamic_symtab): Remove "section_offsets"
+       parameter.
+       * mdebugread.c (parse_symbol): Change type of "section_offsets".
+       (parse_external, psymtab_to_symtab_1): Update.
+       * machoread.c (macho_symfile_offsets): Update.
+       * ia64-tdep.c (ia64_find_unwind_table): Update.
+       * hppa-tdep.c (read_unwind_info): Update.
+       * hppa-bsd-tdep.c (hppabsd_find_global_pointer): Update.
+       * dwarf2read.c (create_addrmap_from_index)
+       (create_addrmap_from_aranges, dw2_find_pc_sect_compunit_symtab)
+       (process_psymtab_comp_unit_reader, add_partial_symbol)
+       (add_partial_subprogram, process_full_comp_unit)
+       (read_file_scope, read_func_scope, read_lexical_block_scope)
+       (read_call_site_scope, dwarf2_rnglists_process)
+       (dwarf2_ranges_process, dwarf2_ranges_read)
+       (dwarf_decode_lines_1, var_decode_location, new_symbol)
+       (dwarf2_fetch_die_loc_sect_off, dwarf2_per_cu_text_offset):
+       Update.
+       * dwarf2-frame.c (execute_cfa_program, dwarf2_frame_find_fde):
+       Update.
+       * dtrace-probe.c (dtrace_probe::get_relocated_address): Update.
+       * dbxread.c (read_dbx_symtab, read_ofile_symtab): Update.
+       (process_one_symbol): Change type of "section_offsets".
+       * ctfread.c (get_objfile_text_range): Update.
+       * coffread.c (coff_symtab_read, enter_linenos)
+       (process_coff_symbol): Update.
+       * coff-pe-read.c (add_pe_forwarded_sym): Update.
+       * amd64-windows-tdep.c (amd64_windows_find_unwind_info): Update.
+
+2020-01-08  Tom Tromey  <tromey@adacore.com>
+
+       * dwarf2read.c (parse_macro_definition): Use std::string.
+       (parse_macro_definition): Likewise.
+
+2020-01-08  Tom Tromey  <tromey@adacore.com>
+
+       * dwarf2read.c (abbrev_table_read_table): Use std::vector.
+       (ATTR_ALLOC_CHUNK): Remove.
+
+2020-01-08  Tom Tromey  <tromey@adacore.com>
+
+       * dwarf2read.c (fixup_go_packaging): Use unique_xmalloc_ptr.
+
+2020-01-08  Tom Tromey  <tromey@adacore.com>
+
+       * dwarf2read.c (add_partial_symbol): Use unique_xmalloc_ptr.
+       (dwarf2_compute_name, open_dwo_file): Likewise.
+       (process_enumeration_scope): Use std::vector.
+       (guess_partial_die_structure_name): Use unique_xmalloc_ptr.
+       (partial_die_info::fixup, dwarf2_start_subfile)
+       (guess_full_die_structure_name, dwarf2_name): Likewise.
+       (determine_prefix): Update.
+       (guess_full_die_structure_name): Make return type const.
+       (partial_die_full_name): Return unique_xmalloc_ptr.
+       (DW_FIELD_ALLOC_CHUNK): Remove.
+
 2020-01-07  Tom Tromey  <tromey@adacore.com>
 
        PR build/24937:
index 2ce391fb90615b1383c3580191ca7eae2ca58fd7..e1e777c4355e74a617527fcebee594fcf182f778 100644 (file)
@@ -953,8 +953,8 @@ amd64_windows_find_unwind_info (struct gdbarch *gdbarch, CORE_ADDR pc,
   pe = pe_data (sec->objfile->obfd);
   dir = &pe->pe_opthdr.DataDirectory[PE_EXCEPTION_TABLE];
 
-  base = pe->pe_opthdr.ImageBase
-    + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
+  base = (pe->pe_opthdr.ImageBase
+         + objfile->section_offsets[SECT_OFF_TEXT (objfile)]);
   *image_base = base;
 
   /* Find the entry.
index d0c1e050c891fbc438f6550ff66ad97748724d5d..b7f7b81ca88251e5b6dce444527b286abe5509f3 100644 (file)
@@ -266,7 +266,7 @@ add_pe_forwarded_sym (minimal_symbol_reader &reader,
      really be relocated properly, but nevertheless we make a stab at
      it, choosing an approach consistent with the history of this
      code.  */
-  baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
+  baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)];
 
   reader.record_with_info (qualified_name.c_str (), vma - baseaddr, msymtype,
                           section);
index 0395d6d8794a2505c14eb048604bf5bfa94bf9c4..60efb59b1a341a89bae56ffde667aa9669efc1fa 100644 (file)
@@ -919,8 +919,8 @@ coff_symtab_read (minimal_symbol_reader &reader,
                     file with no symbols.  */
                  if (in_source_file)
                    complete_symtab (filestring,
-                   cs->c_value + ANOFFSET (objfile->section_offsets,
-                                           SECT_OFF_TEXT (objfile)),
+                                    (cs->c_value
+                                     + objfile->section_offsets[SECT_OFF_TEXT (objfile)]),
                                     main_aux.x_scn.x_scnlen);
                  in_source_file = 0;
                }
@@ -986,7 +986,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
                    || cs->c_sclass == C_THUMBEXTFUNC
                    || cs->c_sclass == C_THUMBEXT
                    || (pe_file && (cs->c_sclass == C_STAT)))
-                 offset = ANOFFSET (objfile->section_offsets, sec);
+                 offset = objfile->section_offsets[sec];
 
                if (bfd_section->flags & SEC_CODE)
                  {
@@ -1113,8 +1113,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
                            NULL, cstk.start_addr,
                            fcn_cs_saved.c_value
                            + fcn_aux_saved.x_sym.x_misc.x_fsize
-                           + ANOFFSET (objfile->section_offsets,
-                                       SECT_OFF_TEXT (objfile)));
+                           + objfile->section_offsets[SECT_OFF_TEXT (objfile)]);
              within_function = 0;
            }
          break;
@@ -1123,8 +1122,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
          if (strcmp (cs->c_name, ".bb") == 0)
            {
              tmpaddr = cs->c_value;
-             tmpaddr += ANOFFSET (objfile->section_offsets,
-                                  SECT_OFF_TEXT (objfile));
+             tmpaddr += objfile->section_offsets[SECT_OFF_TEXT (objfile)];
              push_context (++depth, tmpaddr);
            }
          else if (strcmp (cs->c_name, ".eb") == 0)
@@ -1147,9 +1145,9 @@ coff_symtab_read (minimal_symbol_reader &reader,
                }
              if (*get_local_symbols () && !outermost_context_p ())
                {
-                 tmpaddr =
-                   cs->c_value + ANOFFSET (objfile->section_offsets,
-                                           SECT_OFF_TEXT (objfile));
+                 tmpaddr
+                   = (cs->c_value
+                      + objfile->section_offsets[SECT_OFF_TEXT (objfile)]);
                  /* Make a block for the local symbols within.  */
                  finish_block (0, cstk.old_blocks, NULL,
                                cstk.start_addr, tmpaddr);
@@ -1441,8 +1439,7 @@ enter_linenos (long file_offset, int first_line,
       if (L_LNNO32 (&lptr) && L_LNNO32 (&lptr) <= last_line)
        {
          CORE_ADDR addr = lptr.l_addr.l_paddr;
-         addr += ANOFFSET (objfile->section_offsets,
-                           SECT_OFF_TEXT (objfile));
+         addr += objfile->section_offsets[SECT_OFF_TEXT (objfile)];
          record_line (get_current_subfile (),
                       first_line + L_LNNO32 (&lptr),
                       gdbarch_addr_bits_remove (gdbarch, addr));
@@ -1577,8 +1574,7 @@ process_coff_symbol (struct coff_symbol *cs,
 
   if (ISFCN (cs->c_type))
     {
-      SYMBOL_VALUE (sym) += ANOFFSET (objfile->section_offsets,
-                                     SECT_OFF_TEXT (objfile));
+      SYMBOL_VALUE (sym) += objfile->section_offsets[SECT_OFF_TEXT (objfile)];
       SYMBOL_TYPE (sym) =
        lookup_function_type (decode_function_type (cs, cs->c_type,
                                                    aux, objfile));
@@ -1610,8 +1606,7 @@ process_coff_symbol (struct coff_symbol *cs,
          SYMBOL_ACLASS_INDEX (sym) = LOC_STATIC;
          SET_SYMBOL_VALUE_ADDRESS (sym,
                                    (CORE_ADDR) cs->c_value
-                                   + ANOFFSET (objfile->section_offsets,
-                                               SECT_OFF_TEXT (objfile)));
+                                   + objfile->section_offsets[SECT_OFF_TEXT (objfile)]);
          add_symbol_to_list (sym, get_global_symbols ());
          break;
 
@@ -1621,8 +1616,7 @@ process_coff_symbol (struct coff_symbol *cs,
          SYMBOL_ACLASS_INDEX (sym) = LOC_STATIC;
          SET_SYMBOL_VALUE_ADDRESS (sym,
                                    (CORE_ADDR) cs->c_value
-                                   + ANOFFSET (objfile->section_offsets,
-                                               SECT_OFF_TEXT (objfile)));
+                                   + objfile->section_offsets[SECT_OFF_TEXT (objfile)]);
          if (within_function)
            {
              /* Static symbol of local scope.  */
index 990674e0dfc33ddf3240b93983309b6961856f45..ebf1eec6a57658c22e0dd17ca6f4b75a0458336f 100644 (file)
@@ -1165,7 +1165,7 @@ get_objfile_text_range (struct objfile *of, int *tsize)
 
   codes = bfd_get_section_by_name (abfd, ".text");
   *tsize = codes ? bfd_section_size (codes) : 0;
-  return ANOFFSET (of->section_offsets, SECT_OFF_TEXT (of));
+  return of->section_offsets[SECT_OFF_TEXT (of)];
 }
 
 /* Start a symtab for OBJFILE in CTF format.  */
index 0a02acc8ce99f85f0e7c802e334da461d39d165a..0909c67ccbb4c88b3f640ff4b3e8129222bec4ed 100644 (file)
@@ -1046,9 +1046,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile)
 
   /* If data_sect_index is still -1, that's okay.  It's perfectly fine
      for the file to have no .data, no .bss, and no .text at all, if
-     it also has no global or static variables.  If it does, we will
-     get an internal error from an ANOFFSET macro below when we try to
-     use data_sect_index.  */
+     it also has no global or static variables.  */
 
   for (symnum = 0; symnum < DBX_SYMCOUNT (objfile); symnum++)
     {
@@ -2179,13 +2177,12 @@ read_ofile_symtab (struct objfile *objfile, struct partial_symtab *pst)
   int sym_size;                        /* Size of symbols to read */
   CORE_ADDR text_offset;       /* Start of text segment for symbols */
   int text_size;               /* Size of text segment for symbols */
-  struct section_offsets *section_offsets;
 
   sym_offset = LDSYMOFF (pst);
   sym_size = LDSYMLEN (pst);
   text_offset = pst->text_low (objfile);
   text_size = pst->text_high (objfile) - pst->text_low (objfile);
-  section_offsets = objfile->section_offsets;
+  const section_offsets &section_offsets = objfile->section_offsets;
 
   dbxread_objfile = objfile;
 
@@ -2378,7 +2375,7 @@ cp_set_block_scope (const struct symbol *symbol,
 
 void
 process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
-                   const struct section_offsets *section_offsets,
+                   const section_offsets &section_offsets,
                    struct objfile *objfile, enum language language)
 {
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
@@ -2469,7 +2466,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
       sline_found_in_function = 0;
 
       /* Relocate for dynamic loading.  */
-      valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
+      valu += section_offsets[SECT_OFF_TEXT (objfile)];
       valu = gdbarch_addr_bits_remove (gdbarch, valu);
       last_function_start = valu;
 
@@ -2557,7 +2554,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
     case N_FN_SEQ:
       /* This kind of symbol indicates the start of an object file.
          Relocate for dynamic loading.  */
-      valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
+      valu += section_offsets[SECT_OFF_TEXT (objfile)];
       break;
 
     case N_SO:
@@ -2565,7 +2562,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
          source file.  Finish the symbol table of the previous source
          file (if any) and start accumulating a new symbol table.
          Relocate for dynamic loading.  */
-      valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
+      valu += section_offsets[SECT_OFF_TEXT (objfile)];
 
       n_opt_found = 0;
 
@@ -2601,7 +2598,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
          sub-source-file, one whose contents were copied or included
          in the compilation of the main source file (whose name was
          given in the N_SO symbol).  Relocate for dynamic loading.  */
-      valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
+      valu += section_offsets[SECT_OFF_TEXT (objfile)];
       start_subfile (name);
       break;
 
@@ -2701,7 +2698,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
                   symbol_file_add as addr (this is known to affect
                   SunOS 4, and I suspect ELF too).  Since there is no
                   Ttext.text symbol, we can get addr from the text offset.  */
-               valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
+               valu += section_offsets[SECT_OFF_TEXT (objfile)];
                goto define_a_symbol;
              }
          }
@@ -2723,22 +2720,22 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
 
     case_N_STSYM:              /* Static symbol in data segment.  */
     case N_DSLINE:             /* Source line number, data segment.  */
-      valu += ANOFFSET (section_offsets, SECT_OFF_DATA (objfile));
+      valu += section_offsets[SECT_OFF_DATA (objfile)];
       goto define_a_symbol;
 
     case_N_LCSYM:              /* Static symbol in BSS segment.  */
     case N_BSLINE:             /* Source line number, BSS segment.  */
       /* N_BROWS: overlaps with N_BSLINE.  */
-      valu += ANOFFSET (section_offsets, SECT_OFF_BSS (objfile));
+      valu += section_offsets[SECT_OFF_BSS (objfile)];
       goto define_a_symbol;
 
     case_N_ROSYM:              /* Static symbol in read-only data segment.  */
-      valu += ANOFFSET (section_offsets, SECT_OFF_RODATA (objfile));
+      valu += section_offsets[SECT_OFF_RODATA (objfile)];
       goto define_a_symbol;
 
     case N_ENTRY:              /* Alternate entry point.  */
       /* Relocate for dynamic loading.  */
-      valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
+      valu += section_offsets[SECT_OFF_TEXT (objfile)];
       goto define_a_symbol;
 
       /* The following symbol types we don't know how to process.
@@ -2789,8 +2786,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
              /* Deal with the SunPRO 3.0 compiler which omits the
                 address from N_FUN symbols.  */
              if (type == N_FUN
-                 && valu == ANOFFSET (section_offsets,
-                                      SECT_OFF_TEXT (objfile))
+                 && valu == section_offsets[SECT_OFF_TEXT (objfile)]
                  && gdbarch_sofun_address_maybe_missing (gdbarch))
                {
                  struct bound_minimal_symbol minsym
index 6494a8d7ccab3f4fef5fd53037c2f4b8d312203d..85f6c01b6ab09b0fd36a5085968640f6193adfe3 100644 (file)
@@ -685,8 +685,8 @@ dtrace_probe::is_enabled () const
 CORE_ADDR
 dtrace_probe::get_relocated_address (struct objfile *objfile)
 {
-  return this->get_address () + ANOFFSET (objfile->section_offsets,
-                                         SECT_OFF_DATA (objfile));
+  return (this->get_address ()
+         + objfile->section_offsets[SECT_OFF_DATA (objfile)]);
 }
 
 /* Implementation of the get_argument_count method.  */
index 9b49daec7190131c971d3dcdbb1f74e050ac1fc1..baa47c9438980c36c665fc899fc89fd44bf2b06e 100644 (file)
@@ -384,8 +384,7 @@ execute_cfa_program (struct dwarf2_fde *fde, const gdb_byte *insn_ptr,
                                           fde->cie->ptr_size, insn_ptr,
                                           &bytes_read, fde->initial_location);
              /* Apply the objfile offset for relocatable objects.  */
-             fs->pc += ANOFFSET (fde->cie->unit->objfile->section_offsets,
-                                 SECT_OFF_TEXT (fde->cie->unit->objfile));
+             fs->pc += fde->cie->unit->objfile->section_offsets[SECT_OFF_TEXT (fde->cie->unit->objfile)];
              insn_ptr += bytes_read;
              break;
 
@@ -1686,8 +1685,8 @@ dwarf2_frame_find_fde (CORE_ADDR *pc, CORE_ADDR *out_offset)
       if (fde_table->num_entries == 0)
        continue;
 
-      gdb_assert (objfile->section_offsets);
-      offset = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
+      gdb_assert (!objfile->section_offsets.empty ());
+      offset = objfile->section_offsets[SECT_OFF_TEXT (objfile)];
 
       gdb_assert (fde_table->num_entries > 0);
       if (*pc < offset + fde_table->entries[0]->initial_location)
index d6471e5bc316b6185a427c585e8c3cd23b68aaf9..51fb06e3b6617fbda5c4203cdae56c4253ba74c1 100644 (file)
@@ -1340,15 +1340,6 @@ struct dwarf_block
     const gdb_byte *data;
   };
 
-#ifndef ATTR_ALLOC_CHUNK
-#define ATTR_ALLOC_CHUNK 4
-#endif
-
-/* Allocate fields for structs, unions and enums in this size.  */
-#ifndef DW_FIELD_ALLOC_CHUNK
-#define DW_FIELD_ALLOC_CHUNK 4
-#endif
-
 /* FIXME: We might want to set this from BFD via bfd_arch_bits_per_byte,
    but this would require a corresponding change in unpack_field_as_long
    and friends.  */
@@ -3180,7 +3171,7 @@ create_addrmap_from_index (struct dwarf2_per_objfile *dwarf2_per_objfile,
   iter = index->address_table.data ();
   end = iter + index->address_table.size ();
 
-  baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
+  baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)];
 
   while (iter < end)
     {
@@ -3226,8 +3217,7 @@ create_addrmap_from_aranges (struct dwarf2_per_objfile *dwarf2_per_objfile,
   struct objfile *objfile = dwarf2_per_objfile->objfile;
   bfd *abfd = objfile->obfd;
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
-  const CORE_ADDR baseaddr = ANOFFSET (objfile->section_offsets,
-                                      SECT_OFF_TEXT (objfile));
+  const CORE_ADDR baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)];
 
   auto_obstack temp_obstack;
   addrmap *mutable_map = addrmap_create_mutable (&temp_obstack);
@@ -5247,8 +5237,7 @@ dw2_find_pc_sect_compunit_symtab (struct objfile *objfile,
   if (!objfile->partial_symtabs->psymtabs_addrmap)
     return NULL;
 
-  CORE_ADDR baseaddr = ANOFFSET (objfile->section_offsets,
-                                SECT_OFF_TEXT (objfile));
+  CORE_ADDR baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)];
   data = (struct dwarf2_per_cu_data *) addrmap_find
     (objfile->partial_symtabs->psymtabs_addrmap, pc - baseaddr);
   if (!data)
@@ -8078,7 +8067,7 @@ process_psymtab_comp_unit_reader (const struct die_reader_specs *reader,
   /* This must be done before calling dwarf2_build_include_psymtabs.  */
   pst->dirname = dwarf2_string_attr (comp_unit_die, DW_AT_comp_dir, cu);
 
-  baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
+  baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)];
 
   dwarf2_find_base_address (comp_unit_die, cu);
 
@@ -8908,7 +8897,7 @@ partial_die_parent_scope (struct partial_die_info *pdi,
 /* Return the fully scoped name associated with PDI, from compilation unit
    CU.  The result will be allocated with malloc.  */
 
-static char *
+static gdb::unique_xmalloc_ptr<char>
 partial_die_full_name (struct partial_die_info *pdi,
                       struct dwarf2_cu *cu)
 {
@@ -8934,7 +8923,7 @@ partial_die_full_name (struct partial_die_info *pdi,
          attr.u.unsnd = to_underlying (pdi->sect_off);
          die = follow_die_ref (NULL, &attr, &ref_cu);
 
-         return xstrdup (dwarf2_full_name (NULL, die, ref_cu));
+         return make_unique_xstrdup (dwarf2_full_name (NULL, die, ref_cu));
        }
     }
 
@@ -8942,7 +8931,8 @@ partial_die_full_name (struct partial_die_info *pdi,
   if (parent_scope == NULL)
     return NULL;
   else
-    return typename_concat (NULL, parent_scope, pdi->name, 0, cu);
+    return gdb::unique_xmalloc_ptr<char> (typename_concat (NULL, parent_scope,
+                                                          pdi->name, 0, cu));
 }
 
 static void
@@ -8955,13 +8945,13 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
   CORE_ADDR addr = 0;
   const char *actual_name = NULL;
   CORE_ADDR baseaddr;
-  char *built_actual_name;
 
-  baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
+  baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)];
 
-  built_actual_name = partial_die_full_name (pdi, cu);
+  gdb::unique_xmalloc_ptr<char> built_actual_name
+    = partial_die_full_name (pdi, cu);
   if (built_actual_name != NULL)
-    actual_name = built_actual_name;
+    actual_name = built_actual_name.get ();
 
   if (actual_name == NULL)
     actual_name = pdi->name;
@@ -9054,10 +9044,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
          /* Static Variable.  Skip symbols whose value we cannot know (those
             without location descriptors or constant values).  */
          if (!has_loc && !pdi->has_const_value)
-           {
-             xfree (built_actual_name);
-             return;
-           }
+           return;
 
          add_psymbol_to_list (actual_name,
                               built_actual_name != NULL,
@@ -9107,10 +9094,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
          union or class entry that does not have a byte size attribute
          and that has a DW_AT_declaration attribute."  */
       if (!pdi->has_byte_size && pdi->is_declaration)
-       {
-         xfree (built_actual_name);
-         return;
-       }
+       return;
 
       /* NOTE: carlton/2003-10-07: See comment in new_symbol about
         static vs. global.  */
@@ -9135,8 +9119,6 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
     default:
       break;
     }
-
-  xfree (built_actual_name);
 }
 
 /* Read a partial die corresponding to a namespace; also, add a symbol
@@ -9207,8 +9189,7 @@ add_partial_subprogram (struct partial_die_info *pdi,
              CORE_ADDR this_highpc;
              CORE_ADDR this_lowpc;
 
-             baseaddr = ANOFFSET (objfile->section_offsets,
-                                  SECT_OFF_TEXT (objfile));
+             baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)];
              this_lowpc
                = (gdbarch_adjust_dwarf2_addr (gdbarch,
                                               pdi->lowpc + baseaddr)
@@ -9905,7 +9886,7 @@ compute_delayed_physnames (struct dwarf2_cu *cu)
 static void
 fixup_go_packaging (struct dwarf2_cu *cu)
 {
-  char *package_name = NULL;
+  gdb::unique_xmalloc_ptr<char> package_name;
   struct pending *list;
   int i;
 
@@ -9920,24 +9901,24 @@ fixup_go_packaging (struct dwarf2_cu *cu)
          if (sym->language () == language_go
              && SYMBOL_CLASS (sym) == LOC_BLOCK)
            {
-             char *this_package_name = go_symbol_package_name (sym);
+             gdb::unique_xmalloc_ptr<char> this_package_name
+               (go_symbol_package_name (sym));
 
              if (this_package_name == NULL)
                continue;
              if (package_name == NULL)
-               package_name = this_package_name;
+               package_name = std::move (this_package_name);
              else
                {
                  struct objfile *objfile
                    = cu->per_cu->dwarf2_per_objfile->objfile;
-                 if (strcmp (package_name, this_package_name) != 0)
+                 if (strcmp (package_name.get (), this_package_name.get ()) != 0)
                    complaint (_("Symtab %s has objects from two different Go packages: %s and %s"),
                               (symbol_symtab (sym) != NULL
                                ? symtab_to_filename_for_display
                                    (symbol_symtab (sym))
                                : objfile_name (objfile)),
-                              this_package_name, package_name);
-                 xfree (this_package_name);
+                              this_package_name.get (), package_name.get ());
                }
            }
        }
@@ -9947,7 +9928,7 @@ fixup_go_packaging (struct dwarf2_cu *cu)
     {
       struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile;
       const char *saved_package_name
-       = obstack_strdup (&objfile->per_bfd->storage_obstack, package_name);
+       = obstack_strdup (&objfile->per_bfd->storage_obstack, package_name.get ());
       struct type *type = init_type (objfile, TYPE_CODE_MODULE, 0,
                                     saved_package_name);
       struct symbol *sym;
@@ -9962,8 +9943,6 @@ fixup_go_packaging (struct dwarf2_cu *cu)
       SYMBOL_TYPE (sym) = type;
 
       add_symbol_to_list (sym, cu->get_builder ()->get_global_symbols ());
-
-      xfree (package_name);
     }
 }
 
@@ -10419,7 +10398,7 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu,
   struct block *static_block;
   CORE_ADDR addr;
 
-  baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
+  baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)];
 
   /* Clear the list here in case something was left over.  */
   cu->method_list.clear ();
@@ -10913,11 +10892,10 @@ dwarf2_compute_name (const char *name,
          prefix = determine_prefix (die, cu);
          if (*prefix != '\0')
            {
-             char *prefixed_name = typename_concat (NULL, prefix, name,
-                                                    physname, cu);
+             gdb::unique_xmalloc_ptr<char> prefixed_name
+               (typename_concat (NULL, prefix, name, physname, cu));
 
-             buf.puts (prefixed_name);
-             xfree (prefixed_name);
+             buf.puts (prefixed_name.get ());
            }
          else
            buf.puts (name);
@@ -11622,7 +11600,7 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu)
   CORE_ADDR baseaddr;
 
   prepare_one_comp_unit (cu, die, cu->language);
-  baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
+  baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)];
 
   get_scope_pc_bounds (die, &lowpc, &highpc, cu);
 
@@ -12959,16 +12937,15 @@ open_dwo_file (struct dwarf2_per_objfile *dwarf2_per_objfile,
 
   if (comp_dir != NULL)
     {
-      char *path_to_try = concat (comp_dir, SLASH_STRING,
-                                 file_name, (char *) NULL);
+      gdb::unique_xmalloc_ptr<char> path_to_try
+       (concat (comp_dir, SLASH_STRING, file_name, (char *) NULL));
 
       /* NOTE: If comp_dir is a relative path, this will also try the
         search path, which seems useful.  */
       gdb_bfd_ref_ptr abfd (try_open_dwop_file (dwarf2_per_objfile,
-                                               path_to_try,
+                                               path_to_try.get (),
                                                0 /*is_dwp*/,
                                                1 /*search_cwd*/));
-      xfree (path_to_try);
       if (abfd != NULL)
        return abfd;
     }
@@ -13737,7 +13714,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
        }
     }
 
-  baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
+  baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)];
 
   name = dwarf2_name (die, cu);
 
@@ -13916,7 +13893,7 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu)
   struct die_info *child_die;
   CORE_ADDR baseaddr;
 
-  baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
+  baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)];
 
   /* Ignore blocks with missing or invalid low and high pc attributes.  */
   /* ??? Perhaps consider discontiguous blocks defined by DW_AT_ranges
@@ -13990,7 +13967,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
   int nparams;
   struct die_info *child_die;
 
-  baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
+  baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)];
 
   attr = dwarf2_attr (die, DW_AT_call_return_pc, cu);
   if (attr == NULL)
@@ -14387,7 +14364,7 @@ dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu,
     }
   buffer = dwarf2_per_objfile->rnglists.buffer + offset;
 
-  baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
+  baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)];
 
   while (1)
     {
@@ -14555,7 +14532,7 @@ dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu,
     }
   buffer = dwarf2_per_objfile->ranges.buffer + offset;
 
-  baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
+  baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)];
 
   while (1)
     {
@@ -14633,8 +14610,7 @@ dwarf2_ranges_read (unsigned offset, CORE_ADDR *low_return,
 {
   struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile;
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
-  const CORE_ADDR baseaddr = ANOFFSET (objfile->section_offsets,
-                                      SECT_OFF_TEXT (objfile));
+  const CORE_ADDR baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)];
   int low_set = 0;
   CORE_ADDR low = 0;
   CORE_ADDR high = 0;
@@ -16549,8 +16525,7 @@ process_enumeration_scope (struct die_info *die, struct dwarf2_cu *cu)
     {
       struct die_info *child_die;
       struct symbol *sym;
-      struct field *fields = NULL;
-      int num_fields = 0;
+      std::vector<struct field> fields;
       const char *name;
 
       child_die = die->child;
@@ -16567,34 +16542,26 @@ process_enumeration_scope (struct die_info *die, struct dwarf2_cu *cu)
                {
                  sym = new_symbol (child_die, this_type, cu);
 
-                 if ((num_fields % DW_FIELD_ALLOC_CHUNK) == 0)
-                   {
-                     fields = (struct field *)
-                       xrealloc (fields,
-                                 (num_fields + DW_FIELD_ALLOC_CHUNK)
-                                 * sizeof (struct field));
-                   }
-
-                 FIELD_NAME (fields[num_fields]) = sym->linkage_name ();
-                 FIELD_TYPE (fields[num_fields]) = NULL;
-                 SET_FIELD_ENUMVAL (fields[num_fields], SYMBOL_VALUE (sym));
-                 FIELD_BITSIZE (fields[num_fields]) = 0;
+                 fields.emplace_back ();
+                 struct field &field = fields.back ();
 
-                 num_fields++;
+                 FIELD_NAME (field) = sym->linkage_name ();
+                 FIELD_TYPE (field) = NULL;
+                 SET_FIELD_ENUMVAL (field, SYMBOL_VALUE (sym));
+                 FIELD_BITSIZE (field) = 0;
                }
            }
 
          child_die = sibling_die (child_die);
        }
 
-      if (num_fields)
+      if (!fields.empty ())
        {
-         TYPE_NFIELDS (this_type) = num_fields;
+         TYPE_NFIELDS (this_type) = fields.size ();
          TYPE_FIELDS (this_type) = (struct field *)
-           TYPE_ALLOC (this_type, sizeof (struct field) * num_fields);
-         memcpy (TYPE_FIELDS (this_type), fields,
-                 sizeof (struct field) * num_fields);
-         xfree (fields);
+           TYPE_ALLOC (this_type, sizeof (struct field) * fields.size ());
+         memcpy (TYPE_FIELDS (this_type), fields.data (),
+                 sizeof (struct field) * fields.size ());
        }
     }
 
@@ -18585,8 +18552,7 @@ abbrev_table_read_table (struct dwarf2_per_objfile *dwarf2_per_objfile,
   struct abbrev_info *cur_abbrev;
   unsigned int abbrev_number, bytes_read, abbrev_name;
   unsigned int abbrev_form;
-  struct attr_abbrev *cur_attrs;
-  unsigned int allocated_attrs;
+  std::vector<struct attr_abbrev> cur_attrs;
 
   abbrev_table_up abbrev_table (new struct abbrev_table (sect_off));
 
@@ -18595,12 +18561,10 @@ abbrev_table_read_table (struct dwarf2_per_objfile *dwarf2_per_objfile,
   abbrev_number = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
   abbrev_ptr += bytes_read;
 
-  allocated_attrs = ATTR_ALLOC_CHUNK;
-  cur_attrs = XNEWVEC (struct attr_abbrev, allocated_attrs);
-
   /* Loop until we reach an abbrev number of 0.  */
   while (abbrev_number)
     {
+      cur_attrs.clear ();
       cur_abbrev = abbrev_table->alloc_abbrev ();
 
       /* read in abbrev header */
@@ -18635,25 +18599,18 @@ abbrev_table_read_table (struct dwarf2_per_objfile *dwarf2_per_objfile,
          if (abbrev_name == 0)
            break;
 
-         if (cur_abbrev->num_attrs == allocated_attrs)
-           {
-             allocated_attrs += ATTR_ALLOC_CHUNK;
-             cur_attrs
-               = XRESIZEVEC (struct attr_abbrev, cur_attrs, allocated_attrs);
-           }
-
-         cur_attrs[cur_abbrev->num_attrs].name
-           = (enum dwarf_attribute) abbrev_name;
-         cur_attrs[cur_abbrev->num_attrs].form
-           = (enum dwarf_form) abbrev_form;
-         cur_attrs[cur_abbrev->num_attrs].implicit_const = implicit_const;
+         cur_attrs.emplace_back ();
+         struct attr_abbrev &cur_attr = cur_attrs.back ();
+         cur_attr.name = (enum dwarf_attribute) abbrev_name;
+         cur_attr.form = (enum dwarf_form) abbrev_form;
+         cur_attr.implicit_const = implicit_const;
          ++cur_abbrev->num_attrs;
        }
 
       cur_abbrev->attrs =
        XOBNEWVEC (&abbrev_table->abbrev_obstack, struct attr_abbrev,
                   cur_abbrev->num_attrs);
-      memcpy (cur_abbrev->attrs, cur_attrs,
+      memcpy (cur_abbrev->attrs, cur_attrs.data (),
              cur_abbrev->num_attrs * sizeof (struct attr_abbrev));
 
       abbrev_table->add_abbrev (abbrev_number, cur_abbrev);
@@ -18673,7 +18630,6 @@ abbrev_table_read_table (struct dwarf2_per_objfile *dwarf2_per_objfile,
        break;
     }
 
-  xfree (cur_attrs);
   return abbrev_table;
 }
 
@@ -19346,16 +19302,15 @@ guess_partial_die_structure_name (struct partial_die_info *struct_pdi,
       if (child_pdi->tag == DW_TAG_subprogram
          && child_pdi->linkage_name != NULL)
        {
-         char *actual_class_name
-           language_class_name_from_physname (cu->language_defn,
-                                                child_pdi->linkage_name);
+         gdb::unique_xmalloc_ptr<char> actual_class_name
+           (language_class_name_from_physname (cu->language_defn,
+                                               child_pdi->linkage_name));
          if (actual_class_name != NULL)
            {
              struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile;
              struct_pdi->name
                = obstack_strdup (&objfile->per_bfd->storage_obstack,
-                                 actual_class_name);
-             xfree (actual_class_name);
+                                 actual_class_name.get ());
            }
          break;
        }
@@ -19420,24 +19375,22 @@ partial_die_info::fixup (struct dwarf2_cu *cu)
          || tag == DW_TAG_union_type)
       && linkage_name != NULL)
     {
-      char *demangled;
-
-      demangled = gdb_demangle (linkage_name, DMGL_TYPES);
-      if (demangled)
+      gdb::unique_xmalloc_ptr<char> demangled
+       (gdb_demangle (linkage_name, DMGL_TYPES));
+      if (demangled != nullptr)
        {
          const char *base;
 
          /* Strip any leading namespaces/classes, keep only the base name.
             DW_AT_name for named DIEs does not contain the prefixes.  */
-         base = strrchr (demangled, ':');
-         if (base && base > demangled && base[-1] == ':')
+         base = strrchr (demangled.get (), ':');
+         if (base && base > demangled.get () && base[-1] == ':')
            base++;
          else
-           base = demangled;
+           base = demangled.get ();
 
          struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile;
          name = obstack_strdup (&objfile->per_bfd->storage_obstack, base);
-         xfree (demangled);
        }
     }
 
@@ -21426,7 +21379,7 @@ dwarf_decode_lines_1 (struct line_header *lh, struct dwarf2_cu *cu,
      the line number program).  */
   bool record_lines_p = !decode_for_pst_p;
 
-  baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
+  baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)];
 
   line_ptr = lh->statement_program_start;
   line_end = lh->statement_program_end;
@@ -21717,7 +21670,7 @@ static void
 dwarf2_start_subfile (struct dwarf2_cu *cu, const char *filename,
                      const char *dirname)
 {
-  char *copy = NULL;
+  gdb::unique_xmalloc_ptr<char> copy;
 
   /* In order not to lose the line information directory,
      we concatenate it to the filename when it makes sense.
@@ -21728,14 +21681,11 @@ dwarf2_start_subfile (struct dwarf2_cu *cu, const char *filename,
 
   if (!IS_ABSOLUTE_PATH (filename) && dirname != NULL)
     {
-      copy = concat (dirname, SLASH_STRING, filename, (char *)NULL);
-      filename = copy;
+      copy.reset (concat (dirname, SLASH_STRING, filename, (char *) NULL));
+      filename = copy.get ();
     }
 
   cu->get_builder ()->start_subfile (filename);
-
-  if (copy != NULL)
-    xfree (copy);
 }
 
 /* Start a symtab for DWARF.  NAME, COMP_DIR, LOW_PC are passed to the
@@ -21812,10 +21762,10 @@ var_decode_location (struct attribute *attr, struct symbol *sym,
                                             &dummy));
       SYMBOL_ACLASS_INDEX (sym) = LOC_STATIC;
       fixup_symbol_section (sym, objfile);
-      SET_SYMBOL_VALUE_ADDRESS (sym,
-                               SYMBOL_VALUE_ADDRESS (sym)
-                               + ANOFFSET (objfile->section_offsets,
-                                           SYMBOL_SECTION (sym)));
+      SET_SYMBOL_VALUE_ADDRESS
+       (sym,
+        SYMBOL_VALUE_ADDRESS (sym)
+        + objfile->section_offsets[SYMBOL_SECTION (sym)]);
       return;
     }
 
@@ -21857,7 +21807,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 
   int inlined_func = (die->tag == DW_TAG_inlined_subroutine);
 
-  baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
+  baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)];
 
   name = dwarf2_name (die, cu);
   if (name)
@@ -22703,7 +22653,7 @@ read_type_die_1 (struct die_info *die, struct dwarf2_cu *cu)
    This is the full-die version of guess_partial_die_structure_name.
    In this case we know DIE has no useful parent.  */
 
-static char *
+static const char *
 guess_full_die_structure_name (struct die_info *die, struct dwarf2_cu *cu)
 {
   struct die_info *spec_die;
@@ -22729,33 +22679,32 @@ guess_full_die_structure_name (struct die_info *die, struct dwarf2_cu *cu)
 
          if (linkage_name != NULL)
            {
-             char *actual_name
-               language_class_name_from_physname (cu->language_defn,
-                                                    linkage_name);
-             char *name = NULL;
+             gdb::unique_xmalloc_ptr<char> actual_name
+               (language_class_name_from_physname (cu->language_defn,
+                                                   linkage_name));
+             const char *name = NULL;
 
              if (actual_name != NULL)
                {
                  const char *die_name = dwarf2_name (die, cu);
 
                  if (die_name != NULL
-                     && strcmp (die_name, actual_name) != 0)
+                     && strcmp (die_name, actual_name.get ()) != 0)
                    {
                      /* Strip off the class name from the full name.
                         We want the prefix.  */
                      int die_name_len = strlen (die_name);
-                     int actual_name_len = strlen (actual_name);
+                     int actual_name_len = strlen (actual_name.get ());
+                     const char *ptr = actual_name.get ();
 
                      /* Test for '::' as a sanity check.  */
                      if (actual_name_len > die_name_len + 2
-                         && actual_name[actual_name_len
-                                        - die_name_len - 1] == ':')
+                         && ptr[actual_name_len - die_name_len - 1] == ':')
                        name = obstack_strndup (
                          &objfile->per_bfd->storage_obstack,
-                         actual_name, actual_name_len - die_name_len - 2);
+                         ptr, actual_name_len - die_name_len - 2);
                    }
                }
-             xfree (actual_name);
              return name;
            }
        }
@@ -22942,7 +22891,7 @@ determine_prefix (struct die_info *die, struct dwarf2_cu *cu)
                || die->tag == DW_TAG_structure_type
                || die->tag == DW_TAG_union_type))
          {
-           char *name = guess_full_die_structure_name (die, cu);
+           const char *name = guess_full_die_structure_name (die, cu);
            if (name != NULL)
              return name;
          }
@@ -23116,8 +23065,6 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu)
         http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47510.  */
       if (!attr || DW_STRING (attr) == NULL)
        {
-         char *demangled = NULL;
-
          attr = dw2_linkage_name_attr (die, cu);
          if (attr == NULL || DW_STRING (attr) == NULL)
            return NULL;
@@ -23125,18 +23072,17 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu)
          /* Avoid demangling DW_STRING (attr) the second time on a second
             call for the same DIE.  */
          if (!DW_STRING_IS_CANONICAL (attr))
-           demangled = gdb_demangle (DW_STRING (attr), DMGL_TYPES);
-
-         if (demangled)
            {
+             gdb::unique_xmalloc_ptr<char> demangled
+               (gdb_demangle (DW_STRING (attr), DMGL_TYPES));
+
              const char *base;
 
              /* FIXME: we already did this for the partial symbol... */
              DW_STRING (attr)
                = obstack_strdup (&objfile->per_bfd->storage_obstack,
-                                 demangled);
+                                 demangled.get ());
              DW_STRING_IS_CANONICAL (attr) = 1;
-             xfree (demangled);
 
              /* Strip any leading namespaces/classes, keep only the base name.
                 DW_AT_name for named DIEs does not contain the prefixes.  */
@@ -23659,8 +23605,7 @@ dwarf2_fetch_die_loc_sect_off (sect_offset sect_off,
          != dwarf2_per_objfile->abstract_to_concrete.end ()))
     {
       CORE_ADDR pc = (*get_frame_pc) (baton);
-      CORE_ADDR baseaddr
-       = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
+      CORE_ADDR baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)];
       struct gdbarch *gdbarch = get_objfile_arch (objfile);
 
       for (const auto &cand_off
@@ -24621,7 +24566,7 @@ parse_macro_definition (struct macro_source_file *file, int line,
     {
       /* It's an object-like macro.  */
       int name_len = p - body;
-      char *name = savestring (body, name_len);
+      std::string name (body, name_len);
       const char *replacement;
 
       if (*p == ' ')
@@ -24632,14 +24577,12 @@ parse_macro_definition (struct macro_source_file *file, int line,
           replacement = body + name_len;
         }
 
-      macro_define_object (file, line, name, replacement);
-
-      xfree (name);
+      macro_define_object (file, line, name.c_str (), replacement);
     }
   else if (*p == '(')
     {
       /* It's a function-like macro.  */
-      char *name = savestring (body, p - body);
+      std::string name (body, p - body);
       int argc = 0;
       int argv_size = 1;
       char **argv = XNEWVEC (char *, argv_size);
@@ -24688,14 +24631,14 @@ parse_macro_definition (struct macro_source_file *file, int line,
 
           if (*p == ' ')
             /* Perfectly formed definition, no complaints.  */
-            macro_define_function (file, line, name,
+            macro_define_function (file, line, name.c_str (),
                                    argc, (const char **) argv,
                                    p + 1);
           else if (*p == '\0')
             {
               /* Complain, but do define it.  */
              dwarf2_macro_malformed_definition_complaint (body);
-              macro_define_function (file, line, name,
+              macro_define_function (file, line, name.c_str (),
                                      argc, (const char **) argv,
                                      p);
             }
@@ -24707,7 +24650,6 @@ parse_macro_definition (struct macro_source_file *file, int line,
         /* Just complain.  */
        dwarf2_macro_malformed_definition_complaint (body);
 
-      xfree (name);
       {
         int i;
 
@@ -25680,7 +25622,7 @@ dwarf2_per_cu_text_offset (struct dwarf2_per_cu_data *per_cu)
 {
   struct objfile *objfile = per_cu->dwarf2_per_objfile->objfile;
 
-  return ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
+  return objfile->section_offsets[SECT_OFF_TEXT (objfile)];
 }
 
 /* Return a type that is a generic pointer type, the size of which matches
index 6575c2413c3ce1a9c1634e80b7d1f807e6b7647f..34dec20298fb5217a014c19d2302e9b655247fa5 100644 (file)
@@ -87,8 +87,7 @@ hppabsd_find_global_pointer (struct gdbarch *gdbarch, struct value *function)
                     we have to do it ourselves.  */
                  pltgot = extract_unsigned_integer (buf, sizeof buf,
                                                     byte_order);
-                 pltgot += ANOFFSET (sec->objfile->section_offsets,
-                                     SECT_OFF_TEXT (sec->objfile));
+                 pltgot += sec->objfile->section_offsets[SECT_OFF_TEXT (sec->objfile)];
 
                  return pltgot;
                }
index 9aa274d0bafdc0ed585251b969842c1cf3bc478a..1ee1b0ba286e29836fa664b8c251448a652537e2 100644 (file)
@@ -357,7 +357,7 @@ read_unwind_info (struct objfile *objfile)
   struct hppa_unwind_info *ui;
   struct hppa_objfile_private *obj_private;
 
-  text_offset = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
+  text_offset = objfile->section_offsets[SECT_OFF_TEXT (objfile)];
   ui = (struct hppa_unwind_info *) obstack_alloc (&objfile->objfile_obstack,
                                           sizeof (struct hppa_unwind_info));
 
index 382ca3c88cf05457ce55a3162128ac4d325a82fe..40d4fd3c19d3c80147008b5ffcbf64bdd8c28537 100644 (file)
@@ -2713,7 +2713,7 @@ ia64_find_unwind_table (struct objfile *objfile, unw_word_t ip,
   ehdr = elf_tdata (bfd)->elf_header;
   phdr = elf_tdata (bfd)->phdr;
 
-  load_base = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
+  load_base = objfile->section_offsets[SECT_OFF_TEXT (objfile)];
 
   for (i = 0; i < ehdr->e_phnum; ++i)
     {
index f7dc280617532fb8af081f1bc281a87953a4ed6b..2bb3ab32cb30d21048479b6cd570b849180f16c8 100644 (file)
@@ -907,12 +907,7 @@ macho_symfile_offsets (struct objfile *objfile,
   struct obj_section *osect;
 
   /* Allocate section_offsets.  */
-  objfile->num_sections = bfd_count_sections (objfile->obfd);
-  objfile->section_offsets = (struct section_offsets *)
-    obstack_alloc (&objfile->objfile_obstack,
-                   SIZEOF_N_SECTION_OFFSETS (objfile->num_sections));
-  memset (objfile->section_offsets, 0,
-          SIZEOF_N_SECTION_OFFSETS (objfile->num_sections));
+  objfile->section_offsets.assign (bfd_count_sections (objfile->obfd), 0);
 
   /* This code is run when we first add the objfile with
      symfile_add_with_addrs_or_offsets, when "addrs" not "offsets" are
index 622ff279249a039efb987d42c8ad81aa6b3e2c54..ff1d13032210447d0e6a80521cca11e2d6cc90c4 100644 (file)
@@ -580,7 +580,7 @@ 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,
-             struct section_offsets *section_offsets, struct objfile *objfile)
+             const section_offsets &section_offsets, struct objfile *objfile)
 {
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
   const bfd_size_type external_sym_size = debug_swap->external_sym_size;
@@ -610,18 +610,18 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
          The value of a stBlock symbol is the displacement from the
          procedure address.  */
       if (sh->st != stEnd && sh->st != stBlock)
-       sh->value += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
+       sh->value += section_offsets[SECT_OFF_TEXT (objfile)];
       break;
     case scData:
     case scSData:
     case scRData:
     case scPData:
     case scXData:
-      sh->value += ANOFFSET (section_offsets, SECT_OFF_DATA (objfile));
+      sh->value += section_offsets[SECT_OFF_DATA (objfile)];
       break;
     case scBss:
     case scSBss:
-      sh->value += ANOFFSET (section_offsets, SECT_OFF_BSS (objfile));
+      sh->value += section_offsets[SECT_OFF_BSS (objfile)];
       break;
     }
 
@@ -2023,8 +2023,7 @@ parse_procedure (PDR *pr, struct compunit_symtab *search_symtab,
       /* GDB expects the absolute function start address for the
          procedure descriptor in e->pdr.adr.
          As the address in the procedure descriptor is usually relative,
-         we would have to relocate e->pdr.adr with cur_fdr->adr and
-         ANOFFSET (pst->section_offsets, SECT_OFF_TEXT (pst->objfile)).
+         we would have to relocate e->pdr.adr with cur_fdr->adr.
          Unfortunately cur_fdr->adr and e->pdr.adr are both absolute
          in shared libraries on some systems, and on other systems
          e->pdr.adr is sometimes offset by a bogus value.
@@ -2060,11 +2059,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 *, int, struct section_offsets *,
-                           struct objfile *);
-
 static void
-parse_external (EXTR *es, int bigend, struct section_offsets *section_offsets,
+parse_external (EXTR *es, int bigend, const section_offsets &section_offsets,
                struct objfile *objfile)
 {
   union aux_ext *ax;
@@ -3862,7 +3858,7 @@ psymtab_to_symtab_1 (struct objfile *objfile,
   struct linetable *lines;
   CORE_ADDR lowest_pdr_addr = 0;
   int last_symtab_ended = 0;
-  struct section_offsets *section_offsets = objfile->section_offsets;
+  const section_offsets &section_offsets = objfile->section_offsets;
 
   if (pst->readin)
     return;
@@ -3980,8 +3976,7 @@ psymtab_to_symtab_1 (struct objfile *objfile,
                      && previous_stab_code != (unsigned char) N_SO
                      && *name == '\000')
                    {
-                     valu += ANOFFSET (section_offsets,
-                                       SECT_OFF_TEXT (objfile));
+                     valu += section_offsets[SECT_OFF_TEXT (objfile)];
                      previous_stab_code = N_SO;
                      cust = end_symtab (valu, SECT_OFF_TEXT (objfile));
                      end_stabs ();
@@ -4028,8 +4023,7 @@ psymtab_to_symtab_1 (struct objfile *objfile,
              else
                {
                  /* Handle encoded stab line number.  */
-                 valu += ANOFFSET (section_offsets,
-                                   SECT_OFF_TEXT (objfile));
+                 valu += section_offsets[SECT_OFF_TEXT (objfile)];
                  record_line (get_current_subfile (), sh.index,
                               gdbarch_addr_bits_remove (gdbarch, valu));
                }
index d7f2aa44b3f97f8adbf691fb23cbc817a40bd4b1..2c11873d4449ce6021335f833779c0f82ecf3355 100644 (file)
@@ -43,7 +43,6 @@
 
 static void
 read_alphacoff_dynamic_symtab (minimal_symbol_reader &,
-                              struct section_offsets *,
                               struct objfile *objfile);
 
 /* Initialize anything that needs initializing when a completely new
@@ -84,7 +83,7 @@ mipscoff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
 
   /* Add alpha coff dynamic symbols.  */
 
-  read_alphacoff_dynamic_symtab (reader, objfile->section_offsets, objfile);
+  read_alphacoff_dynamic_symtab (reader, objfile);
 
   /* Install any minimal symbols that have been collected as the current
      minimal symbols for this objfile.  */
@@ -174,7 +173,6 @@ alphacoff_locate_sections (bfd *ignore_abfd, asection *sectp, void *sip)
 
 static void
 read_alphacoff_dynamic_symtab (minimal_symbol_reader &reader,
-                              struct section_offsets *section_offsets,
                               struct objfile *objfile)
 {
   bfd *abfd = objfile->obfd;
index ff408b605277c14c9fe105f72166228333731694..3138049e6223b3b45e6700d63c69c621e5d34ba4 100644 (file)
@@ -391,9 +391,9 @@ entry_point_address_query (CORE_ADDR *entry_p)
   if (symfile_objfile == NULL || !symfile_objfile->per_bfd->ei.entry_point_p)
     return 0;
 
+  int idx = symfile_objfile->per_bfd->ei.the_bfd_section_index;
   *entry_p = (symfile_objfile->per_bfd->ei.entry_point
-             + ANOFFSET (symfile_objfile->section_offsets,
-                         symfile_objfile->per_bfd->ei.the_bfd_section_index));
+             + symfile_objfile->section_offsets[idx]);
 
   return 1;
 }
@@ -626,7 +626,7 @@ objfile::~objfile ()
 
 static void
 relocate_one_symbol (struct symbol *sym, struct objfile *objfile,
-                    struct section_offsets *delta)
+                    const section_offsets &delta)
 {
   fixup_symbol_section (sym, objfile);
 
@@ -640,7 +640,7 @@ relocate_one_symbol (struct symbol *sym, struct objfile *objfile,
     {
       SET_SYMBOL_VALUE_ADDRESS (sym,
                                SYMBOL_VALUE_ADDRESS (sym)
-                               + ANOFFSET (delta, SYMBOL_SECTION (sym)));
+                               + delta[SYMBOL_SECTION (sym)]);
     }
 }
 
@@ -650,19 +650,16 @@ relocate_one_symbol (struct symbol *sym, struct objfile *objfile,
 
 static int
 objfile_relocate1 (struct objfile *objfile, 
-                  const struct section_offsets *new_offsets)
+                  const section_offsets &new_offsets)
 {
-  struct section_offsets *delta =
-    ((struct section_offsets *) 
-     alloca (SIZEOF_N_SECTION_OFFSETS (objfile->num_sections)));
+  section_offsets delta (objfile->section_offsets.size ());
 
   int something_changed = 0;
 
-  for (int i = 0; i < objfile->num_sections; ++i)
+  for (int i = 0; i < objfile->section_offsets.size (); ++i)
     {
-      delta->offsets[i] =
-       ANOFFSET (new_offsets, i) - ANOFFSET (objfile->section_offsets, i);
-      if (ANOFFSET (delta, i) != 0)
+      delta[i] = new_offsets[i] - objfile->section_offsets[i];
+      if (delta[i] != 0)
        something_changed = 1;
     }
   if (!something_changed)
@@ -681,9 +678,7 @@ objfile_relocate1 (struct objfile *objfile,
            if (l)
              {
                for (int i = 0; i < l->nitems; ++i)
-                 l->item[i].pc += ANOFFSET (delta,
-                                            COMPUNIT_BLOCK_LINE_SECTION
-                                            (cust));
+                 l->item[i].pc += delta[COMPUNIT_BLOCK_LINE_SECTION (cust)];
              }
          }
       }
@@ -694,8 +689,7 @@ objfile_relocate1 (struct objfile *objfile,
        int block_line_section = COMPUNIT_BLOCK_LINE_SECTION (cust);
 
        if (BLOCKVECTOR_MAP (bv))
-         addrmap_relocate (BLOCKVECTOR_MAP (bv),
-                           ANOFFSET (delta, block_line_section));
+         addrmap_relocate (BLOCKVECTOR_MAP (bv), delta[block_line_section]);
 
        for (int i = 0; i < BLOCKVECTOR_NBLOCKS (bv); ++i)
          {
@@ -704,16 +698,14 @@ objfile_relocate1 (struct objfile *objfile,
            struct mdict_iterator miter;
 
            b = BLOCKVECTOR_BLOCK (bv, i);
-           BLOCK_START (b) += ANOFFSET (delta, block_line_section);
-           BLOCK_END (b) += ANOFFSET (delta, block_line_section);
+           BLOCK_START (b) += delta[block_line_section];
+           BLOCK_END (b) += delta[block_line_section];
 
            if (BLOCK_RANGES (b) != nullptr)
              for (int j = 0; j < BLOCK_NRANGES (b); j++)
                {
-                 BLOCK_RANGE_START (b, j)
-                   += ANOFFSET (delta, block_line_section);
-                 BLOCK_RANGE_END (b, j) += ANOFFSET (delta,
-                                                     block_line_section);
+                 BLOCK_RANGE_START (b, j) += delta[block_line_section];
+                 BLOCK_RANGE_END (b, j) += delta[block_line_section];
                }
 
            /* We only want to iterate over the local symbols, not any
@@ -741,8 +733,8 @@ objfile_relocate1 (struct objfile *objfile,
   {
     int i;
 
-    for (i = 0; i < objfile->num_sections; ++i)
-      (objfile->section_offsets)->offsets[i] = ANOFFSET (new_offsets, i);
+    for (i = 0; i < objfile->section_offsets.size (); ++i)
+      objfile->section_offsets[i] = new_offsets[i];
   }
 
   /* Rebuild section map next time we need it.  */
@@ -773,7 +765,7 @@ objfile_relocate1 (struct objfile *objfile,
 
 void
 objfile_relocate (struct objfile *objfile,
-                 const struct section_offsets *new_offsets)
+                 const section_offsets &new_offsets)
 {
   int changed = 0;
 
@@ -792,15 +784,13 @@ objfile_relocate (struct objfile *objfile,
 
       addr_info_make_relative (&objfile_addrs, debug_objfile->obfd);
 
-      gdb_assert (debug_objfile->num_sections
+      gdb_assert (debug_objfile->section_offsets.size ()
                  == gdb_bfd_count_sections (debug_objfile->obfd));
-      std::vector<struct section_offsets>
-       new_debug_offsets (SIZEOF_N_SECTION_OFFSETS (debug_objfile->num_sections));
-      relative_addr_info_to_section_offsets (new_debug_offsets.data (),
-                                            debug_objfile->num_sections,
-                                            objfile_addrs);
+      section_offsets new_debug_offsets
+       (debug_objfile->section_offsets.size ());
+      relative_addr_info_to_section_offsets (new_debug_offsets, objfile_addrs);
 
-      changed |= objfile_relocate1 (debug_objfile, new_debug_offsets.data ());
+      changed |= objfile_relocate1 (debug_objfile, new_debug_offsets);
     }
 
   /* Relocate breakpoints as necessary, after things are relocated.  */
@@ -815,14 +805,7 @@ objfile_relocate (struct objfile *objfile,
 static int
 objfile_rebase1 (struct objfile *objfile, CORE_ADDR slide)
 {
-  struct section_offsets *new_offsets =
-    ((struct section_offsets *)
-     alloca (SIZEOF_N_SECTION_OFFSETS (objfile->num_sections)));
-  int i;
-
-  for (i = 0; i < objfile->num_sections; ++i)
-    new_offsets->offsets[i] = slide;
-
+  section_offsets new_offsets (objfile->section_offsets.size (), slide);
   return objfile_relocate1 (objfile, new_offsets);
 }
 
index 56c7295421707111fda3f6031abc2ff18c442a4a..1301f2c23fd215c64bd35bb9a27707d41a02e96c 100644 (file)
@@ -141,7 +141,7 @@ struct obj_section
 
 /* Relocation offset applied to S.  */
 #define obj_section_offset(s)                                          \
-  (((s)->objfile->section_offsets)->offsets[gdb_bfd_section_index ((s)->objfile->obfd, (s)->the_bfd_section)])
+  (((s)->objfile->section_offsets)[gdb_bfd_section_index ((s)->objfile->obfd, (s)->the_bfd_section)])
 
 /* The memory address of section S (vma + offset).  */
 #define obj_section_addr(s)                                            \
@@ -560,14 +560,12 @@ public:
   /* Set of relocation offsets to apply to each section.
      The table is indexed by the_bfd_section->index, thus it is generally
      as large as the number of sections in the binary.
-     The table is stored on the objfile_obstack.
 
      These offsets indicate that all symbols (including partial and
      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.  */
 
-  struct section_offsets *section_offsets = nullptr;
-  int num_sections = 0;
+  ::section_offsets section_offsets;
 
   /* Indexes in the section_offsets array.  These are initialized by the
      *_symfile_offsets() family of functions (som_symfile_offsets,
@@ -669,7 +667,7 @@ extern void build_objfile_section_table (struct objfile *);
 
 extern void free_objfile_separate_debug (struct objfile *);
 
-extern void objfile_relocate (struct objfile *, const struct section_offsets *);
+extern void objfile_relocate (struct objfile *, const section_offsets &);
 extern void objfile_rebase (struct objfile *, CORE_ADDR);
 
 extern int objfile_has_partial_symbols (struct objfile *objfile);
index cae45188da2090984d21be1a0289f9daa3f5b0e8..e7630050e1803573ca22d4ca0c53bc9be8c30999 100644 (file)
@@ -55,8 +55,7 @@ struct partial_symbol
      the offsets provided in OBJFILE.  */
   CORE_ADDR address (const struct objfile *objfile) const
   {
-    return (ginfo.value.address
-           + ANOFFSET (objfile->section_offsets, ginfo.section));
+    return ginfo.value.address + objfile->section_offsets[ginfo.section];
   }
 
   /* Set the address of this partial symbol.  The address must be
@@ -120,15 +119,13 @@ struct partial_symtab
   /* Return the relocated low text address of this partial_symtab.  */
   CORE_ADDR text_low (struct objfile *objfile) const
   {
-    return m_text_low + ANOFFSET (objfile->section_offsets,
-                                 SECT_OFF_TEXT (objfile));
+    return m_text_low + objfile->section_offsets[SECT_OFF_TEXT (objfile)];
   }
 
   /* Return the relocated high text address of this partial_symtab.  */
   CORE_ADDR text_high (struct objfile *objfile) const
   {
-    return m_text_high + ANOFFSET (objfile->section_offsets,
-                                  SECT_OFF_TEXT (objfile));
+    return m_text_high + objfile->section_offsets[SECT_OFF_TEXT (objfile)];
   }
 
   /* Set the low text address of this partial_symtab.  */
index c835e1e59462871e43d2729f8c989cbb5aafc46c..7caf1c6029a993fc693daf1a625ba31bc75fbd62 100644 (file)
@@ -316,8 +316,7 @@ find_pc_sect_psymtab (struct objfile *objfile, CORE_ADDR pc,
   if (objfile->partial_symtabs->psymtabs != NULL
       && objfile->partial_symtabs->psymtabs_addrmap != NULL)
     {
-      CORE_ADDR baseaddr = ANOFFSET (objfile->section_offsets,
-                                    SECT_OFF_TEXT (objfile));
+      CORE_ADDR baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)];
 
       struct partial_symtab *pst
        = ((struct partial_symtab *)
index 7923be1d2fca294f311a8a93643a3d47e04cb989..082499e6e84644aa3c20d34d6b678f7c343186ae 100644 (file)
@@ -4049,7 +4049,6 @@ remote_target::get_offsets ()
   char *ptr;
   int lose, num_segments = 0, do_sections, do_segments;
   CORE_ADDR text_addr, data_addr, bss_addr, segments[2];
-  struct section_offsets *offs;
   struct symfile_segment_data *data;
 
   if (symfile_objfile == NULL)
@@ -4128,10 +4127,7 @@ remote_target::get_offsets ()
   else if (*ptr != '\0')
     warning (_("Target reported unsupported offsets: %s"), buf);
 
-  offs = ((struct section_offsets *)
-         alloca (SIZEOF_N_SECTION_OFFSETS (symfile_objfile->num_sections)));
-  memcpy (offs, symfile_objfile->section_offsets,
-         SIZEOF_N_SECTION_OFFSETS (symfile_objfile->num_sections));
+  section_offsets offs = symfile_objfile->section_offsets;
 
   data = get_symfile_segment_data (symfile_objfile->obfd);
   do_segments = (data != NULL);
@@ -4184,15 +4180,15 @@ remote_target::get_offsets ()
 
   if (do_sections)
     {
-      offs->offsets[SECT_OFF_TEXT (symfile_objfile)] = text_addr;
+      offs[SECT_OFF_TEXT (symfile_objfile)] = text_addr;
 
       /* This is a temporary kludge to force data and bss to use the
         same offsets because that's what nlmconv does now.  The real
         solution requires changes to the stub and remote.c that I
         don't have time to do right now.  */
 
-      offs->offsets[SECT_OFF_DATA (symfile_objfile)] = data_addr;
-      offs->offsets[SECT_OFF_BSS (symfile_objfile)] = data_addr;
+      offs[SECT_OFF_DATA (symfile_objfile)] = data_addr;
+      offs[SECT_OFF_BSS (symfile_objfile)] = data_addr;
     }
 
   objfile_relocate (symfile_objfile, offs);
index f79f005b0a2eae59e48d1e21f0f7d8ebf5404f76..f44ea937d9479a60380972873df4eaf969c582d6 100644 (file)
@@ -390,19 +390,15 @@ solib_aix_clear_solib (void)
 }
 
 /* Compute and return the OBJFILE's section_offset array, using
-   the associated loader info (INFO).
+   the associated loader info (INFO).  */
 
-   The resulting array is computed on the heap and must be
-   deallocated after use.  */
-
-static gdb::unique_xmalloc_ptr<struct section_offsets>
+static section_offsets
 solib_aix_get_section_offsets (struct objfile *objfile,
                               lm_info_aix *info)
 {
   bfd *abfd = objfile->obfd;
 
-  gdb::unique_xmalloc_ptr<struct section_offsets> offsets
-    (XCNEWVEC (struct section_offsets, objfile->num_sections));
+  section_offsets offsets (objfile->section_offsets.size ());
 
   /* .text */
 
@@ -411,7 +407,7 @@ solib_aix_get_section_offsets (struct objfile *objfile,
       struct bfd_section *sect
        = objfile->sections[objfile->sect_index_text].the_bfd_section;
 
-      offsets->offsets[objfile->sect_index_text]
+      offsets[objfile->sect_index_text]
        = info->text_addr + sect->filepos - bfd_section_vma (sect);
     }
 
@@ -422,7 +418,7 @@ solib_aix_get_section_offsets (struct objfile *objfile,
       struct bfd_section *sect
        = objfile->sections[objfile->sect_index_data].the_bfd_section;
 
-      offsets->offsets[objfile->sect_index_data]
+      offsets[objfile->sect_index_data]
        = info->data_addr - bfd_section_vma (sect);
     }
 
@@ -435,8 +431,8 @@ solib_aix_get_section_offsets (struct objfile *objfile,
   if (objfile->sect_index_bss != -1
       && objfile->sect_index_data != -1)
     {
-      offsets->offsets[objfile->sect_index_bss]
-       = (offsets->offsets[objfile->sect_index_data]
+      offsets[objfile->sect_index_bss]
+       = (offsets[objfile->sect_index_data]
           + solib_aix_bss_data_overlap (abfd));
     }
 
@@ -468,10 +464,10 @@ solib_aix_solib_create_inferior_hook (int from_tty)
   lm_info_aix &exec_info = (*library_list)[0];
   if (symfile_objfile != NULL)
     {
-      gdb::unique_xmalloc_ptr<struct section_offsets> offsets
+      section_offsets offsets
        = solib_aix_get_section_offsets (symfile_objfile, &exec_info);
 
-      objfile_relocate (symfile_objfile, offsets.get ());
+      objfile_relocate (symfile_objfile, offsets);
     }
 }
 
index 96c389c291a01b17cbca24751ded96092101bf42..52fa0e868aacd7746ddd4e3227d3e28d8bb52fc4 100644 (file)
@@ -911,8 +911,7 @@ dsbt_relocate_main_executable (void)
   info->main_executable_lm_info = new lm_info_dsbt;
   info->main_executable_lm_info->map = ldm;
 
-  gdb::unique_xmalloc_ptr<struct section_offsets> new_offsets
-    (XCNEWVEC (struct section_offsets, symfile_objfile->num_sections));
+  section_offsets new_offsets (symfile_objfile->section_offsets.size ());
   changed = 0;
 
   ALL_OBJFILE_OSECTIONS (symfile_objfile, osect)
@@ -926,7 +925,7 @@ dsbt_relocate_main_executable (void)
       /* Current address of section.  */
       addr = obj_section_addr (osect);
       /* Offset from where this section started.  */
-      offset = ANOFFSET (symfile_objfile->section_offsets, osect_idx);
+      offset = symfile_objfile->section_offsets[osect_idx];
       /* Original address prior to any past relocations.  */
       orig_addr = addr - offset;
 
@@ -935,10 +934,10 @@ dsbt_relocate_main_executable (void)
          if (ldm->segs[seg].p_vaddr <= orig_addr
              && orig_addr < ldm->segs[seg].p_vaddr + ldm->segs[seg].p_memsz)
            {
-             new_offsets->offsets[osect_idx]
+             new_offsets[osect_idx]
                = ldm->segs[seg].addr - ldm->segs[seg].p_vaddr;
 
-             if (new_offsets->offsets[osect_idx] != offset)
+             if (new_offsets[osect_idx] != offset)
                changed = 1;
              break;
            }
@@ -946,7 +945,7 @@ dsbt_relocate_main_executable (void)
     }
 
   if (changed)
-    objfile_relocate (symfile_objfile, new_offsets.get ());
+    objfile_relocate (symfile_objfile, new_offsets);
 
   /* Now that symfile_objfile has been relocated, we can compute the
      GOT value and stash it away.  */
index a96bfa049417e4db7fce661a8c85a851d5d4b1fb..10476f6250c94554c7ca6adef4609b34424fb018 100644 (file)
@@ -785,8 +785,7 @@ frv_relocate_main_executable (void)
   main_executable_lm_info = new lm_info_frv;
   main_executable_lm_info->map = ldm;
 
-  gdb::unique_xmalloc_ptr<struct section_offsets> new_offsets
-    (XCNEWVEC (struct section_offsets, symfile_objfile->num_sections));
+  section_offsets new_offsets (symfile_objfile->section_offsets.size ());
   changed = 0;
 
   ALL_OBJFILE_OSECTIONS (symfile_objfile, osect)
@@ -800,7 +799,7 @@ frv_relocate_main_executable (void)
       /* Current address of section.  */
       addr = obj_section_addr (osect);
       /* Offset from where this section started.  */
-      offset = ANOFFSET (symfile_objfile->section_offsets, osect_idx);
+      offset = symfile_objfile->section_offsets[osect_idx];
       /* Original address prior to any past relocations.  */
       orig_addr = addr - offset;
 
@@ -809,10 +808,10 @@ frv_relocate_main_executable (void)
          if (ldm->segs[seg].p_vaddr <= orig_addr
              && orig_addr < ldm->segs[seg].p_vaddr + ldm->segs[seg].p_memsz)
            {
-             new_offsets->offsets[osect_idx]
+             new_offsets[osect_idx]
                = ldm->segs[seg].addr - ldm->segs[seg].p_vaddr;
 
-             if (new_offsets->offsets[osect_idx] != offset)
+             if (new_offsets[osect_idx] != offset)
                changed = 1;
              break;
            }
@@ -820,7 +819,7 @@ frv_relocate_main_executable (void)
     }
 
   if (changed)
-    objfile_relocate (symfile_objfile, new_offsets.get ());
+    objfile_relocate (symfile_objfile, new_offsets);
 
   /* Now that symfile_objfile has been relocated, we can compute the
      GOT value and stash it away.  */
index daf803fb65f2d6778d0db3256f92edaf937b199f..2d275f2b9c077d9b4b5242e359e6909e3347af49 100644 (file)
@@ -2273,8 +2273,7 @@ enable_break (struct svr4_info *info, int from_tty)
          CORE_ADDR load_addr;
 
          tmp_bfd = os->objfile->obfd;
-         load_addr = ANOFFSET (os->objfile->section_offsets,
-                               SECT_OFF_TEXT (os->objfile));
+         load_addr = os->objfile->section_offsets[SECT_OFF_TEXT (os->objfile)];
 
          interp_sect = bfd_get_section_by_name (tmp_bfd, ".text");
          if (interp_sect)
@@ -2975,15 +2974,8 @@ svr4_relocate_main_executable (void)
 
   if (symfile_objfile)
     {
-      struct section_offsets *new_offsets;
-      int i;
-
-      new_offsets = XALLOCAVEC (struct section_offsets,
-                               symfile_objfile->num_sections);
-
-      for (i = 0; i < symfile_objfile->num_sections; i++)
-       new_offsets->offsets[i] = displacement;
-
+      section_offsets new_offsets (symfile_objfile->section_offsets.size (),
+                                  displacement);
       objfile_relocate (symfile_objfile, new_offsets);
     }
   else if (exec_bfd)
index e90107e578256f3ea5a9969e9855f6b5c5e00036..625f0990d109e44c8081115970022ad040c086bf 100644 (file)
@@ -46,7 +46,7 @@ struct lm_info_target : public lm_info_base
 
   /* The cached offsets for each section of this shared library,
      determined from SEGMENT_BASES, or SECTION_BASES.  */
-  gdb::unique_xmalloc_ptr<section_offsets> offsets;
+  section_offsets offsets;
 };
 
 typedef std::vector<std::unique_ptr<lm_info_target>> lm_info_vector;
@@ -305,12 +305,11 @@ solib_target_relocate_section_addresses (struct so_list *so,
 
   /* Build the offset table only once per object file.  We can not do
      it any earlier, since we need to open the file first.  */
-  if (li->offsets == NULL)
+  if (li->offsets.empty ())
     {
       int num_sections = gdb_bfd_count_sections (so->abfd);
 
-      li->offsets.reset ((struct section_offsets *)
-                        xzalloc (SIZEOF_N_SECTION_OFFSETS (num_sections)));
+      li->offsets.assign (num_sections, 0);
 
       if (!li->section_bases.empty ())
        {
@@ -355,7 +354,7 @@ Could not relocate shared library \"%s\": wrong number of ALLOC sections"),
                      gdb_assert (so->addr_low <= so->addr_high);
                      found_range = 1;
                    }
-                 li->offsets->offsets[i] = li->section_bases[bases_index];
+                 li->offsets[i] = li->section_bases[bases_index];
                  bases_index++;
                }
              if (!found_range)
@@ -377,7 +376,7 @@ Could not relocate shared library \"%s\": no segments"), so->so_name);
              int i;
 
              if (!symfile_map_offsets_to_segments (so->abfd, data,
-                                                   li->offsets.get (),
+                                                   li->offsets,
                                                    li->segment_bases.size (),
                                                    li->segment_bases.data ()))
                warning (_("\
@@ -414,9 +413,8 @@ Could not relocate shared library \"%s\": bad offsets"), so->so_name);
        }
     }
 
-  offset = li->offsets->offsets[gdb_bfd_section_index
-                               (sec->the_bfd_section->owner,
-                                sec->the_bfd_section)];
+  offset = li->offsets[gdb_bfd_section_index (sec->the_bfd_section->owner,
+                                             sec->the_bfd_section)];
   sec->addr += offset;
   sec->endaddr += offset;
 }
index 181b29133aca604f2280bfde142dca76ba9de427..aa52a98e72d91804047fa2a9d89f221abfa60714 100644 (file)
@@ -178,7 +178,7 @@ extern struct partial_symtab *dbx_end_psymtab
    int textlow_not_set);
 
 extern void process_one_symbol (int, int, CORE_ADDR, const char *,
-                               const struct section_offsets *,
+                               const section_offsets &,
                                struct objfile *, enum language);
 
 extern void elfstab_build_psymtabs (struct objfile *objfile,
index 39da2900e7af30d0c24702019c8b835038b0b646..5e9a043ffebaf9ec933630fdb7c0a2ff84c3bff3 100644 (file)
@@ -1290,8 +1290,7 @@ stap_probe::parse_arguments (struct gdbarch *gdbarch)
 static CORE_ADDR
 relocate_address (CORE_ADDR address, struct objfile *objfile)
 {
-  return address + ANOFFSET (objfile->section_offsets,
-                            SECT_OFF_DATA (objfile));
+  return address + objfile->section_offsets[SECT_OFF_DATA (objfile)];
 }
 
 /* Implementation of the get_relocated_address method.  */
index 86d61741079bfcc556147fff019ab93a43c61530..0285f8fc34c1d4fa47dacf4370c45ef38a54e4cf 100644 (file)
@@ -269,7 +269,7 @@ build_section_addr_info_from_objfile (const struct objfile *objfile)
     {
       int sectindex = sap[i].sectindex;
 
-      sap[i].addr += objfile->section_offsets->offsets[sectindex];
+      sap[i].addr += objfile->section_offsets[sectindex];
     }
   return sap;
 }
@@ -315,14 +315,14 @@ init_objfile_sect_indices (struct objfile *objfile)
      later, e.g. by the remote qOffsets packet, and then this will
      be wrong!  That's why we try segments first.  */
 
-  for (i = 0; i < objfile->num_sections; i++)
+  for (i = 0; i < objfile->section_offsets.size (); i++)
     {
-      if (ANOFFSET (objfile->section_offsets, i) != 0)
+      if (objfile->section_offsets[i] != 0)
        {
          break;
        }
     }
-  if (i == objfile->num_sections)
+  if (i == objfile->section_offsets.size ())
     {
       if (objfile->sect_index_text == -1)
        objfile->sect_index_text = 0;
@@ -339,7 +339,7 @@ init_objfile_sect_indices (struct objfile *objfile)
 
 struct place_section_arg
 {
-  struct section_offsets *offsets;
+  section_offsets *offsets;
   CORE_ADDR lowest;
 };
 
@@ -350,7 +350,8 @@ static void
 place_section (bfd *abfd, asection *sect, void *obj)
 {
   struct place_section_arg *arg = (struct place_section_arg *) obj;
-  CORE_ADDR *offsets = arg->offsets->offsets, start_addr;
+  section_offsets &offsets = *arg->offsets;
+  CORE_ADDR start_addr;
   int done;
   ULONGEST align = ((ULONGEST) 1) << bfd_section_alignment (sect);
 
@@ -408,17 +409,15 @@ place_section (bfd *abfd, asection *sect, void *obj)
 }
 
 /* Store section_addr_info as prepared (made relative and with SECTINDEX
-   filled-in) by addr_info_make_relative into SECTION_OFFSETS of NUM_SECTIONS
-   entries.  */
+   filled-in) by addr_info_make_relative into SECTION_OFFSETS.  */
 
 void
-relative_addr_info_to_section_offsets (struct section_offsets *section_offsets,
-                                      int num_sections,
+relative_addr_info_to_section_offsets (section_offsets &section_offsets,
                                       const section_addr_info &addrs)
 {
   int i;
 
-  memset (section_offsets, 0, SIZEOF_N_SECTION_OFFSETS (num_sections));
+  section_offsets.assign (section_offsets.size (), 0);
 
   /* Now calculate offsets for section that were specified by the caller.  */
   for (i = 0; i < addrs.size (); i++)
@@ -432,7 +431,7 @@ relative_addr_info_to_section_offsets (struct section_offsets *section_offsets,
       /* Record all sections in offsets.  */
       /* The section_offsets in the objfile are here filled in using
          the BFD index.  */
-      section_offsets->offsets[osp->sectindex] = osp->addr;
+      section_offsets[osp->sectindex] = osp->addr;
     }
 }
 
@@ -636,12 +635,8 @@ void
 default_symfile_offsets (struct objfile *objfile,
                         const section_addr_info &addrs)
 {
-  objfile->num_sections = gdb_bfd_count_sections (objfile->obfd);
-  objfile->section_offsets = (struct section_offsets *)
-    obstack_alloc (&objfile->objfile_obstack,
-                  SIZEOF_N_SECTION_OFFSETS (objfile->num_sections));
-  relative_addr_info_to_section_offsets (objfile->section_offsets,
-                                        objfile->num_sections, addrs);
+  objfile->section_offsets.resize (gdb_bfd_count_sections (objfile->obfd));
+  relative_addr_info_to_section_offsets (objfile->section_offsets, addrs);
 
   /* For relocatable files, all loadable sections will start at zero.
      The zero is meaningless, so try to pick arbitrary addresses such
@@ -662,11 +657,11 @@ default_symfile_offsets (struct objfile *objfile,
 
       if (cur_sec == NULL)
        {
-         CORE_ADDR *offsets = objfile->section_offsets->offsets;
+         section_offsets &offsets = objfile->section_offsets;
 
          /* Pick non-overlapping offsets for sections the user did not
             place explicitly.  */
-         arg.offsets = objfile->section_offsets;
+         arg.offsets = &objfile->section_offsets;
          arg.lowest = 0;
          bfd_map_over_sections (objfile->obfd, place_section, &arg);
 
@@ -902,7 +897,7 @@ init_entry_point_info (struct objfile *objfile)
    (as gleaned by GDB's shared library code).  We convert each address
    into an offset from the section VMA's as it appears in the object
    file, and then call the file's sym_offsets function to convert this
-   into a format-specific offset table --- a `struct section_offsets'.
+   into a format-specific offset table --- a `section_offsets'.
    The sectindex field is used to control the ordering of sections
    with the same name.  Upon return, it is updated to contain the
    corresponding BFD section index, or -1 if the section was not found.
@@ -926,13 +921,8 @@ syms_from_objfile_1 (struct objfile *objfile,
       /* No symbols to load, but we still need to make sure
         that the section_offsets table is allocated.  */
       int num_sections = gdb_bfd_count_sections (objfile->obfd);
-      size_t size = SIZEOF_N_SECTION_OFFSETS (num_sections);
 
-      objfile->num_sections = num_sections;
-      objfile->section_offsets
-       = (struct section_offsets *) obstack_alloc (&objfile->objfile_obstack,
-                                                   size);
-      memset (objfile->section_offsets, 0, size);
+      objfile->section_offsets.assign (num_sections, 0);
       return;
     }
 
@@ -2164,8 +2154,7 @@ set_objfile_default_section_offset (struct objfile *objf,
                                    CORE_ADDR offset)
 {
   /* Add OFFSET to all sections by default.  */
-  std::vector<struct section_offsets> offsets (objf->num_sections,
-                                              { { offset } });
+  section_offsets offsets (objf->section_offsets.size (), offset);
 
   /* Create sorted lists of all sections in ADDRS as well as all
      sections in OBJF.  */
@@ -2203,11 +2192,11 @@ set_objfile_default_section_offset (struct objfile *objf,
        }
 
       if (cmp == 0)
-       offsets[objf_sect->sectindex].offsets[0] = 0;
+       offsets[objf_sect->sectindex] = 0;
     }
 
   /* Apply the new section offsets.  */
-  objfile_relocate (objf, offsets.data ());
+  objfile_relocate (objf, offsets);
 }
 
 /* This function allows the addition of incrementally linked object files.
@@ -2479,9 +2468,6 @@ reread_symbols (void)
       new_modtime = new_statbuf.st_mtime;
       if (new_modtime != objfile->mtime)
        {
-         struct section_offsets *offsets;
-         int num_offsets;
-
          printf_filtered (_("`%s' has changed; re-reading symbols.\n"),
                           objfile_name (objfile));
 
@@ -2556,14 +2542,6 @@ reread_symbols (void)
            error (_("Can't read symbols from %s: %s."), objfile_name (objfile),
                   bfd_errmsg (bfd_get_error ()));
 
-         /* Save the offsets, we will nuke them with the rest of the
-            objfile_obstack.  */
-         num_offsets = objfile->num_sections;
-         offsets = ((struct section_offsets *)
-                    alloca (SIZEOF_N_SECTION_OFFSETS (num_offsets)));
-         memcpy (offsets, objfile->section_offsets,
-                 SIZEOF_N_SECTION_OFFSETS (num_offsets));
-
          objfile->reset_psymtabs ();
 
          /* NB: after this call to obstack_free, objfiles_changed
@@ -2595,15 +2573,6 @@ reread_symbols (void)
 
          build_objfile_section_table (objfile);
 
-         /* We use the same section offsets as from last time.  I'm not
-            sure whether that is always correct for shared libraries.  */
-         objfile->section_offsets = (struct section_offsets *)
-           obstack_alloc (&objfile->objfile_obstack,
-                          SIZEOF_N_SECTION_OFFSETS (num_offsets));
-         memcpy (objfile->section_offsets, offsets,
-                 SIZEOF_N_SECTION_OFFSETS (num_offsets));
-         objfile->num_sections = num_offsets;
-
          /* What the hell is sym_new_init for, anyway?  The concept of
             distinguishing between the main file and additional files
             in this way seems rather dubious.  */
@@ -3705,7 +3674,7 @@ free_symfile_segment_data (struct symfile_segment_data *data)
 int
 symfile_map_offsets_to_segments (bfd *abfd,
                                 const struct symfile_segment_data *data,
-                                struct section_offsets *offsets,
+                                section_offsets &offsets,
                                 int num_segment_bases,
                                 const CORE_ADDR *segment_bases)
 {
@@ -3737,8 +3706,7 @@ symfile_map_offsets_to_segments (bfd *abfd,
       if (which > num_segment_bases)
         which = num_segment_bases;
 
-      offsets->offsets[i] = (segment_bases[which - 1]
-                             - data->segment_bases[which - 1]);
+      offsets[i] = segment_bases[which - 1] - data->segment_bases[which - 1];
     }
 
   return 1;
index 17e02a9da843a3d4e26f9db2c6d2caf21c34c733..5b349752d5091a05dd78dda0a53a70c777a474a4 100644 (file)
@@ -373,8 +373,7 @@ extern section_addr_info
   build_section_addr_info_from_objfile (const struct objfile *objfile);
 
 extern void relative_addr_info_to_section_offsets
-  (struct section_offsets *section_offsets, int num_sections,
-   const section_addr_info &addrs);
+  (section_offsets &section_offsets, const section_addr_info &addrs);
 
 extern void addr_info_make_relative (section_addr_info *addrs,
                                     bfd *abfd);
@@ -515,7 +514,7 @@ extern bfd_byte *symfile_relocate_debug_section (struct objfile *, asection *,
 
 extern int symfile_map_offsets_to_segments (bfd *,
                                            const struct symfile_segment_data *,
-                                           struct section_offsets *,
+                                           section_offsets &,
                                            int, const CORE_ADDR *);
 struct symfile_segment_data *get_symfile_segment_data (bfd *abfd);
 void free_symfile_segment_data (struct symfile_segment_data *data);
index b6f1a986ca34dec05bbbe9bd77bf13e7cd0d4879..a5b17ffa3810e4c8a6b5440178515b651421e611 100644 (file)
@@ -240,8 +240,7 @@ dump_msymbols (struct objfile *objfile, struct ui_file *outfile)
       /* Use the relocated address as shown in the symbol here -- do
         not try to respect copy relocations.  */
       CORE_ADDR addr = (msymbol->value.address
-                       + ANOFFSET (objfile->section_offsets,
-                                   msymbol->section));
+                       + objfile->section_offsets[msymbol->section]);
       fputs_filtered (paddress (gdbarch, addr), outfile);
       fprintf_filtered (outfile, " %s", msymbol->linkage_name ());
       if (section)
index 88b8faedb5910da843f70c240ef0841d857870cb..5274b88f7ab538fe1d918c40b5021d46a94de557 100644 (file)
@@ -1687,11 +1687,10 @@ fixup_section (struct general_symbol_info *ginfo,
 
         So, instead, search the section table when lookup by name has
         failed.  The ``addr'' and ``endaddr'' fields may have already
-        been relocated.  If so, the relocation offset (i.e. the
-        ANOFFSET value) needs to be subtracted from these values when
-        performing the comparison.  We unconditionally subtract it,
-        because, when no relocation has been performed, the ANOFFSET
-        value will simply be zero.
+        been relocated.  If so, the relocation offset needs to be
+        subtracted from these values when performing the comparison.
+        We unconditionally subtract it, because, when no relocation
+        has been performed, the value will simply be zero.
 
         The address of the symbol whose section we're fixing up HAS
         NOT BEEN adjusted (relocated) yet.  It can't have been since
@@ -1717,7 +1716,7 @@ fixup_section (struct general_symbol_info *ginfo,
       ALL_OBJFILE_OSECTIONS (objfile, s)
        {
          int idx = s - objfile->sections;
-         CORE_ADDR offset = ANOFFSET (objfile->section_offsets, idx);
+         CORE_ADDR offset = objfile->section_offsets[idx];
 
          if (fallback == -1)
            fallback = idx;
@@ -6373,8 +6372,7 @@ get_msymbol_address (struct objfile *objf, const struct minimal_symbol *minsym)
            return BMSYMBOL_VALUE_ADDRESS (found);
        }
     }
-  return (minsym->value.address
-         + ANOFFSET (objf->section_offsets, minsym->section));
+  return minsym->value.address + objf->section_offsets[minsym->section];
 }
 
 \f
index d84ac5ca6829aa3164b1384e74d7d542a084e845..5fa067b5f48d921b70e2404ee9643297fe81e25f 100644 (file)
@@ -726,7 +726,7 @@ extern CORE_ADDR get_msymbol_address (struct objfile *objf,
 #define MSYMBOL_VALUE_ADDRESS(objfile, symbol)                         \
   (((symbol)->maybe_copied) ? get_msymbol_address (objfile, symbol)    \
    : ((symbol)->value.address                                          \
-      + ANOFFSET ((objfile)->section_offsets, ((symbol)->section))))
+      + (objfile)->section_offsets[(symbol)->section]))
 /* For a bound minsym, we can easily compute the address directly.  */
 #define BMSYMBOL_VALUE_ADDRESS(symbol) \
   MSYMBOL_VALUE_ADDRESS ((symbol).objfile, (symbol).minsym)
@@ -1309,30 +1309,11 @@ struct linetable
 };
 
 /* How to relocate the symbols from each section in a symbol file.
-   Each struct contains an array of offsets.
    The ordering and meaning of the offsets is file-type-dependent;
    typically it is indexed by section numbers or symbol types or
-   something like that.
+   something like that.  */
 
-   To give us flexibility in changing the internal representation
-   of these offsets, the ANOFFSET macro must be used to insert and
-   extract offset values in the struct.  */
-
-struct section_offsets
-{
-  CORE_ADDR offsets[1];                /* As many as needed.  */
-};
-
-#define        ANOFFSET(secoff, whichone) \
-  ((whichone == -1)                      \
-   ? (internal_error (__FILE__, __LINE__, \
-                     _("Section index is uninitialized")), -1) \
-   : secoff->offsets[whichone])
-
-/* The size of a section_offsets table for N sections.  */
-#define SIZEOF_N_SECTION_OFFSETS(n) \
-  (sizeof (struct section_offsets) \
-   + sizeof (((struct section_offsets *) 0)->offsets) * ((n)-1))
+typedef std::vector<CORE_ADDR> section_offsets;
 
 /* Each source file or header is represented by a struct symtab.
    The name "symtab" is historical, another name for it is "filetab".
index 6985a43d388042ea71b79ef5230a490917df0da0..d0fa90e49fb6b670fd1f49fbc5656a14488c853d 100644 (file)
@@ -864,7 +864,7 @@ enter_line_range (struct subfile *subfile, unsigned beginoffset,
       addr = (int_lnno.l_lnno
              ? int_lnno.l_addr.l_paddr
              : read_symbol_nvalue (int_lnno.l_addr.l_symndx));
-      addr += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
+      addr += objfile->section_offsets[SECT_OFF_TEXT (objfile)];
 
       if (addr < startaddr || (endaddr && addr >= endaddr))
        return;
@@ -1232,8 +1232,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
                        }
 
                      file_start_addr =
-                       cs->c_value + ANOFFSET (objfile->section_offsets,
-                                               SECT_OFF_TEXT (objfile));
+                       cs->c_value + objfile->section_offsets[SECT_OFF_TEXT (objfile)];
                      file_end_addr = file_start_addr + CSECT_LEN (&main_aux);
 
                      if (cs->c_name && (cs->c_name[0] == '.' || cs->c_name[0] == '@'))
@@ -1355,8 +1354,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
        case C_FCN:
          if (strcmp (cs->c_name, ".bf") == 0)
            {
-             CORE_ADDR off = ANOFFSET (objfile->section_offsets,
-                                       SECT_OFF_TEXT (objfile));
+             CORE_ADDR off = objfile->section_offsets[SECT_OFF_TEXT (objfile)];
 
              bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type, cs->c_sclass,
                                    0, cs->c_naux, &main_aux);
@@ -1400,8 +1398,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
                            NULL, cstk.start_addr,
                            (fcn_cs_saved.c_value
                             + fcn_aux_saved.x_sym.x_misc.x_fsize
-                            + ANOFFSET (objfile->section_offsets,
-                                        SECT_OFF_TEXT (objfile))));
+                            + objfile->section_offsets[SECT_OFF_TEXT (objfile)]));
              within_function = 0;
            }
          break;
@@ -1468,8 +1465,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
              depth++;
              newobj = push_context (depth,
                                  (cs->c_value
-                                  + ANOFFSET (objfile->section_offsets,
-                                              SECT_OFF_TEXT (objfile))));
+                                  + objfile->section_offsets[SECT_OFF_TEXT (objfile)]));
            }
          else if (strcmp (cs->c_name, ".eb") == 0)
            {
@@ -1491,8 +1487,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
                                cstk.old_blocks, NULL,
                                cstk.start_addr,
                                (cs->c_value
-                                + ANOFFSET (objfile->section_offsets,
-                                            SECT_OFF_TEXT (objfile))));
+                                + objfile->section_offsets[SECT_OFF_TEXT (objfile)]));
                }
              *get_local_symbols () = cstk.locals;
            }
@@ -1554,7 +1549,7 @@ process_xcoff_symbol (struct coff_symbol *cs, struct objfile *objfile)
   else
     {
       sec = secnum_to_section (cs->c_secnum, objfile);
-      off = ANOFFSET (objfile->section_offsets, sec);
+      off = objfile->section_offsets[sec];
     }
 
   name = cs->c_name;
@@ -1657,8 +1652,7 @@ process_xcoff_symbol (struct coff_symbol *cs, struct objfile *objfile)
          if (*pp == 'V' && !within_function)
            *pp = 'S';
          sym = define_symbol ((cs->c_value
-                               + ANOFFSET (objfile->section_offsets,
-                                           static_block_section)),
+                               + objfile->section_offsets[static_block_section]),
                               cs->c_name, 0, 0, objfile);
          if (sym != NULL)
            {
@@ -3024,7 +3018,7 @@ xcoff_symfile_offsets (struct objfile *objfile,
      us to test whether the associated section exists or not, and then
      access it quickly (without searching it again).  */
 
-  if (objfile->num_sections == 0)
+  if (objfile->section_offsets.empty ())
     return; /* Is that even possible?  Better safe than sorry.  */
 
   first_section_name = bfd_section_name (objfile->sections[0].the_bfd_section);
index 220b9f4c5f98423b7bbe4b808e91036634d4a33b..011943d55a8ded64d63094e1836b3f79bd062168 100644 (file)
@@ -1,3 +1,15 @@
+2020-01-08  Alan Modra  <amodra@gmail.com>
+
+       * z8k-dis.c: Include libiberty.h
+       (instr_data_s): Make max_fetched unsigned.
+       (z8k_lookup_instr): Make nibl_index and tabl_index unsigned.
+       Don't exceed byte_info bounds.
+       (output_instr): Make num_bytes unsigned.
+       (unpack_instr): Likewise for nibl_count and loop.
+       * z8kgen.c (gas <opcode_entry_type>): Make noperands, length and
+       idx unsigned.
+       * z8k-opc.h: Regenerate.
+
 2020-01-07  Shahab Vahedi  <shahab@synopsys.com>
 
        * arc-tbl.h (llock): Use 'LLOCK' as class.
index 7cd59d868147b0251c0979717623724387188bd4..cb871decfaba7033f601b5b347171db068940135 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "sysdep.h"
 #include "disassemble.h"
+#include "libiberty.h"
 
 #define DEFINE_TABLE
 #include "z8k-opc.h"
@@ -35,7 +36,7 @@ typedef struct
   unsigned short words[24];
 
   /* Nibble number of first word not yet fetched.  */
-  int max_fetched;
+  unsigned int max_fetched;
   bfd_vma insn_start;
   OPCODES_SIGJMP_BUF bailout;
 
@@ -189,7 +190,7 @@ print_insn_z8002 (bfd_vma addr, disassemble_info *info)
 int
 z8k_lookup_instr (unsigned char *nibbles, disassemble_info *info)
 {
-  int nibl_index, tabl_index;
+  unsigned int nibl_index, tabl_index;
   int nibl_matched;
   int need_fetch = 0;
   unsigned short instr_nibl;
@@ -202,7 +203,9 @@ z8k_lookup_instr (unsigned char *nibbles, disassemble_info *info)
     {
       nibl_matched = 1;
       for (nibl_index = 0;
-          nibl_index < z8k_table[tabl_index].length * 2 && nibl_matched;
+          nibl_matched
+            && nibl_index < ARRAY_SIZE (z8k_table[0].byte_info)
+            && nibl_index < z8k_table[tabl_index].length * 2;
           nibl_index++)
        {
          if ((nibl_index % 4) == 0)
@@ -281,7 +284,7 @@ output_instr (instr_data_s *instr_data,
               unsigned long addr ATTRIBUTE_UNUSED,
               disassemble_info *info)
 {
-  int num_bytes;
+  unsigned int num_bytes;
   char out_str[100];
 
   out_str[0] = 0;
@@ -297,7 +300,7 @@ output_instr (instr_data_s *instr_data,
 static void
 unpack_instr (instr_data_s *instr_data, int is_segmented, disassemble_info *info)
 {
-  int nibl_count, loop;
+  unsigned int nibl_count, loop;
   unsigned short instr_nibl, instr_byte, instr_word;
   long instr_long;
   unsigned int tabl_datum, datum_class;
index 68c4ad4800d989c3081949eaf49bfadcb3626353..35ce4bc655e030cf9db0efed7dfb313ee34e55d2 100644 (file)
@@ -292,9 +292,9 @@ typedef struct {
   void (*func) (void);
   unsigned int arg_info[4];
   unsigned int byte_info[10];
-  int noperands;
-  int length;
-  int idx;
+  unsigned int noperands;
+  unsigned int length;
+  unsigned int idx;
 } opcode_entry_type;
 
 #ifdef DEFINE_TABLE
index a1b74ca4f37ae5b783171a702907ed395e99435a..b72fcffa35721c2c40856bb889c60d53b45efff0 100644 (file)
@@ -1290,9 +1290,9 @@ gas (void)
   printf ("  void (*func) (void);\n");
   printf ("  unsigned int arg_info[4];\n");
   printf ("  unsigned int byte_info[%d];\n", BYTE_INFO_LEN);
-  printf ("  int noperands;\n");
-  printf ("  int length;\n");
-  printf ("  int idx;\n");
+  printf ("  unsigned int noperands;\n");
+  printf ("  unsigned int length;\n");
+  printf ("  unsigned int idx;\n");
   printf ("} opcode_entry_type;\n\n");
   printf ("#ifdef DEFINE_TABLE\n");
   printf ("const opcode_entry_type z8k_table[] = {\n");
This page took 0.074483 seconds and 4 git commands to generate.