+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.
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)
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);
const char *actual_name = NULL;
CORE_ADDR baseaddr;
- baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
+ baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)];
gdb::unique_xmalloc_ptr<char> built_actual_name
= partial_die_full_name (pdi, cu);
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)
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 ();
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);
}
}
- 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;
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;
&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)
!= 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
{
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);