aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2020-01-23 17:55:35 -0500
committerSimon Marchi <simon.marchi@efficios.com>2020-01-23 17:55:35 -0500
commitb3b3bada0d514f8e57a04fd333f05d1da94e2304 (patch)
treefb20ef8071ffa1e058668d0f823d38da07381c70 /gdb
parentab53f3826242df0f051f9a6fa4b2926687205025 (diff)
downloadgdb-b3b3bada0d514f8e57a04fd333f05d1da94e2304.zip
gdb-b3b3bada0d514f8e57a04fd333f05d1da94e2304.tar.gz
gdb-b3b3bada0d514f8e57a04fd333f05d1da94e2304.tar.bz2
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.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog51
-rw-r--r--gdb/amd64-windows-tdep.c3
-rw-r--r--gdb/coff-pe-read.c2
-rw-r--r--gdb/coffread.c14
-rw-r--r--gdb/ctfread.c2
-rw-r--r--gdb/dtrace-probe.c3
-rw-r--r--gdb/dwarf2-frame.c4
-rw-r--r--gdb/dwarf2read.c38
-rw-r--r--gdb/hppa-bsd-tdep.c2
-rw-r--r--gdb/hppa-tdep.c2
-rw-r--r--gdb/ia64-tdep.c2
-rw-r--r--gdb/objfiles.h72
-rw-r--r--gdb/psympriv.h4
-rw-r--r--gdb/psymtab.c2
-rw-r--r--gdb/solib-svr4.c2
-rw-r--r--gdb/stap-probe.c2
-rw-r--r--gdb/xcoffread.c12
17 files changed, 135 insertions, 82 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index a37affe..f0bbaae 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -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>
* darwin-nat.c (darwin_nat_target::wait_1): Move `inf`
diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c
index b2155f3..d4d7968 100644
--- a/gdb/amd64-windows-tdep.c
+++ b/gdb/amd64-windows-tdep.c
@@ -953,8 +953,7 @@ amd64_windows_find_unwind_info (struct gdbarch *gdbarch, CORE_ADDR pc,
pe = pe_data (sec->objfile->obfd);
dir = &pe->pe_opthdr.DataDirectory[PE_EXCEPTION_TABLE];
- base = (pe->pe_opthdr.ImageBase
- + objfile->section_offsets[SECT_OFF_TEXT (objfile)]);
+ base = pe->pe_opthdr.ImageBase + objfile->text_section_offset ();
*image_base = base;
/* Find the entry.
diff --git a/gdb/coff-pe-read.c b/gdb/coff-pe-read.c
index 047f2e5..3ecfb3d 100644
--- a/gdb/coff-pe-read.c
+++ b/gdb/coff-pe-read.c
@@ -266,7 +266,7 @@ add_pe_forwarded_sym (minimal_symbol_reader &reader,
really be relocated properly, but nevertheless we make a stab at
it, choosing an approach consistent with the history of this
code. */
- baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)];
+ baseaddr = objfile->text_section_offset ();
reader.record_with_info (qualified_name.c_str (), vma - baseaddr, msymtype,
section);
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 227cf86..b682755 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -920,7 +920,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
if (in_source_file)
complete_symtab (filestring,
(cs->c_value
- + objfile->section_offsets[SECT_OFF_TEXT (objfile)]),
+ + objfile->text_section_offset ()),
main_aux.x_scn.x_scnlen);
in_source_file = 0;
}
@@ -1113,7 +1113,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
NULL, cstk.start_addr,
fcn_cs_saved.c_value
+ fcn_aux_saved.x_sym.x_misc.x_fsize
- + objfile->section_offsets[SECT_OFF_TEXT (objfile)]);
+ + objfile->text_section_offset ());
within_function = 0;
}
break;
@@ -1122,7 +1122,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
if (strcmp (cs->c_name, ".bb") == 0)
{
tmpaddr = cs->c_value;
- tmpaddr += objfile->section_offsets[SECT_OFF_TEXT (objfile)];
+ tmpaddr += objfile->text_section_offset ();
push_context (++depth, tmpaddr);
}
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 ())
{
- tmpaddr
- = (cs->c_value
- + objfile->section_offsets[SECT_OFF_TEXT (objfile)]);
+ tmpaddr = cs->c_value + objfile->text_section_offset ();
/* Make a block for the local symbols within. */
finish_block (0, cstk.old_blocks, NULL,
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)
{
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 (),
first_line + L_LNNO32 (&lptr),
gdbarch_addr_bits_remove (gdbarch, addr));
@@ -1574,7 +1572,7 @@ process_coff_symbol (struct coff_symbol *cs,
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) =
lookup_function_type (decode_function_type (cs, cs->c_type,
aux, objfile));
diff --git a/gdb/ctfread.c b/gdb/ctfread.c
index bfca270..f3c067e 100644
--- a/gdb/ctfread.c
+++ b/gdb/ctfread.c
@@ -1165,7 +1165,7 @@ get_objfile_text_range (struct objfile *of, int *tsize)
codes = bfd_get_section_by_name (abfd, ".text");
*tsize = codes ? bfd_section_size (codes) : 0;
- return of->section_offsets[SECT_OFF_TEXT (of)];
+ return of->text_section_offset ();
}
/* Start a symtab for OBJFILE in CTF format. */
diff --git a/gdb/dtrace-probe.c b/gdb/dtrace-probe.c
index 71d627b..daa5dcc 100644
--- a/gdb/dtrace-probe.c
+++ b/gdb/dtrace-probe.c
@@ -685,8 +685,7 @@ dtrace_probe::is_enabled () const
CORE_ADDR
dtrace_probe::get_relocated_address (struct objfile *objfile)
{
- return (this->get_address ()
- + objfile->section_offsets[SECT_OFF_DATA (objfile)]);
+ return this->get_address () + objfile->data_section_offset ();
}
/* Implementation of the get_argument_count method. */
diff --git a/gdb/dwarf2-frame.c b/gdb/dwarf2-frame.c
index a043d48..40eb7f5 100644
--- a/gdb/dwarf2-frame.c
+++ b/gdb/dwarf2-frame.c
@@ -384,7 +384,7 @@ execute_cfa_program (struct dwarf2_fde *fde, const gdb_byte *insn_ptr,
fde->cie->ptr_size, insn_ptr,
&bytes_read, fde->initial_location);
/* Apply the objfile offset for relocatable objects. */
- fs->pc += 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;
break;
@@ -1686,7 +1686,7 @@ dwarf2_frame_find_fde (CORE_ADDR *pc, CORE_ADDR *out_offset)
continue;
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);
if (*pc < offset + fde_table->entries[0]->initial_location)
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index dfa2f91..a494db7 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -3213,7 +3213,7 @@ create_addrmap_from_index (struct dwarf2_per_objfile *dwarf2_per_objfile,
iter = index->address_table.data ();
end = iter + index->address_table.size ();
- baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)];
+ baseaddr = objfile->text_section_offset ();
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;
bfd *abfd = objfile->obfd;
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;
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)
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
(objfile->partial_symtabs->psymtabs_addrmap, pc - baseaddr);
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. */
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);
@@ -8954,7 +8954,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
const char *actual_name = NULL;
CORE_ADDR baseaddr;
- baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)];
+ baseaddr = objfile->text_section_offset ();
gdb::unique_xmalloc_ptr<char> built_actual_name
= 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_lowpc;
- baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)];
+ baseaddr = objfile->text_section_offset ();
this_lowpc
= (gdbarch_adjust_dwarf2_addr (gdbarch,
pdi->lowpc + baseaddr)
@@ -10399,7 +10399,7 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu,
struct block *static_block;
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. */
cu->method_list.clear ();
@@ -11601,7 +11601,7 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu)
CORE_ADDR baseaddr;
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);
@@ -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);
@@ -13883,7 +13883,7 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu)
struct die_info *child_die;
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. */
/* ??? 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;
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);
if (attr == NULL)
@@ -14354,7 +14354,7 @@ dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu,
}
buffer = dwarf2_per_objfile->rnglists.buffer + offset;
- baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)];
+ baseaddr = objfile->text_section_offset ();
while (1)
{
@@ -14522,7 +14522,7 @@ dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu,
}
buffer = dwarf2_per_objfile->ranges.buffer + offset;
- baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)];
+ baseaddr = objfile->text_section_offset ();
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 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;
CORE_ADDR low = 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). */
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_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);
- baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)];
+ baseaddr = objfile->text_section_offset ();
name = dwarf2_name (die, cu);
if (name)
@@ -23651,7 +23651,7 @@ dwarf2_fetch_die_loc_sect_off (sect_offset sect_off,
!= dwarf2_per_objfile->abstract_to_concrete.end ()))
{
CORE_ADDR pc = (*get_frame_pc) (baton);
- CORE_ADDR baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)];
+ CORE_ADDR baseaddr = objfile->text_section_offset ();
struct gdbarch *gdbarch = get_objfile_arch (objfile);
for (const auto &cand_off
@@ -25659,9 +25659,7 @@ dwarf2_per_cu_ref_addr_size (struct dwarf2_per_cu_data *per_cu)
CORE_ADDR
dwarf2_per_cu_text_offset (struct dwarf2_per_cu_data *per_cu)
{
- struct objfile *objfile = per_cu->dwarf2_per_objfile->objfile;
-
- return objfile->section_offsets[SECT_OFF_TEXT (objfile)];
+ return per_cu->dwarf2_per_objfile->objfile->text_section_offset ();
}
/* Return a type that is a generic pointer type, the size of which matches
diff --git a/gdb/hppa-bsd-tdep.c b/gdb/hppa-bsd-tdep.c
index 34dec20..3994167 100644
--- a/gdb/hppa-bsd-tdep.c
+++ b/gdb/hppa-bsd-tdep.c
@@ -87,7 +87,7 @@ hppabsd_find_global_pointer (struct gdbarch *gdbarch, struct value *function)
we have to do it ourselves. */
pltgot = extract_unsigned_integer (buf, sizeof buf,
byte_order);
- pltgot += sec->objfile->section_offsets[SECT_OFF_TEXT (sec->objfile)];
+ pltgot += sec->objfile->text_section_offset ();
return pltgot;
}
diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c
index d8a3a56..3730a73 100644
--- a/gdb/hppa-tdep.c
+++ b/gdb/hppa-tdep.c
@@ -357,7 +357,7 @@ read_unwind_info (struct objfile *objfile)
struct hppa_unwind_info *ui;
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,
sizeof (struct hppa_unwind_info));
diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c
index dd07b7d..db02882 100644
--- a/gdb/ia64-tdep.c
+++ b/gdb/ia64-tdep.c
@@ -2713,7 +2713,7 @@ ia64_find_unwind_table (struct objfile *objfile, unw_word_t ip,
ehdr = elf_tdata (bfd)->elf_header;
phdr = elf_tdata (bfd)->phdr;
- load_base = objfile->section_offsets[SECT_OFF_TEXT (objfile)];
+ load_base = objfile->text_section_offset ();
for (i = 0; i < ehdr->e_phnum; ++i)
{
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 1301f2c..b71a8a9 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -155,6 +155,37 @@ struct obj_section
+ bfd_section_size ((s)->the_bfd_section) \
+ 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
interesting information about its internal state at runtime, on a
per objfile basis, such as information about the number of symbols
@@ -492,6 +523,15 @@ public:
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,
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,
iterate_over_objfiles_in_search_order_cb_ftype *cb,
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. */
diff --git a/gdb/psympriv.h b/gdb/psympriv.h
index e763005..be03465 100644
--- a/gdb/psympriv.h
+++ b/gdb/psympriv.h
@@ -119,13 +119,13 @@ struct partial_symtab
/* Return the relocated low text address of this partial_symtab. */
CORE_ADDR text_low (struct objfile *objfile) const
{
- return m_text_low + 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. */
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. */
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 09231bf9..18580f5 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -316,7 +316,7 @@ find_pc_sect_psymtab (struct objfile *objfile, CORE_ADDR pc,
if (objfile->partial_symtabs->psymtabs != NULL
&& objfile->partial_symtabs->psymtabs_addrmap != NULL)
{
- CORE_ADDR baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)];
+ CORE_ADDR baseaddr = objfile->text_section_offset ();
struct partial_symtab *pst
= ((struct partial_symtab *)
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 1c769bb..38c832f 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -2273,7 +2273,7 @@ enable_break (struct svr4_info *info, int from_tty)
CORE_ADDR load_addr;
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");
if (interp_sect)
diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c
index 2d15212..1a5ba5a 100644
--- a/gdb/stap-probe.c
+++ b/gdb/stap-probe.c
@@ -1290,7 +1290,7 @@ stap_probe::parse_arguments (struct gdbarch *gdbarch)
static CORE_ADDR
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. */
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index aae2e37..66ace43 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -865,7 +865,7 @@ enter_line_range (struct subfile *subfile, unsigned beginoffset,
addr = (int_lnno.l_lnno
? int_lnno.l_addr.l_paddr
: read_symbol_nvalue (int_lnno.l_addr.l_symndx));
- addr += objfile->section_offsets[SECT_OFF_TEXT (objfile)];
+ addr += objfile->text_section_offset ();
if (addr < startaddr || (endaddr && addr >= endaddr))
return;
@@ -1233,7 +1233,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
}
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);
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:
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,
0, cs->c_naux, &main_aux);
@@ -1399,7 +1399,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
NULL, cstk.start_addr,
(fcn_cs_saved.c_value
+ fcn_aux_saved.x_sym.x_misc.x_fsize
- + objfile->section_offsets[SECT_OFF_TEXT (objfile)]));
+ + objfile->text_section_offset ()));
within_function = 0;
}
break;
@@ -1466,7 +1466,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
depth++;
newobj = push_context (depth,
(cs->c_value
- + objfile->section_offsets[SECT_OFF_TEXT (objfile)]));
+ + objfile->text_section_offset ()));
}
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.start_addr,
(cs->c_value
- + objfile->section_offsets[SECT_OFF_TEXT (objfile)]));
+ + objfile->text_section_offset ()));
}
*get_local_symbols () = cstk.locals;
}