mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-05 15:15:42 +00:00
Add obj_section::contains method
I noticed a number of spots checking whether an address is in an obj_section. This patch introduces a new method for this and changes some code to use it. Regression tested on x86-64 Fedora 38. Approved-By: Andrew Burgess <aburgess@redhat.com>
This commit is contained in:
@@ -716,7 +716,7 @@ frob_address (struct objfile *objfile, CORE_ADDR pc,
|
|||||||
{
|
{
|
||||||
for (obj_section *iter : objfile->sections ())
|
for (obj_section *iter : objfile->sections ())
|
||||||
{
|
{
|
||||||
if (pc >= iter->addr () && pc < iter->endaddr ())
|
if (iter->contains (pc))
|
||||||
{
|
{
|
||||||
*unrel_addr = unrelocated_addr (pc - iter->offset ());
|
*unrel_addr = unrelocated_addr (pc - iter->offset ());
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -1213,7 +1213,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 (osect->addr () <= addr && addr < osect->endaddr ())
|
if (osect->contains (addr))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -394,6 +394,12 @@ struct obj_section
|
|||||||
return this->addr () + bfd_section_size (this->the_bfd_section);
|
return this->addr () + bfd_section_size (this->the_bfd_section);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* True if ADDR is in this obj_section, false otherwise. */
|
||||||
|
bool contains (CORE_ADDR addr) const
|
||||||
|
{
|
||||||
|
return addr >= this->addr () && addr < endaddr ();
|
||||||
|
}
|
||||||
|
|
||||||
/* BFD section pointer */
|
/* BFD section pointer */
|
||||||
struct bfd_section *the_bfd_section;
|
struct bfd_section *the_bfd_section;
|
||||||
|
|
||||||
|
|||||||
@@ -1499,7 +1499,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 (osect->addr () <= sect_addr && sect_addr < osect->endaddr ()
|
if (osect->contains (sect_addr)
|
||||||
&& (msymbol
|
&& (msymbol
|
||||||
= lookup_minimal_symbol_by_pc_section (sect_addr,
|
= lookup_minimal_symbol_by_pc_section (sect_addr,
|
||||||
osect).minsym))
|
osect).minsym))
|
||||||
|
|||||||
@@ -3085,8 +3085,7 @@ pc_in_mapped_range (CORE_ADDR pc, struct obj_section *section)
|
|||||||
{
|
{
|
||||||
if (section_is_overlay (section))
|
if (section_is_overlay (section))
|
||||||
{
|
{
|
||||||
if (section->addr () <= pc
|
if (section->contains (pc))
|
||||||
&& pc < section->endaddr ())
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user