gdb: convert obj_section macros to methods

Convert these three macros to methods of obj_section.  The problem fixed
by the following patch is caused by an out of bound access of the
objfile::section_offsets vector.  Since this is deep in macros, we don't
get a clear backtrace and it's difficult to debug.  Changing that to
methods means we can step in them and break on them.

Because their implementation requires knowing about struct objfile, move
struct obj_section below struct objfile in objfiles.h.

The obj_section_offset was used in one place as an lvalue to set
offsets, in machoread.c.  Replace that with a set_offset method.

Add the objfile::section_offset and objfile::set_section_offset methods
to improve encapsulation (reduce other objects poking into struct
objfile's internals).

gdb/ChangeLog:

	* objfiles.h (struct obj_section): Move down.
	<offset, set_offset, addr, endaddr>: New.
	(obj_section_offset, obj_section_addr, obj_section_endaddr),
	replace all users to use obj_section methods.
	(struct objfile) <section_offset, set_section_offset>: New.

Change-Id: I97e8fcae93ab2353fbdadcb4a5ec10d7949a7334
This commit is contained in:
Simon Marchi
2021-06-28 15:28:26 -04:00
parent f07fad95a9
commit 0c1bcd2327
22 changed files with 134 additions and 102 deletions

View File

@ -1,3 +1,19 @@
2021-06-28 Simon Marchi <simon.marchi@polymtl.ca>
* objfiles.h (struct obj_section): Move down.
<offset, set_offset, addr, endaddr>: New.
(obj_section_offset, obj_section_addr, obj_section_endaddr),
replace all users to use obj_section methods.
(struct objfile) <section_offset, set_section_offset>: New.
2021-06-28 Simon Marchi <simon.marchi@polymtl.ca>
* objfiles.h (struct obj_section): Move down.
<offset, set_offset, addr, endaddr>: New.
(obj_section_offset, obj_section_addr, obj_section_endaddr),
replace all users to use obj_section methods.
(struct objfile) <section_offset, set_section_offset>: New.
2021-06-28 Simon Marchi <simon.marchi@polymtl.ca> 2021-06-28 Simon Marchi <simon.marchi@polymtl.ca>
* .flake8: New. * .flake8: New.

View File

@ -395,8 +395,7 @@ arm_find_mapping_symbol (CORE_ADDR memaddr, CORE_ADDR *start)
data->section_maps_sorted[section_idx] = true; data->section_maps_sorted[section_idx] = true;
} }
struct arm_mapping_symbol map_key arm_mapping_symbol map_key = { memaddr - sec->addr (), 0 };
= { memaddr - obj_section_addr (sec), 0 };
arm_mapping_symbol_vec::const_iterator it arm_mapping_symbol_vec::const_iterator it
= std::lower_bound (map.begin (), map.end (), map_key); = std::lower_bound (map.begin (), map.end (), map_key);
@ -409,7 +408,7 @@ arm_find_mapping_symbol (CORE_ADDR memaddr, CORE_ADDR *start)
if (it->value == map_key.value) if (it->value == map_key.value)
{ {
if (start) if (start)
*start = it->value + obj_section_addr (sec); *start = it->value + sec->addr ();
return it->type; return it->type;
} }
} }
@ -420,7 +419,7 @@ arm_find_mapping_symbol (CORE_ADDR memaddr, CORE_ADDR *start)
= it - 1; = it - 1;
if (start) if (start)
*start = prev_it->value + obj_section_addr (sec); *start = prev_it->value + sec->addr ();
return prev_it->type; return prev_it->type;
} }
} }
@ -2218,7 +2217,7 @@ arm_exidx_new_objfile (struct objfile *objfile)
NULL NULL
}; };
CORE_ADDR pc = pers + obj_section_offset (pers_sec); CORE_ADDR pc = pers + pers_sec->offset ();
int k; int k;
for (k = 0; personality[k]; k++) for (k = 0; personality[k]; k++)
@ -2303,7 +2302,7 @@ arm_find_exidx_entry (CORE_ADDR memaddr, CORE_ADDR *start)
if (sec != NULL) if (sec != NULL)
{ {
struct arm_exidx_data *data; struct arm_exidx_data *data;
struct arm_exidx_entry map_key = { memaddr - obj_section_addr (sec), 0 }; struct arm_exidx_entry map_key = { memaddr - sec->addr (), 0 };
data = arm_exidx_data_key.get (sec->objfile->obfd); data = arm_exidx_data_key.get (sec->objfile->obfd);
if (data != NULL) if (data != NULL)
@ -2323,7 +2322,7 @@ arm_find_exidx_entry (CORE_ADDR memaddr, CORE_ADDR *start)
if (idx->addr == map_key.addr) if (idx->addr == map_key.addr)
{ {
if (start) if (start)
*start = idx->addr + obj_section_addr (sec); *start = idx->addr + sec->addr ();
return idx->entry; return idx->entry;
} }
} }
@ -2332,7 +2331,7 @@ arm_find_exidx_entry (CORE_ADDR memaddr, CORE_ADDR *start)
{ {
idx = idx - 1; idx = idx - 1;
if (start) if (start)
*start = idx->addr + obj_section_addr (sec); *start = idx->addr + sec->addr ();
return idx->entry; return idx->entry;
} }
} }

View File

@ -636,8 +636,7 @@ program_space::add_target_sections (struct objfile *objfile)
if (bfd_section_size (osect->the_bfd_section) == 0) if (bfd_section_size (osect->the_bfd_section) == 0)
continue; continue;
m_target_sections.emplace_back (obj_section_addr (osect), m_target_sections.emplace_back (osect->addr (), osect->endaddr (),
obj_section_endaddr (osect),
osect->the_bfd_section, (void *) objfile); osect->the_bfd_section, (void *) objfile);
} }
} }

View File

@ -404,8 +404,8 @@ gcore_create_callback (CORE_ADDR vaddr, unsigned long size, int read,
bfd *abfd = objfile->obfd; bfd *abfd = objfile->obfd;
asection *asec = objsec->the_bfd_section; asection *asec = objsec->the_bfd_section;
bfd_vma align = (bfd_vma) 1 << bfd_section_alignment (asec); bfd_vma align = (bfd_vma) 1 << bfd_section_alignment (asec);
bfd_vma start = obj_section_addr (objsec) & -align; bfd_vma start = objsec->addr () & -align;
bfd_vma end = (obj_section_endaddr (objsec) + align - 1) & -align; bfd_vma end = (objsec->endaddr () + align - 1) & -align;
/* Match if either the entire memory region lies inside the /* Match if either the entire memory region lies inside the
section (i.e. a mapping covering some pages of a large section (i.e. a mapping covering some pages of a large
@ -479,7 +479,7 @@ objfile_find_memory_regions (struct target_ops *self,
int size = bfd_section_size (isec); int size = bfd_section_size (isec);
int ret; int ret;
ret = (*func) (obj_section_addr (objsec), size, ret = (*func) (objsec->addr (), size,
1, /* All sections will be readable. */ 1, /* All sections will be readable. */
(flags & SEC_READONLY) == 0, /* Writable. */ (flags & SEC_READONLY) == 0, /* Writable. */
(flags & SEC_CODE) != 0, /* Executable. */ (flags & SEC_CODE) != 0, /* Executable. */

View File

@ -64,8 +64,8 @@ hppabsd_find_global_pointer (struct gdbarch *gdbarch, struct value *function)
if (sec < faddr_sec->objfile->sections_end) if (sec < faddr_sec->objfile->sections_end)
{ {
CORE_ADDR addr = obj_section_addr (sec); CORE_ADDR addr = sec->addr ();
CORE_ADDR endaddr = obj_section_endaddr (sec); CORE_ADDR endaddr = sec->endaddr ();
while (addr < endaddr) while (addr < endaddr)
{ {

View File

@ -371,8 +371,8 @@ hppa_linux_find_global_pointer (struct gdbarch *gdbarch,
{ {
CORE_ADDR addr, endaddr; CORE_ADDR addr, endaddr;
addr = obj_section_addr (osect); addr = osect->addr ();
endaddr = obj_section_endaddr (osect); endaddr = osect->endaddr ();
while (addr < endaddr) while (addr < endaddr)
{ {

View File

@ -943,11 +943,7 @@ hppa64_convert_code_addr_to_fptr (struct gdbarch *gdbarch, CORE_ADDR code)
if (opd < sec->objfile->sections_end) if (opd < sec->objfile->sections_end)
{ {
CORE_ADDR addr; for (CORE_ADDR addr = opd->addr (); addr < opd->endaddr (); addr += 2 * 8)
for (addr = obj_section_addr (opd);
addr < obj_section_endaddr (opd);
addr += 2 * 8)
{ {
ULONGEST opdaddr; ULONGEST opdaddr;
gdb_byte tmp[8]; gdb_byte tmp[8];

View File

@ -2859,7 +2859,7 @@ ia64_get_dyn_info_list (unw_addr_space_t as,
void *buf = NULL; void *buf = NULL;
text_sec = objfile->sections + SECT_OFF_TEXT (objfile); text_sec = objfile->sections + SECT_OFF_TEXT (objfile);
ip = obj_section_addr (text_sec); ip = text_sec->addr ();
ret = ia64_find_unwind_table (objfile, ip, &di, &buf); ret = ia64_find_unwind_table (objfile, ip, &di, &buf);
if (ret >= 0) if (ret >= 0)
{ {
@ -3432,10 +3432,8 @@ ia64_find_global_pointer_from_dynamic_section (struct gdbarch *gdbarch,
if (osect < faddr_sect->objfile->sections_end) if (osect < faddr_sect->objfile->sections_end)
{ {
CORE_ADDR addr, endaddr; CORE_ADDR addr = osect->addr ();
CORE_ADDR endaddr = osect->endaddr ();
addr = obj_section_addr (osect);
endaddr = obj_section_endaddr (osect);
while (addr < endaddr) while (addr < endaddr)
{ {
@ -3515,10 +3513,8 @@ find_extant_func_descr (struct gdbarch *gdbarch, CORE_ADDR faddr)
if (osect < faddr_sect->objfile->sections_end) if (osect < faddr_sect->objfile->sections_end)
{ {
CORE_ADDR addr, endaddr; CORE_ADDR addr = osect->addr ();
CORE_ADDR endaddr = osect->endaddr ();
addr = obj_section_addr (osect);
endaddr = obj_section_endaddr (osect);
while (addr < endaddr) while (addr < endaddr)
{ {

View File

@ -926,7 +926,7 @@ macho_symfile_offsets (struct objfile *objfile,
if (bfd_sect_name == addrs[i].name) if (bfd_sect_name == addrs[i].name)
{ {
obj_section_offset (osect) = addrs[i].addr; osect->set_offset (addrs[i].addr);
break; break;
} }
} }

View File

@ -319,8 +319,7 @@ print_objfile_section_info (bfd *abfd, struct obj_section *asect,
print_section_index (abfd, asect->the_bfd_section, index_digits); print_section_index (abfd, asect->the_bfd_section, index_digits);
maint_print_section_info (name, flags, maint_print_section_info (name, flags,
obj_section_addr (asect), asect->addr (), asect->endaddr (),
obj_section_endaddr (asect),
asect->the_bfd_section->filepos, asect->the_bfd_section->filepos,
addr_size); addr_size);
} }

View File

@ -687,9 +687,9 @@ frob_address (struct objfile *objfile, CORE_ADDR *pc)
ALL_OBJFILE_OSECTIONS (objfile, iter) ALL_OBJFILE_OSECTIONS (objfile, iter)
{ {
if (*pc >= obj_section_addr (iter) && *pc < obj_section_endaddr (iter)) if (*pc >= iter->addr () && *pc < iter->endaddr ())
{ {
*pc -= obj_section_offset (iter); *pc -= iter->offset ();
return 1; return 1;
} }
} }
@ -1616,12 +1616,12 @@ minimal_symbol_upper_bound (struct bound_minimal_symbol minsym)
obj_section = minsym.obj_section (); obj_section = minsym.obj_section ();
if (iter != past_the_end if (iter != past_the_end
&& (MSYMBOL_VALUE_ADDRESS (minsym.objfile, iter) && (MSYMBOL_VALUE_ADDRESS (minsym.objfile, iter)
< obj_section_endaddr (obj_section))) < obj_section->endaddr ()))
result = MSYMBOL_VALUE_ADDRESS (minsym.objfile, iter); result = MSYMBOL_VALUE_ADDRESS (minsym.objfile, iter);
else else
/* We got the start address from the last msymbol in the objfile. /* We got the start address from the last msymbol in the objfile.
So the end address is the end of the section. */ So the end address is the end of the section. */
result = obj_section_endaddr (obj_section); result = obj_section->endaddr ();
return result; return result;
} }

View File

@ -729,7 +729,7 @@ objfile_relocate1 (struct objfile *objfile,
int idx = s - objfile->sections; int idx = s - objfile->sections;
exec_set_section_address (bfd_get_filename (objfile->obfd), idx, exec_set_section_address (bfd_get_filename (objfile->obfd), idx,
obj_section_addr (s)); s->addr ());
} }
/* Data changed. */ /* Data changed. */
@ -899,8 +899,8 @@ have_minimal_symbols (void)
static bool static bool
sort_cmp (const struct obj_section *sect1, const obj_section *sect2) sort_cmp (const struct obj_section *sect1, const obj_section *sect2)
{ {
const CORE_ADDR sect1_addr = obj_section_addr (sect1); const CORE_ADDR sect1_addr = sect1->addr ();
const CORE_ADDR sect2_addr = obj_section_addr (sect2); const CORE_ADDR sect2_addr = sect2->addr ();
if (sect1_addr < sect2_addr) if (sect1_addr < sect2_addr)
return true; return true;
@ -982,7 +982,7 @@ sort_cmp (const struct obj_section *sect1, const obj_section *sect2)
static struct obj_section * static struct obj_section *
preferred_obj_section (struct obj_section *a, struct obj_section *b) preferred_obj_section (struct obj_section *a, struct obj_section *b)
{ {
gdb_assert (obj_section_addr (a) == obj_section_addr (b)); gdb_assert (a->addr () == b->addr ());
gdb_assert ((a->objfile->separate_debug_objfile == b->objfile) gdb_assert ((a->objfile->separate_debug_objfile == b->objfile)
|| (b->objfile->separate_debug_objfile == a->objfile)); || (b->objfile->separate_debug_objfile == a->objfile));
gdb_assert ((a->objfile->separate_debug_objfile_backlink == b->objfile) gdb_assert ((a->objfile->separate_debug_objfile_backlink == b->objfile)
@ -1030,8 +1030,8 @@ filter_debuginfo_sections (struct obj_section **map, int map_size)
struct obj_section *const sect2 = map[i + 1]; struct obj_section *const sect2 = map[i + 1];
const struct objfile *const objfile1 = sect1->objfile; const struct objfile *const objfile1 = sect1->objfile;
const struct objfile *const objfile2 = sect2->objfile; const struct objfile *const objfile2 = sect2->objfile;
const CORE_ADDR sect1_addr = obj_section_addr (sect1); const CORE_ADDR sect1_addr = sect1->addr ();
const CORE_ADDR sect2_addr = obj_section_addr (sect2); const CORE_ADDR sect2_addr = sect2->addr ();
if (sect1_addr == sect2_addr if (sect1_addr == sect2_addr
&& (objfile1->separate_debug_objfile == objfile2 && (objfile1->separate_debug_objfile == objfile2
@ -1075,9 +1075,9 @@ filter_overlapping_sections (struct obj_section **map, int map_size)
{ {
struct obj_section *const sect1 = map[i]; struct obj_section *const sect1 = map[i];
struct obj_section *const sect2 = map[k]; struct obj_section *const sect2 = map[k];
const CORE_ADDR sect1_addr = obj_section_addr (sect1); const CORE_ADDR sect1_addr = sect1->addr ();
const CORE_ADDR sect2_addr = obj_section_addr (sect2); const CORE_ADDR sect2_addr = sect2->addr ();
const CORE_ADDR sect1_endaddr = obj_section_endaddr (sect1); const CORE_ADDR sect1_endaddr = sect1->endaddr ();
gdb_assert (sect1_addr <= sect2_addr); gdb_assert (sect1_addr <= sect2_addr);
@ -1093,7 +1093,7 @@ filter_overlapping_sections (struct obj_section **map, int map_size)
const struct bfd_section *const bfds1 = sect1->the_bfd_section; const struct bfd_section *const bfds1 = sect1->the_bfd_section;
const struct bfd_section *const bfds2 = sect2->the_bfd_section; const struct bfd_section *const bfds2 = sect2->the_bfd_section;
const CORE_ADDR sect2_endaddr = obj_section_endaddr (sect2); const CORE_ADDR sect2_endaddr = sect2->endaddr ();
struct gdbarch *const gdbarch = objf1->arch (); struct gdbarch *const gdbarch = objf1->arch ();
@ -1184,9 +1184,9 @@ bsearch_cmp (const void *key, const void *elt)
const CORE_ADDR pc = *(CORE_ADDR *) key; const CORE_ADDR pc = *(CORE_ADDR *) key;
const struct obj_section *section = *(const struct obj_section **) elt; const struct obj_section *section = *(const struct obj_section **) elt;
if (pc < obj_section_addr (section)) if (pc < section->addr ())
return -1; return -1;
if (pc < obj_section_endaddr (section)) if (pc < section->endaddr ())
return 0; return 0;
return 1; return 1;
} }
@ -1289,8 +1289,7 @@ is_addr_in_objfile (CORE_ADDR addr, const struct objfile *objfile)
if (section_is_overlay (osect) && !section_is_mapped (osect)) if (section_is_overlay (osect) && !section_is_mapped (osect))
continue; continue;
if (obj_section_addr (osect) <= addr if (osect->addr () <= addr && addr < osect->endaddr ())
&& addr < obj_section_endaddr (osect))
return true; return true;
} }
return false; return false;

View File

@ -127,37 +127,6 @@ struct entry_info
unsigned initialized : 1; unsigned initialized : 1;
}; };
/* Sections in an objfile. The section offsets are stored in the
OBJFILE. */
struct obj_section
{
/* BFD section pointer */
struct bfd_section *the_bfd_section;
/* Objfile this section is part of. */
struct objfile *objfile;
/* True if this "overlay section" is mapped into an "overlay region". */
int ovly_mapped;
};
/* Relocation offset applied to S. */
#define obj_section_offset(s) \
(((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) \
(bfd_section_vma (s->the_bfd_section) \
+ obj_section_offset (s))
/* The one-passed-the-end memory address of section S
(vma + size + offset). */
#define obj_section_endaddr(s) \
(bfd_section_vma (s->the_bfd_section) \
+ bfd_section_size ((s)->the_bfd_section) \
+ obj_section_offset (s))
#define ALL_OBJFILE_OSECTIONS(objfile, osect) \ #define ALL_OBJFILE_OSECTIONS(objfile, osect) \
for (osect = objfile->sections; osect < objfile->sections_end; osect++) \ for (osect = objfile->sections; osect < objfile->sections_end; osect++) \
if (osect->the_bfd_section == NULL) \ if (osect->the_bfd_section == NULL) \
@ -664,6 +633,27 @@ public:
/* See quick_symbol_functions. */ /* See quick_symbol_functions. */
void require_partial_symbols (bool verbose); void require_partial_symbols (bool verbose);
/* Return the relocation offset applied to SECTION. */
CORE_ADDR section_offset (bfd_section *section) const
{
/* The section's owner can be nullptr if it is one of the _bfd_std_section
section. */
gdb_assert (section->owner == nullptr || section->owner == this->obfd);
int idx = gdb_bfd_section_index (this->obfd, section);
return this->section_offsets[idx];
}
/* Set the relocation offset applied to SECTION. */
void set_section_offset (bfd_section *section, CORE_ADDR offset)
{
/* The section's owner can be nullptr if it is one of the _bfd_std_section
section. */
gdb_assert (section->owner == nullptr || section->owner == this->obfd);
int idx = gdb_bfd_section_index (this->obfd, section);
this->section_offsets[idx] = offset;
}
/* 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
@ -836,6 +826,47 @@ struct objfile_deleter
typedef std::unique_ptr<objfile, objfile_deleter> objfile_up; typedef std::unique_ptr<objfile, objfile_deleter> objfile_up;
/* Sections in an objfile. The section offsets are stored in the
OBJFILE. */
struct obj_section
{
/* Relocation offset applied to the section. */
CORE_ADDR offset () const
{
return this->objfile->section_offset (this->the_bfd_section);
}
/* Set the relocation offset applied to the section. */
void set_offset (CORE_ADDR offset)
{
this->objfile->set_section_offset (this->the_bfd_section, offset);
}
/* The memory address of the section (vma + offset). */
CORE_ADDR addr () const
{
return bfd_section_vma (this->the_bfd_section) + this->offset ();
}
/* The one-passed-the-end memory address of the section
(vma + size + offset). */
CORE_ADDR endaddr () const
{
return this->addr () + bfd_section_size (this->the_bfd_section);
}
/* BFD section pointer */
struct bfd_section *the_bfd_section;
/* Objfile this section is part of. */
struct objfile *objfile;
/* True if this "overlay section" is mapped into an "overlay region". */
int ovly_mapped;
};
/* Declarations for functions defined in objfiles.c */ /* Declarations for functions defined in objfiles.c */
extern int entry_point_address_query (CORE_ADDR *entry_p); extern int entry_point_address_query (CORE_ADDR *entry_p);

View File

@ -1525,8 +1525,7 @@ info_symbol_command (const char *arg, int from_tty)
sect_addr = overlay_mapped_address (addr, osect); sect_addr = overlay_mapped_address (addr, osect);
if (obj_section_addr (osect) <= sect_addr if (osect->addr () <= sect_addr && sect_addr < osect->endaddr ()
&& sect_addr < obj_section_endaddr (osect)
&& (msymbol && (msymbol
= lookup_minimal_symbol_by_pc_section (sect_addr, = lookup_minimal_symbol_by_pc_section (sect_addr,
osect).minsym)) osect).minsym))

View File

@ -685,8 +685,7 @@ solib_aix_get_toc_value (CORE_ADDR pc)
"(%s has no data section)"), "(%s has no data section)"),
core_addr_to_string (pc), objfile_name (pc_osect->objfile)); core_addr_to_string (pc), objfile_name (pc_osect->objfile));
result = (obj_section_addr (data_osect) result = data_osect->addr () + xcoff_get_toc_offset (pc_osect->objfile);
+ xcoff_get_toc_offset (pc_osect->objfile));
solib_aix_debug_printf ("pc=%s -> %s", core_addr_to_string (pc), solib_aix_debug_printf ("pc=%s -> %s", core_addr_to_string (pc),
core_addr_to_string (result)); core_addr_to_string (result));

View File

@ -925,7 +925,7 @@ dsbt_relocate_main_executable (void)
osect_idx = osect - objf->sections; osect_idx = osect - objf->sections;
/* Current address of section. */ /* Current address of section. */
addr = obj_section_addr (osect); addr = osect->addr ();
/* Offset from where this section started. */ /* Offset from where this section started. */
offset = objf->section_offsets[osect_idx]; offset = objf->section_offsets[osect_idx];
/* Original address prior to any past relocations. */ /* Original address prior to any past relocations. */

View File

@ -797,7 +797,7 @@ frv_relocate_main_executable (void)
osect_idx = osect - objf->sections; osect_idx = osect - objf->sections;
/* Current address of section. */ /* Current address of section. */
addr = obj_section_addr (osect); addr = osect->addr ();
/* Offset from where this section started. */ /* Offset from where this section started. */
offset = objf->section_offsets[osect_idx]; offset = objf->section_offsets[osect_idx];
/* Original address prior to any past relocations. */ /* Original address prior to any past relocations. */

View File

@ -3012,7 +3012,7 @@ pc_in_unmapped_range (CORE_ADDR pc, struct obj_section *section)
/* We assume the LMA is relocated by the same offset as the VMA. */ /* We assume the LMA is relocated by the same offset as the VMA. */
bfd_vma size = bfd_section_size (bfd_section); bfd_vma size = bfd_section_size (bfd_section);
CORE_ADDR offset = obj_section_offset (section); CORE_ADDR offset = section->offset ();
if (bfd_section_lma (bfd_section) + offset <= pc if (bfd_section_lma (bfd_section) + offset <= pc
&& pc < bfd_section_lma (bfd_section) + offset + size) && pc < bfd_section_lma (bfd_section) + offset + size)
@ -3030,8 +3030,8 @@ pc_in_mapped_range (CORE_ADDR pc, struct obj_section *section)
{ {
if (section_is_overlay (section)) if (section_is_overlay (section))
{ {
if (obj_section_addr (section) <= pc if (section->addr () <= pc
&& pc < obj_section_endaddr (section)) && pc < section->endaddr ())
return 1; return 1;
} }
@ -3044,10 +3044,10 @@ pc_in_mapped_range (CORE_ADDR pc, struct obj_section *section)
static int static int
sections_overlap (struct obj_section *a, struct obj_section *b) sections_overlap (struct obj_section *a, struct obj_section *b)
{ {
CORE_ADDR a_start = obj_section_addr (a); CORE_ADDR a_start = a->addr ();
CORE_ADDR a_end = obj_section_endaddr (a); CORE_ADDR a_end = a->endaddr ();
CORE_ADDR b_start = obj_section_addr (b); CORE_ADDR b_start = b->addr ();
CORE_ADDR b_end = obj_section_endaddr (b); CORE_ADDR b_end = b->endaddr ();
return (a_start < b_end && b_start < a_end); return (a_start < b_end && b_start < a_end);
} }

View File

@ -1698,8 +1698,7 @@ fixup_section (struct general_symbol_info *ginfo,
if (fallback == -1) if (fallback == -1)
fallback = idx; fallback = idx;
if (obj_section_addr (s) - offset <= addr if (s->addr () - offset <= addr && addr < s->endaddr () - offset)
&& addr < obj_section_endaddr (s) - offset)
{ {
ginfo->set_section_index (idx); ginfo->set_section_index (idx);
return; return;

View File

@ -747,7 +747,7 @@ tilegx_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
s = find_pc_section (start_pc); s = find_pc_section (start_pc);
end_pc = start_pc + 8 * TILEGX_BUNDLE_SIZE_IN_BYTES; end_pc = start_pc + 8 * TILEGX_BUNDLE_SIZE_IN_BYTES;
if (s != NULL) if (s != NULL)
end_pc = std::min (end_pc, obj_section_endaddr (s)); end_pc = std::min (end_pc, s->endaddr ());
/* Otherwise, try to skip prologue the hard way. */ /* Otherwise, try to skip prologue the hard way. */
return tilegx_analyze_prologue (gdbarch, return tilegx_analyze_prologue (gdbarch,

View File

@ -178,7 +178,7 @@ tui_find_backward_disassembly_start_address (CORE_ADDR addr)
section. */ section. */
struct obj_section *section = find_pc_section (addr); struct obj_section *section = find_pc_section (addr);
if (section != NULL) if (section != NULL)
return obj_section_addr (section); return section->addr ();
return addr; return addr;
} }

View File

@ -562,8 +562,8 @@ xstormy16_find_jmp_table_entry (struct gdbarch *gdbarch, CORE_ADDR faddr)
{ {
CORE_ADDR addr, endaddr; CORE_ADDR addr, endaddr;
addr = obj_section_addr (osect); addr = osect->addr ();
endaddr = obj_section_endaddr (osect); endaddr = osect->endaddr ();
for (; addr < endaddr; addr += 2 * xstormy16_inst_size) for (; addr < endaddr; addr += 2 * xstormy16_inst_size)
{ {