+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
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;
/* 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)
{
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
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@
+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.
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;
md_begin (void)
{
const opcode_entry_type *opcode;
- int idx = -1;
+ unsigned int idx = -1u;
opcode_hash_control = hash_new ();
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)
{
* 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.
* 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}
@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
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
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
@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
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
}
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.
--- /dev/null
+#name: defining a section with the same name as a symbol
+#error_output: pr14891.l
--- /dev/null
+[^:]*: Assembler messages:
+[^:]*:3: Error: section name 'foo' already defined as another symbol
+[^:]*:6: Error: symbol `bar' is already defined
--- /dev/null
+
+foo:
+.section foo, "a"
+
+.section bar, "a"
+bar:
+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:
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.
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);
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;
}
|| 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)
{
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;
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)
}
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);
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));
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));
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;
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. */
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. */
/* 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++)
{
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 §ion_offsets = objfile->section_offsets;
dbxread_objfile = objfile;
void
process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
- const struct section_offsets *section_offsets,
+ const section_offsets §ion_offsets,
struct objfile *objfile, enum language language)
{
struct gdbarch *gdbarch = get_objfile_arch (objfile);
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;
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:
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;
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;
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;
}
}
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.
/* 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
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. */
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;
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)
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. */
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)
{
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);
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)
/* 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);
/* 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)
{
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));
}
}
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
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;
/* 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,
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. */
default:
break;
}
-
- xfree (built_actual_name);
}
/* Read a partial die corresponding to a namespace; also, add a symbol
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)
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;
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 ());
}
}
}
{
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;
SYMBOL_TYPE (sym) = type;
add_symbol_to_list (sym, cu->get_builder ()->get_global_symbols ());
-
- xfree (package_name);
}
}
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 ();
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);
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);
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;
}
}
}
- baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
+ baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)];
name = dwarf2_name (die, 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
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)
}
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)
{
}
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)
{
{
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;
{
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;
{
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 ());
}
}
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));
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 */
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);
break;
}
- xfree (cur_attrs);
return abbrev_table;
}
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;
}
|| 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);
}
}
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;
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.
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
&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;
}
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)
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;
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;
}
}
|| 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;
}
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;
/* 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. */
!= 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
{
/* 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 == ' ')
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);
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);
}
/* Just complain. */
dwarf2_macro_malformed_definition_complaint (body);
- xfree (name);
{
int i;
{
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
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;
}
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));
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)
{
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
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 §ion_offsets, struct objfile *objfile)
{
struct gdbarch *gdbarch = get_objfile_arch (objfile);
const bfd_size_type external_sym_size = debug_swap->external_sym_size;
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;
}
/* 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.
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 §ion_offsets,
struct objfile *objfile)
{
union aux_ext *ax;
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 §ion_offsets = objfile->section_offsets;
if (pst->readin)
return;
&& 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 ();
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));
}
static void
read_alphacoff_dynamic_symtab (minimal_symbol_reader &,
- struct section_offsets *,
struct objfile *objfile);
/* Initialize anything that needs initializing when a completely new
/* 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. */
static void
read_alphacoff_dynamic_symtab (minimal_symbol_reader &reader,
- struct section_offsets *section_offsets,
struct objfile *objfile)
{
bfd *abfd = objfile->obfd;
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;
}
static void
relocate_one_symbol (struct symbol *sym, struct objfile *objfile,
- struct section_offsets *delta)
+ const section_offsets &delta)
{
fixup_symbol_section (sym, objfile);
{
SET_SYMBOL_VALUE_ADDRESS (sym,
SYMBOL_VALUE_ADDRESS (sym)
- + ANOFFSET (delta, SYMBOL_SECTION (sym)));
+ + delta[SYMBOL_SECTION (sym)]);
}
}
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)
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)];
}
}
}
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)
{
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
{
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. */
void
objfile_relocate (struct objfile *objfile,
- const struct section_offsets *new_offsets)
+ const section_offsets &new_offsets)
{
int changed = 0;
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. */
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);
}
/* 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) \
/* 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,
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);
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
/* 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. */
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 *)
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)
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);
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);
}
/* 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 */
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);
}
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);
}
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));
}
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);
}
}
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)
/* 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;
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;
}
}
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. */
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)
/* 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;
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;
}
}
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. */
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)
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)
/* 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;
/* 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 ())
{
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)
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 (_("\
}
}
- 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;
}
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,
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. */
{
int sectindex = sap[i].sectindex;
- sap[i].addr += objfile->section_offsets->offsets[sectindex];
+ sap[i].addr += objfile->section_offsets[sectindex];
}
return sap;
}
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;
struct place_section_arg
{
- struct section_offsets *offsets;
+ section_offsets *offsets;
CORE_ADDR lowest;
};
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);
}
/* 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 §ion_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++)
/* 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;
}
}
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
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);
(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.
/* 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;
}
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. */
}
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.
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));
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
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. */
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)
{
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;
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 §ion_offsets, const section_addr_info &addrs);
extern void addr_info_make_relative (section_addr_info *addrs,
bfd *abfd);
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);
/* 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)
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
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;
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
#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)
};
/* 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".
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;
}
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] == '@'))
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);
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;
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)
{
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;
}
else
{
sec = secnum_to_section (cs->c_secnum, objfile);
- off = ANOFFSET (objfile->section_offsets, sec);
+ off = objfile->section_offsets[sec];
}
name = cs->c_name;
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)
{
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);
+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.
#include "sysdep.h"
#include "disassemble.h"
+#include "libiberty.h"
#define DEFINE_TABLE
#include "z8k-opc.h"
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;
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;
{
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)
unsigned long addr ATTRIBUTE_UNUSED,
disassemble_info *info)
{
- int num_bytes;
+ unsigned int num_bytes;
char out_str[100];
out_str[0] = 0;
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;
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
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");