gdb: introduce objfile text_section_offset and data_section_offset methods

The pattern

  objfile->section_offsets[SECT_OFF_TEXT (objfile)]

... appears very often, to get the offset of the text section of an
objfile.  I thought it would be more readable to write it as:

  objfile->text_section_offset ()

... so I added this method and used it where possible.  I also added
data_section_offset, although it is not used as much.

gdb/ChangeLog:

	* objfiles.h (ALL_OBJFILE_OSECTIONS): Move up.
	(SECT_OFF_DATA): Likewise.
	(SECT_OFF_RODATA): Likewise.
	(SECT_OFF_TEXT): Likewise.
	(SECT_OFF_BSS): Likewise.
	(struct objfile) <text_section_offset, data_section_offset>: New
	methods.
	* amd64-windows-tdep.c (amd64_windows_find_unwind_info): Use
	objfile::text_section_offset.
	* coff-pe-read.c (add_pe_forwarded_sym): Likewise.
	* coffread.c (coff_symtab_read): Likewise.
	(enter_linenos): Likewise.
	(process_coff_symbol): Likewise.
	* ctfread.c (get_objfile_text_range): Likewise.
	* dtrace-probe.c (dtrace_probe::get_relocated_address):
	Use objfile::data_section_offset.
	* dwarf2-frame.c (execute_cfa_program): Use
	objfile::text_section_offset.
	(dwarf2_frame_find_fde): Likewise.
	* dwarf2read.c (create_addrmap_from_index): Likewise.
	(create_addrmap_from_aranges): Likewise.
	(dw2_find_pc_sect_compunit_symtab): Likewise.
	(process_psymtab_comp_unit_reader): Likewise.
	(add_partial_symbol): Likewise.
	(add_partial_subprogram): Likewise.
	(process_full_comp_unit): Likewise.
	(read_file_scope): Likewise.
	(read_func_scope): Likewise.
	(read_lexical_block_scope): Likewise.
	(read_call_site_scope): Likewise.
	(dwarf2_rnglists_process): Likewise.
	(dwarf2_ranges_process): Likewise.
	(dwarf2_ranges_read): Likewise.
	(dwarf_decode_lines_1): Likewise.
	(new_symbol): Likewise.
	(dwarf2_fetch_die_loc_sect_off): Likewise.
	(dwarf2_per_cu_text_offset): Likewise.
	* hppa-bsd-tdep.c (hppabsd_find_global_pointer): Likewise.
	* hppa-tdep.c (read_unwind_info): Likewise.
	* ia64-tdep.c (ia64_find_unwind_table): Likewise.
	* psympriv.h (struct partial_symtab): Likewise.
	* psymtab.c (find_pc_sect_psymtab): Likewise.
	* solib-svr4.c (enable_break): Likewise.
	* stap-probe.c (relocate_address): Use
	objfile::data_section_offset.
	* xcoffread.c (enter_line_range): Use
	objfile::text_section_offset.
	(read_xcoff_symtab): Likewise.
This commit is contained in:
Simon Marchi 2020-01-23 17:55:35 -05:00 committed by Simon Marchi
parent ab53f38262
commit b3b3bada0d
17 changed files with 135 additions and 82 deletions

View File

@ -1,3 +1,54 @@
2020-01-23 Simon Marchi <simon.marchi@polymtl.ca>
* objfiles.h (ALL_OBJFILE_OSECTIONS): Move up.
(SECT_OFF_DATA): Likewise.
(SECT_OFF_RODATA): Likewise.
(SECT_OFF_TEXT): Likewise.
(SECT_OFF_BSS): Likewise.
(struct objfile) <text_section_offset, data_section_offset>: New
methods.
* amd64-windows-tdep.c (amd64_windows_find_unwind_info): Use
objfile::text_section_offset.
* coff-pe-read.c (add_pe_forwarded_sym): Likewise.
* coffread.c (coff_symtab_read): Likewise.
(enter_linenos): Likewise.
(process_coff_symbol): Likewise.
* ctfread.c (get_objfile_text_range): Likewise.
* dtrace-probe.c (dtrace_probe::get_relocated_address):
Use objfile::data_section_offset.
* dwarf2-frame.c (execute_cfa_program): Use
objfile::text_section_offset.
(dwarf2_frame_find_fde): Likewise.
* dwarf2read.c (create_addrmap_from_index): Likewise.
(create_addrmap_from_aranges): Likewise.
(dw2_find_pc_sect_compunit_symtab): Likewise.
(process_psymtab_comp_unit_reader): Likewise.
(add_partial_symbol): Likewise.
(add_partial_subprogram): Likewise.
(process_full_comp_unit): Likewise.
(read_file_scope): Likewise.
(read_func_scope): Likewise.
(read_lexical_block_scope): Likewise.
(read_call_site_scope): Likewise.
(dwarf2_rnglists_process): Likewise.
(dwarf2_ranges_process): Likewise.
(dwarf2_ranges_read): Likewise.
(dwarf_decode_lines_1): Likewise.
(new_symbol): Likewise.
(dwarf2_fetch_die_loc_sect_off): Likewise.
(dwarf2_per_cu_text_offset): Likewise.
* hppa-bsd-tdep.c (hppabsd_find_global_pointer): Likewise.
* hppa-tdep.c (read_unwind_info): Likewise.
* ia64-tdep.c (ia64_find_unwind_table): Likewise.
* psympriv.h (struct partial_symtab): Likewise.
* psymtab.c (find_pc_sect_psymtab): Likewise.
* solib-svr4.c (enable_break): Likewise.
* stap-probe.c (relocate_address): Use
objfile::data_section_offset.
* xcoffread.c (enter_line_range): Use
objfile::text_section_offset.
(read_xcoff_symtab): Likewise.
2020-01-23 Simon Marchi <simon.marchi@efficios.com> 2020-01-23 Simon Marchi <simon.marchi@efficios.com>
* darwin-nat.c (darwin_nat_target::wait_1): Move `inf` * darwin-nat.c (darwin_nat_target::wait_1): Move `inf`

View File

@ -953,8 +953,7 @@ amd64_windows_find_unwind_info (struct gdbarch *gdbarch, CORE_ADDR pc,
pe = pe_data (sec->objfile->obfd); pe = pe_data (sec->objfile->obfd);
dir = &pe->pe_opthdr.DataDirectory[PE_EXCEPTION_TABLE]; dir = &pe->pe_opthdr.DataDirectory[PE_EXCEPTION_TABLE];
base = (pe->pe_opthdr.ImageBase base = pe->pe_opthdr.ImageBase + objfile->text_section_offset ();
+ objfile->section_offsets[SECT_OFF_TEXT (objfile)]);
*image_base = base; *image_base = base;
/* Find the entry. /* Find the entry.

View File

@ -266,7 +266,7 @@ add_pe_forwarded_sym (minimal_symbol_reader &reader,
really be relocated properly, but nevertheless we make a stab at really be relocated properly, but nevertheless we make a stab at
it, choosing an approach consistent with the history of this it, choosing an approach consistent with the history of this
code. */ code. */
baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; baseaddr = objfile->text_section_offset ();
reader.record_with_info (qualified_name.c_str (), vma - baseaddr, msymtype, reader.record_with_info (qualified_name.c_str (), vma - baseaddr, msymtype,
section); section);

View File

@ -920,7 +920,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
if (in_source_file) if (in_source_file)
complete_symtab (filestring, complete_symtab (filestring,
(cs->c_value (cs->c_value
+ objfile->section_offsets[SECT_OFF_TEXT (objfile)]), + objfile->text_section_offset ()),
main_aux.x_scn.x_scnlen); main_aux.x_scn.x_scnlen);
in_source_file = 0; in_source_file = 0;
} }
@ -1113,7 +1113,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
NULL, cstk.start_addr, NULL, cstk.start_addr,
fcn_cs_saved.c_value fcn_cs_saved.c_value
+ fcn_aux_saved.x_sym.x_misc.x_fsize + fcn_aux_saved.x_sym.x_misc.x_fsize
+ objfile->section_offsets[SECT_OFF_TEXT (objfile)]); + objfile->text_section_offset ());
within_function = 0; within_function = 0;
} }
break; break;
@ -1122,7 +1122,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
if (strcmp (cs->c_name, ".bb") == 0) if (strcmp (cs->c_name, ".bb") == 0)
{ {
tmpaddr = cs->c_value; tmpaddr = cs->c_value;
tmpaddr += objfile->section_offsets[SECT_OFF_TEXT (objfile)]; tmpaddr += objfile->text_section_offset ();
push_context (++depth, tmpaddr); push_context (++depth, tmpaddr);
} }
else if (strcmp (cs->c_name, ".eb") == 0) else if (strcmp (cs->c_name, ".eb") == 0)
@ -1145,9 +1145,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
} }
if (*get_local_symbols () && !outermost_context_p ()) if (*get_local_symbols () && !outermost_context_p ())
{ {
tmpaddr tmpaddr = cs->c_value + objfile->text_section_offset ();
= (cs->c_value
+ objfile->section_offsets[SECT_OFF_TEXT (objfile)]);
/* Make a block for the local symbols within. */ /* Make a block for the local symbols within. */
finish_block (0, cstk.old_blocks, NULL, finish_block (0, cstk.old_blocks, NULL,
cstk.start_addr, tmpaddr); cstk.start_addr, tmpaddr);
@ -1439,7 +1437,7 @@ enter_linenos (long file_offset, int first_line,
if (L_LNNO32 (&lptr) && L_LNNO32 (&lptr) <= last_line) if (L_LNNO32 (&lptr) && L_LNNO32 (&lptr) <= last_line)
{ {
CORE_ADDR addr = lptr.l_addr.l_paddr; CORE_ADDR addr = lptr.l_addr.l_paddr;
addr += objfile->section_offsets[SECT_OFF_TEXT (objfile)]; addr += objfile->text_section_offset ();
record_line (get_current_subfile (), record_line (get_current_subfile (),
first_line + L_LNNO32 (&lptr), first_line + L_LNNO32 (&lptr),
gdbarch_addr_bits_remove (gdbarch, addr)); gdbarch_addr_bits_remove (gdbarch, addr));
@ -1574,7 +1572,7 @@ process_coff_symbol (struct coff_symbol *cs,
if (ISFCN (cs->c_type)) if (ISFCN (cs->c_type))
{ {
SYMBOL_VALUE (sym) += objfile->section_offsets[SECT_OFF_TEXT (objfile)]; SYMBOL_VALUE (sym) += objfile->text_section_offset ();
SYMBOL_TYPE (sym) = SYMBOL_TYPE (sym) =
lookup_function_type (decode_function_type (cs, cs->c_type, lookup_function_type (decode_function_type (cs, cs->c_type,
aux, objfile)); aux, objfile));

View File

@ -1165,7 +1165,7 @@ get_objfile_text_range (struct objfile *of, int *tsize)
codes = bfd_get_section_by_name (abfd, ".text"); codes = bfd_get_section_by_name (abfd, ".text");
*tsize = codes ? bfd_section_size (codes) : 0; *tsize = codes ? bfd_section_size (codes) : 0;
return of->section_offsets[SECT_OFF_TEXT (of)]; return of->text_section_offset ();
} }
/* Start a symtab for OBJFILE in CTF format. */ /* Start a symtab for OBJFILE in CTF format. */

View File

@ -685,8 +685,7 @@ dtrace_probe::is_enabled () const
CORE_ADDR CORE_ADDR
dtrace_probe::get_relocated_address (struct objfile *objfile) dtrace_probe::get_relocated_address (struct objfile *objfile)
{ {
return (this->get_address () return this->get_address () + objfile->data_section_offset ();
+ objfile->section_offsets[SECT_OFF_DATA (objfile)]);
} }
/* Implementation of the get_argument_count method. */ /* Implementation of the get_argument_count method. */

View File

@ -384,7 +384,7 @@ execute_cfa_program (struct dwarf2_fde *fde, const gdb_byte *insn_ptr,
fde->cie->ptr_size, insn_ptr, fde->cie->ptr_size, insn_ptr,
&bytes_read, fde->initial_location); &bytes_read, fde->initial_location);
/* Apply the objfile offset for relocatable objects. */ /* Apply the objfile offset for relocatable objects. */
fs->pc += fde->cie->unit->objfile->section_offsets[SECT_OFF_TEXT (fde->cie->unit->objfile)]; fs->pc += fde->cie->unit->objfile->text_section_offset ();
insn_ptr += bytes_read; insn_ptr += bytes_read;
break; break;
@ -1686,7 +1686,7 @@ dwarf2_frame_find_fde (CORE_ADDR *pc, CORE_ADDR *out_offset)
continue; continue;
gdb_assert (!objfile->section_offsets.empty ()); gdb_assert (!objfile->section_offsets.empty ());
offset = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; offset = objfile->text_section_offset ();
gdb_assert (fde_table->num_entries > 0); gdb_assert (fde_table->num_entries > 0);
if (*pc < offset + fde_table->entries[0]->initial_location) if (*pc < offset + fde_table->entries[0]->initial_location)

View File

@ -3213,7 +3213,7 @@ create_addrmap_from_index (struct dwarf2_per_objfile *dwarf2_per_objfile,
iter = index->address_table.data (); iter = index->address_table.data ();
end = iter + index->address_table.size (); end = iter + index->address_table.size ();
baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; baseaddr = objfile->text_section_offset ();
while (iter < end) while (iter < end)
{ {
@ -3259,7 +3259,7 @@ create_addrmap_from_aranges (struct dwarf2_per_objfile *dwarf2_per_objfile,
struct objfile *objfile = dwarf2_per_objfile->objfile; struct objfile *objfile = dwarf2_per_objfile->objfile;
bfd *abfd = objfile->obfd; bfd *abfd = objfile->obfd;
struct gdbarch *gdbarch = get_objfile_arch (objfile); struct gdbarch *gdbarch = get_objfile_arch (objfile);
const CORE_ADDR baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; const CORE_ADDR baseaddr = objfile->text_section_offset ();
auto_obstack temp_obstack; auto_obstack temp_obstack;
addrmap *mutable_map = addrmap_create_mutable (&temp_obstack); addrmap *mutable_map = addrmap_create_mutable (&temp_obstack);
@ -5281,7 +5281,7 @@ dw2_find_pc_sect_compunit_symtab (struct objfile *objfile,
if (!objfile->partial_symtabs->psymtabs_addrmap) if (!objfile->partial_symtabs->psymtabs_addrmap)
return NULL; return NULL;
CORE_ADDR baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; CORE_ADDR baseaddr = objfile->text_section_offset ();
data = (struct dwarf2_per_cu_data *) addrmap_find data = (struct dwarf2_per_cu_data *) addrmap_find
(objfile->partial_symtabs->psymtabs_addrmap, pc - baseaddr); (objfile->partial_symtabs->psymtabs_addrmap, pc - baseaddr);
if (!data) if (!data)
@ -8076,7 +8076,7 @@ process_psymtab_comp_unit_reader (const struct die_reader_specs *reader,
/* This must be done before calling dwarf2_build_include_psymtabs. */ /* This must be done before calling dwarf2_build_include_psymtabs. */
pst->dirname = dwarf2_string_attr (comp_unit_die, DW_AT_comp_dir, cu); pst->dirname = dwarf2_string_attr (comp_unit_die, DW_AT_comp_dir, cu);
baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; baseaddr = objfile->text_section_offset ();
dwarf2_find_base_address (comp_unit_die, cu); dwarf2_find_base_address (comp_unit_die, cu);
@ -8954,7 +8954,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
const char *actual_name = NULL; const char *actual_name = NULL;
CORE_ADDR baseaddr; CORE_ADDR baseaddr;
baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; baseaddr = objfile->text_section_offset ();
gdb::unique_xmalloc_ptr<char> built_actual_name gdb::unique_xmalloc_ptr<char> built_actual_name
= partial_die_full_name (pdi, cu); = partial_die_full_name (pdi, cu);
@ -9197,7 +9197,7 @@ add_partial_subprogram (struct partial_die_info *pdi,
CORE_ADDR this_highpc; CORE_ADDR this_highpc;
CORE_ADDR this_lowpc; CORE_ADDR this_lowpc;
baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; baseaddr = objfile->text_section_offset ();
this_lowpc this_lowpc
= (gdbarch_adjust_dwarf2_addr (gdbarch, = (gdbarch_adjust_dwarf2_addr (gdbarch,
pdi->lowpc + baseaddr) pdi->lowpc + baseaddr)
@ -10399,7 +10399,7 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu,
struct block *static_block; struct block *static_block;
CORE_ADDR addr; CORE_ADDR addr;
baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; baseaddr = objfile->text_section_offset ();
/* Clear the list here in case something was left over. */ /* Clear the list here in case something was left over. */
cu->method_list.clear (); cu->method_list.clear ();
@ -11601,7 +11601,7 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu)
CORE_ADDR baseaddr; CORE_ADDR baseaddr;
prepare_one_comp_unit (cu, die, cu->language); prepare_one_comp_unit (cu, die, cu->language);
baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; baseaddr = objfile->text_section_offset ();
get_scope_pc_bounds (die, &lowpc, &highpc, cu); get_scope_pc_bounds (die, &lowpc, &highpc, cu);
@ -13704,7 +13704,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
} }
} }
baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; baseaddr = objfile->text_section_offset ();
name = dwarf2_name (die, cu); name = dwarf2_name (die, cu);
@ -13883,7 +13883,7 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu)
struct die_info *child_die; struct die_info *child_die;
CORE_ADDR baseaddr; CORE_ADDR baseaddr;
baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; baseaddr = objfile->text_section_offset ();
/* Ignore blocks with missing or invalid low and high pc attributes. */ /* Ignore blocks with missing or invalid low and high pc attributes. */
/* ??? Perhaps consider discontiguous blocks defined by DW_AT_ranges /* ??? Perhaps consider discontiguous blocks defined by DW_AT_ranges
@ -13957,7 +13957,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
int nparams; int nparams;
struct die_info *child_die; struct die_info *child_die;
baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; baseaddr = objfile->text_section_offset ();
attr = dwarf2_attr (die, DW_AT_call_return_pc, cu); attr = dwarf2_attr (die, DW_AT_call_return_pc, cu);
if (attr == NULL) if (attr == NULL)
@ -14354,7 +14354,7 @@ dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu,
} }
buffer = dwarf2_per_objfile->rnglists.buffer + offset; buffer = dwarf2_per_objfile->rnglists.buffer + offset;
baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; baseaddr = objfile->text_section_offset ();
while (1) while (1)
{ {
@ -14522,7 +14522,7 @@ dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu,
} }
buffer = dwarf2_per_objfile->ranges.buffer + offset; buffer = dwarf2_per_objfile->ranges.buffer + offset;
baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; baseaddr = objfile->text_section_offset ();
while (1) while (1)
{ {
@ -14600,7 +14600,7 @@ dwarf2_ranges_read (unsigned offset, CORE_ADDR *low_return,
{ {
struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile; struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile;
struct gdbarch *gdbarch = get_objfile_arch (objfile); struct gdbarch *gdbarch = get_objfile_arch (objfile);
const CORE_ADDR baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; const CORE_ADDR baseaddr = objfile->text_section_offset ();
int low_set = 0; int low_set = 0;
CORE_ADDR low = 0; CORE_ADDR low = 0;
CORE_ADDR high = 0; CORE_ADDR high = 0;
@ -21425,7 +21425,7 @@ dwarf_decode_lines_1 (struct line_header *lh, struct dwarf2_cu *cu,
the line number program). */ the line number program). */
bool record_lines_p = !decode_for_pst_p; bool record_lines_p = !decode_for_pst_p;
baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; baseaddr = objfile->text_section_offset ();
line_ptr = lh->statement_program_start; line_ptr = lh->statement_program_start;
line_end = lh->statement_program_end; line_end = lh->statement_program_end;
@ -21853,7 +21853,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
int inlined_func = (die->tag == DW_TAG_inlined_subroutine); int inlined_func = (die->tag == DW_TAG_inlined_subroutine);
baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; baseaddr = objfile->text_section_offset ();
name = dwarf2_name (die, cu); name = dwarf2_name (die, cu);
if (name) if (name)
@ -23651,7 +23651,7 @@ dwarf2_fetch_die_loc_sect_off (sect_offset sect_off,
!= dwarf2_per_objfile->abstract_to_concrete.end ())) != dwarf2_per_objfile->abstract_to_concrete.end ()))
{ {
CORE_ADDR pc = (*get_frame_pc) (baton); CORE_ADDR pc = (*get_frame_pc) (baton);
CORE_ADDR baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; CORE_ADDR baseaddr = objfile->text_section_offset ();
struct gdbarch *gdbarch = get_objfile_arch (objfile); struct gdbarch *gdbarch = get_objfile_arch (objfile);
for (const auto &cand_off for (const auto &cand_off
@ -25659,9 +25659,7 @@ dwarf2_per_cu_ref_addr_size (struct dwarf2_per_cu_data *per_cu)
CORE_ADDR CORE_ADDR
dwarf2_per_cu_text_offset (struct dwarf2_per_cu_data *per_cu) dwarf2_per_cu_text_offset (struct dwarf2_per_cu_data *per_cu)
{ {
struct objfile *objfile = per_cu->dwarf2_per_objfile->objfile; return per_cu->dwarf2_per_objfile->objfile->text_section_offset ();
return objfile->section_offsets[SECT_OFF_TEXT (objfile)];
} }
/* Return a type that is a generic pointer type, the size of which matches /* Return a type that is a generic pointer type, the size of which matches

View File

@ -87,7 +87,7 @@ hppabsd_find_global_pointer (struct gdbarch *gdbarch, struct value *function)
we have to do it ourselves. */ we have to do it ourselves. */
pltgot = extract_unsigned_integer (buf, sizeof buf, pltgot = extract_unsigned_integer (buf, sizeof buf,
byte_order); byte_order);
pltgot += sec->objfile->section_offsets[SECT_OFF_TEXT (sec->objfile)]; pltgot += sec->objfile->text_section_offset ();
return pltgot; return pltgot;
} }

View File

@ -357,7 +357,7 @@ read_unwind_info (struct objfile *objfile)
struct hppa_unwind_info *ui; struct hppa_unwind_info *ui;
struct hppa_objfile_private *obj_private; struct hppa_objfile_private *obj_private;
text_offset = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; text_offset = objfile->text_section_offset ();
ui = (struct hppa_unwind_info *) obstack_alloc (&objfile->objfile_obstack, ui = (struct hppa_unwind_info *) obstack_alloc (&objfile->objfile_obstack,
sizeof (struct hppa_unwind_info)); sizeof (struct hppa_unwind_info));

View File

@ -2713,7 +2713,7 @@ ia64_find_unwind_table (struct objfile *objfile, unw_word_t ip,
ehdr = elf_tdata (bfd)->elf_header; ehdr = elf_tdata (bfd)->elf_header;
phdr = elf_tdata (bfd)->phdr; phdr = elf_tdata (bfd)->phdr;
load_base = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; load_base = objfile->text_section_offset ();
for (i = 0; i < ehdr->e_phnum; ++i) for (i = 0; i < ehdr->e_phnum; ++i)
{ {

View File

@ -155,6 +155,37 @@ struct obj_section
+ bfd_section_size ((s)->the_bfd_section) \ + bfd_section_size ((s)->the_bfd_section) \
+ obj_section_offset (s)) + obj_section_offset (s))
#define ALL_OBJFILE_OSECTIONS(objfile, osect) \
for (osect = objfile->sections; osect < objfile->sections_end; osect++) \
if (osect->the_bfd_section == NULL) \
{ \
/* Nothing. */ \
} \
else
#define SECT_OFF_DATA(objfile) \
((objfile->sect_index_data == -1) \
? (internal_error (__FILE__, __LINE__, \
_("sect_index_data not initialized")), -1) \
: objfile->sect_index_data)
#define SECT_OFF_RODATA(objfile) \
((objfile->sect_index_rodata == -1) \
? (internal_error (__FILE__, __LINE__, \
_("sect_index_rodata not initialized")), -1) \
: objfile->sect_index_rodata)
#define SECT_OFF_TEXT(objfile) \
((objfile->sect_index_text == -1) \
? (internal_error (__FILE__, __LINE__, \
_("sect_index_text not initialized")), -1) \
: objfile->sect_index_text)
/* Sometimes the .bss section is missing from the objfile, so we don't
want to die here. Let the users of SECT_OFF_BSS deal with an
uninitialized section index. */
#define SECT_OFF_BSS(objfile) (objfile)->sect_index_bss
/* The "objstats" structure provides a place for gdb to record some /* The "objstats" structure provides a place for gdb to record some
interesting information about its internal state at runtime, on a interesting information about its internal state at runtime, on a
per objfile basis, such as information about the number of symbols per objfile basis, such as information about the number of symbols
@ -492,6 +523,15 @@ public:
return separate_debug_range (this); return separate_debug_range (this);
} }
CORE_ADDR text_section_offset () const
{
return section_offsets[SECT_OFF_TEXT (this)];
}
CORE_ADDR data_section_offset () const
{
return section_offsets[SECT_OFF_DATA (this)];
}
/* The object file's original name as specified by the user, /* The object file's original name as specified by the user,
made absolute, and tilde-expanded. However, it is not canonicalized made absolute, and tilde-expanded. However, it is not canonicalized
@ -737,38 +777,6 @@ extern void default_iterate_over_objfiles_in_search_order
(struct gdbarch *gdbarch, (struct gdbarch *gdbarch,
iterate_over_objfiles_in_search_order_cb_ftype *cb, iterate_over_objfiles_in_search_order_cb_ftype *cb,
void *cb_data, struct objfile *current_objfile); void *cb_data, struct objfile *current_objfile);
#define ALL_OBJFILE_OSECTIONS(objfile, osect) \
for (osect = objfile->sections; osect < objfile->sections_end; osect++) \
if (osect->the_bfd_section == NULL) \
{ \
/* Nothing. */ \
} \
else
#define SECT_OFF_DATA(objfile) \
((objfile->sect_index_data == -1) \
? (internal_error (__FILE__, __LINE__, \
_("sect_index_data not initialized")), -1) \
: objfile->sect_index_data)
#define SECT_OFF_RODATA(objfile) \
((objfile->sect_index_rodata == -1) \
? (internal_error (__FILE__, __LINE__, \
_("sect_index_rodata not initialized")), -1) \
: objfile->sect_index_rodata)
#define SECT_OFF_TEXT(objfile) \
((objfile->sect_index_text == -1) \
? (internal_error (__FILE__, __LINE__, \
_("sect_index_text not initialized")), -1) \
: objfile->sect_index_text)
/* Sometimes the .bss section is missing from the objfile, so we don't
want to die here. Let the users of SECT_OFF_BSS deal with an
uninitialized section index. */
#define SECT_OFF_BSS(objfile) (objfile)->sect_index_bss
/* Reset the per-BFD storage area on OBJ. */ /* Reset the per-BFD storage area on OBJ. */

View File

@ -119,13 +119,13 @@ struct partial_symtab
/* Return the relocated low text address of this partial_symtab. */ /* Return the relocated low text address of this partial_symtab. */
CORE_ADDR text_low (struct objfile *objfile) const CORE_ADDR text_low (struct objfile *objfile) const
{ {
return m_text_low + objfile->section_offsets[SECT_OFF_TEXT (objfile)]; return m_text_low + objfile->text_section_offset ();
} }
/* Return the relocated high text address of this partial_symtab. */ /* Return the relocated high text address of this partial_symtab. */
CORE_ADDR text_high (struct objfile *objfile) const CORE_ADDR text_high (struct objfile *objfile) const
{ {
return m_text_high + objfile->section_offsets[SECT_OFF_TEXT (objfile)]; return m_text_high + objfile->text_section_offset ();
} }
/* Set the low text address of this partial_symtab. */ /* Set the low text address of this partial_symtab. */

View File

@ -316,7 +316,7 @@ find_pc_sect_psymtab (struct objfile *objfile, CORE_ADDR pc,
if (objfile->partial_symtabs->psymtabs != NULL if (objfile->partial_symtabs->psymtabs != NULL
&& objfile->partial_symtabs->psymtabs_addrmap != NULL) && objfile->partial_symtabs->psymtabs_addrmap != NULL)
{ {
CORE_ADDR baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; CORE_ADDR baseaddr = objfile->text_section_offset ();
struct partial_symtab *pst struct partial_symtab *pst
= ((struct partial_symtab *) = ((struct partial_symtab *)

View File

@ -2273,7 +2273,7 @@ enable_break (struct svr4_info *info, int from_tty)
CORE_ADDR load_addr; CORE_ADDR load_addr;
tmp_bfd = os->objfile->obfd; tmp_bfd = os->objfile->obfd;
load_addr = os->objfile->section_offsets[SECT_OFF_TEXT (os->objfile)]; load_addr = os->objfile->text_section_offset ();
interp_sect = bfd_get_section_by_name (tmp_bfd, ".text"); interp_sect = bfd_get_section_by_name (tmp_bfd, ".text");
if (interp_sect) if (interp_sect)

View File

@ -1290,7 +1290,7 @@ stap_probe::parse_arguments (struct gdbarch *gdbarch)
static CORE_ADDR static CORE_ADDR
relocate_address (CORE_ADDR address, struct objfile *objfile) relocate_address (CORE_ADDR address, struct objfile *objfile)
{ {
return address + objfile->section_offsets[SECT_OFF_DATA (objfile)]; return address + objfile->data_section_offset ();
} }
/* Implementation of the get_relocated_address method. */ /* Implementation of the get_relocated_address method. */

View File

@ -865,7 +865,7 @@ enter_line_range (struct subfile *subfile, unsigned beginoffset,
addr = (int_lnno.l_lnno addr = (int_lnno.l_lnno
? int_lnno.l_addr.l_paddr ? int_lnno.l_addr.l_paddr
: read_symbol_nvalue (int_lnno.l_addr.l_symndx)); : read_symbol_nvalue (int_lnno.l_addr.l_symndx));
addr += objfile->section_offsets[SECT_OFF_TEXT (objfile)]; addr += objfile->text_section_offset ();
if (addr < startaddr || (endaddr && addr >= endaddr)) if (addr < startaddr || (endaddr && addr >= endaddr))
return; return;
@ -1233,7 +1233,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
} }
file_start_addr = file_start_addr =
cs->c_value + objfile->section_offsets[SECT_OFF_TEXT (objfile)]; cs->c_value + objfile->text_section_offset ();
file_end_addr = file_start_addr + CSECT_LEN (&main_aux); file_end_addr = file_start_addr + CSECT_LEN (&main_aux);
if (cs->c_name && (cs->c_name[0] == '.' || cs->c_name[0] == '@')) if (cs->c_name && (cs->c_name[0] == '.' || cs->c_name[0] == '@'))
@ -1355,7 +1355,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
case C_FCN: case C_FCN:
if (strcmp (cs->c_name, ".bf") == 0) if (strcmp (cs->c_name, ".bf") == 0)
{ {
CORE_ADDR off = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; CORE_ADDR off = objfile->text_section_offset ();
bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type, cs->c_sclass, bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type, cs->c_sclass,
0, cs->c_naux, &main_aux); 0, cs->c_naux, &main_aux);
@ -1399,7 +1399,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
NULL, cstk.start_addr, NULL, cstk.start_addr,
(fcn_cs_saved.c_value (fcn_cs_saved.c_value
+ fcn_aux_saved.x_sym.x_misc.x_fsize + fcn_aux_saved.x_sym.x_misc.x_fsize
+ objfile->section_offsets[SECT_OFF_TEXT (objfile)])); + objfile->text_section_offset ()));
within_function = 0; within_function = 0;
} }
break; break;
@ -1466,7 +1466,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
depth++; depth++;
newobj = push_context (depth, newobj = push_context (depth,
(cs->c_value (cs->c_value
+ objfile->section_offsets[SECT_OFF_TEXT (objfile)])); + objfile->text_section_offset ()));
} }
else if (strcmp (cs->c_name, ".eb") == 0) else if (strcmp (cs->c_name, ".eb") == 0)
{ {
@ -1488,7 +1488,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
cstk.old_blocks, NULL, cstk.old_blocks, NULL,
cstk.start_addr, cstk.start_addr,
(cs->c_value (cs->c_value
+ objfile->section_offsets[SECT_OFF_TEXT (objfile)])); + objfile->text_section_offset ()));
} }
*get_local_symbols () = cstk.locals; *get_local_symbols () = cstk.locals;
} }