static struct obj_section *
arm_obj_section_from_vma (struct objfile *objfile, bfd_vma vma)
{
- struct obj_section *osect;
-
- ALL_OBJFILE_OSECTIONS (objfile, osect)
+ for (obj_section *osect : objfile->sections ())
if (bfd_section_flags (osect->the_bfd_section) & SEC_ALLOC)
{
bfd_vma start, size;
void
program_space::add_target_sections (struct objfile *objfile)
{
- struct obj_section *osect;
-
gdb_assert (objfile != nullptr);
/* Compute the number of sections to add. */
- ALL_OBJFILE_OSECTIONS (objfile, osect)
+ for (obj_section *osect : objfile->sections ())
{
if (bfd_section_size (osect->the_bfd_section) == 0)
continue;
{
/* See if this region of memory lies inside a known file on disk.
If so, we can avoid copying its contents by clearing SEC_LOAD. */
- struct obj_section *objsec;
for (objfile *objfile : current_program_space->objfiles ())
- ALL_OBJFILE_OSECTIONS (objfile, objsec)
+ for (obj_section *objsec : objfile->sections ())
{
bfd *abfd = objfile->obfd.get ();
asection *asec = objsec->the_bfd_section;
find_memory_region_ftype func, void *obfd)
{
/* Use objfile data to create memory sections. */
- struct obj_section *objsec;
bfd_vma temp_bottom, temp_top;
/* Call callback function for each objfile section. */
for (objfile *objfile : current_program_space->objfiles ())
- ALL_OBJFILE_OSECTIONS (objfile, objsec)
+ for (obj_section *objsec : objfile->sections ())
{
asection *isec = objsec->the_bfd_section;
flagword flags = bfd_section_flags (isec);
faddr_sec = find_pc_section (faddr);
if (faddr_sec != NULL)
{
- struct obj_section *sec;
-
- ALL_OBJFILE_OSECTIONS (faddr_sec->objfile, sec)
+ for (struct obj_section *sec : faddr_sec->objfile->sections ())
{
if (strcmp (sec->the_bfd_section->name, ".dynamic") == 0)
- break;
- }
-
- if (sec < faddr_sec->objfile->sections_end)
- {
- CORE_ADDR addr = sec->addr ();
- CORE_ADDR endaddr = sec->endaddr ();
-
- while (addr < endaddr)
{
- gdb_byte buf[4];
- LONGEST tag;
-
- if (target_read_memory (addr, buf, sizeof buf) != 0)
- break;
+ CORE_ADDR addr = sec->addr ();
+ CORE_ADDR endaddr = sec->endaddr ();
- tag = extract_signed_integer (buf, byte_order);
- if (tag == DT_PLTGOT)
+ while (addr < endaddr)
{
- CORE_ADDR pltgot;
+ gdb_byte buf[4];
+ LONGEST tag;
- if (target_read_memory (addr + 4, buf, sizeof buf) != 0)
+ if (target_read_memory (addr, buf, sizeof buf) != 0)
break;
- /* The NetBSD/OpenBSD ld.so doesn't relocate DT_PLTGOT, so
- we have to do it ourselves. */
- pltgot = extract_unsigned_integer (buf, sizeof buf,
- byte_order);
- pltgot += sec->objfile->text_section_offset ();
+ tag = extract_signed_integer (buf, byte_order);
+ if (tag == DT_PLTGOT)
+ {
+ CORE_ADDR pltgot;
- return pltgot;
- }
+ if (target_read_memory (addr + 4, buf, sizeof buf) != 0)
+ break;
+
+ /* The NetBSD/OpenBSD ld.so doesn't relocate
+ DT_PLTGOT, so we have to do it ourselves. */
+ pltgot = extract_unsigned_integer (buf, sizeof buf,
+ byte_order);
+ pltgot += sec->objfile->text_section_offset ();
+
+ return pltgot;
+ }
- if (tag == DT_NULL)
- break;
+ if (tag == DT_NULL)
+ break;
+
+ addr += 8;
+ }
- addr += 8;
+ break;
}
}
}
faddr_sect = find_pc_section (faddr);
if (faddr_sect != NULL)
{
- struct obj_section *osect;
-
- ALL_OBJFILE_OSECTIONS (faddr_sect->objfile, osect)
+ for (obj_section *osect : faddr_sect->objfile->sections ())
{
if (strcmp (osect->the_bfd_section->name, ".dynamic") == 0)
- break;
- }
-
- if (osect < faddr_sect->objfile->sections_end)
- {
- CORE_ADDR addr, endaddr;
-
- addr = osect->addr ();
- endaddr = osect->endaddr ();
-
- while (addr < endaddr)
{
- int status;
- LONGEST tag;
- gdb_byte buf[4];
+ CORE_ADDR addr, endaddr;
- status = target_read_memory (addr, buf, sizeof (buf));
- if (status != 0)
- break;
- tag = extract_signed_integer (buf, byte_order);
+ addr = osect->addr ();
+ endaddr = osect->endaddr ();
- if (tag == DT_PLTGOT)
+ while (addr < endaddr)
{
- CORE_ADDR global_pointer;
+ int status;
+ LONGEST tag;
+ gdb_byte buf[4];
- status = target_read_memory (addr + 4, buf, sizeof (buf));
+ status = target_read_memory (addr, buf, sizeof (buf));
if (status != 0)
break;
- global_pointer = extract_unsigned_integer (buf, sizeof (buf),
- byte_order);
- /* The payoff... */
- return global_pointer;
- }
-
- if (tag == DT_NULL)
- break;
+ tag = extract_signed_integer (buf, byte_order);
+
+ if (tag == DT_PLTGOT)
+ {
+ CORE_ADDR global_pointer;
+
+ status = target_read_memory (addr + 4, buf,
+ sizeof (buf));
+ if (status != 0)
+ break;
+ global_pointer
+ = extract_unsigned_integer (buf, sizeof (buf),
+ byte_order);
+ /* The payoff... */
+ return global_pointer;
+ }
+
+ if (tag == DT_NULL)
+ break;
- addr += 8;
+ addr += 8;
+ }
+ break;
}
}
}
hppa64_convert_code_addr_to_fptr (struct gdbarch *gdbarch, CORE_ADDR code)
{
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
- struct obj_section *sec, *opd;
+ struct obj_section *sec;
sec = find_pc_section (code);
if (!(sec->the_bfd_section->flags & SEC_CODE))
return code;
- ALL_OBJFILE_OSECTIONS (sec->objfile, opd)
+ for (obj_section *opd : sec->objfile->sections ())
{
if (strcmp (opd->the_bfd_section->name, ".opd") == 0)
- break;
- }
-
- if (opd < sec->objfile->sections_end)
- {
- for (CORE_ADDR addr = opd->addr (); addr < opd->endaddr (); addr += 2 * 8)
{
- ULONGEST opdaddr;
- gdb_byte tmp[8];
+ for (CORE_ADDR addr = opd->addr ();
+ addr < opd->endaddr ();
+ addr += 2 * 8)
+ {
+ ULONGEST opdaddr;
+ gdb_byte tmp[8];
- if (target_read_memory (addr, tmp, sizeof (tmp)))
- break;
- opdaddr = extract_unsigned_integer (tmp, sizeof (tmp), byte_order);
+ if (target_read_memory (addr, tmp, sizeof (tmp)))
+ break;
+ opdaddr = extract_unsigned_integer (tmp, sizeof (tmp), byte_order);
- if (opdaddr == code)
- return addr - 16;
+ if (opdaddr == code)
+ return addr - 16;
+ }
}
}
faddr_sect = find_pc_section (faddr);
if (faddr_sect != NULL)
{
- struct obj_section *osect;
-
- ALL_OBJFILE_OSECTIONS (faddr_sect->objfile, osect)
+ for (obj_section *osect : faddr_sect->objfile->sections ())
{
if (strcmp (osect->the_bfd_section->name, ".dynamic") == 0)
- break;
- }
-
- if (osect < faddr_sect->objfile->sections_end)
- {
- CORE_ADDR addr = osect->addr ();
- CORE_ADDR endaddr = osect->endaddr ();
-
- while (addr < endaddr)
{
- int status;
- LONGEST tag;
- gdb_byte buf[8];
+ CORE_ADDR addr = osect->addr ();
+ CORE_ADDR endaddr = osect->endaddr ();
- status = target_read_memory (addr, buf, sizeof (buf));
- if (status != 0)
- break;
- tag = extract_signed_integer (buf, byte_order);
-
- if (tag == DT_PLTGOT)
+ while (addr < endaddr)
{
- CORE_ADDR global_pointer;
+ int status;
+ LONGEST tag;
+ gdb_byte buf[8];
- status = target_read_memory (addr + 8, buf, sizeof (buf));
+ status = target_read_memory (addr, buf, sizeof (buf));
if (status != 0)
break;
- global_pointer = extract_unsigned_integer (buf, sizeof (buf),
- byte_order);
+ tag = extract_signed_integer (buf, byte_order);
- /* The payoff... */
- return global_pointer;
- }
+ if (tag == DT_PLTGOT)
+ {
+ CORE_ADDR global_pointer;
+
+ status = target_read_memory (addr + 8, buf,
+ sizeof (buf));
+ if (status != 0)
+ break;
+ global_pointer
+ = extract_unsigned_integer (buf, sizeof (buf),
+ byte_order);
+
+ /* The payoff... */
+ return global_pointer;
+ }
+
+ if (tag == DT_NULL)
+ break;
- if (tag == DT_NULL)
- break;
+ addr += 16;
+ }
- addr += 16;
+ break;
}
}
}
if (faddr_sect != NULL)
{
- struct obj_section *osect;
- ALL_OBJFILE_OSECTIONS (faddr_sect->objfile, osect)
+ for (obj_section *osect : faddr_sect->objfile->sections ())
{
if (strcmp (osect->the_bfd_section->name, ".opd") == 0)
- break;
- }
+ {
+ CORE_ADDR addr = osect->addr ();
+ CORE_ADDR endaddr = osect->endaddr ();
- if (osect < faddr_sect->objfile->sections_end)
- {
- CORE_ADDR addr = osect->addr ();
- CORE_ADDR endaddr = osect->endaddr ();
+ while (addr < endaddr)
+ {
+ int status;
+ LONGEST faddr2;
+ gdb_byte buf[8];
- while (addr < endaddr)
- {
- int status;
- LONGEST faddr2;
- gdb_byte buf[8];
+ status = target_read_memory (addr, buf, sizeof (buf));
+ if (status != 0)
+ break;
+ faddr2 = extract_signed_integer (buf, byte_order);
- status = target_read_memory (addr, buf, sizeof (buf));
- if (status != 0)
- break;
- faddr2 = extract_signed_integer (buf, byte_order);
+ if (faddr == faddr2)
+ return addr;
- if (faddr == faddr2)
- return addr;
+ addr += 16;
+ }
- addr += 16;
+ break;
}
}
}
const section_addr_info &addrs)
{
unsigned int i;
- struct obj_section *osect;
/* Allocate section_offsets. */
objfile->section_offsets.assign (gdb_bfd_count_sections (objfile->obfd.get ()), 0);
for (i = 0; i < addrs.size (); i++)
{
- ALL_OBJFILE_OSECTIONS (objfile, osect)
+ for (obj_section *osect : objfile->sections ())
{
const char *bfd_sect_name = osect->the_bfd_section->name;
objfile->sect_index_text = 0;
- ALL_OBJFILE_OSECTIONS (objfile, osect)
+ for (obj_section *osect : objfile->sections ())
{
const char *bfd_sect_name = osect->the_bfd_section->name;
int sect_index = osect - objfile->sections_start;
p = skip_spaces (p + 1);
for (objfile *objfile : current_program_space->objfiles ())
- ALL_OBJFILE_OSECTIONS (objfile, sect)
+ for (obj_section *iter : objfile->sections ())
{
- if (strncmp (sect->the_bfd_section->name, arg, arg_len) == 0)
+ if (strncmp (iter->the_bfd_section->name, arg, arg_len) == 0)
goto found;
}
frob_address (struct objfile *objfile, CORE_ADDR pc,
unrelocated_addr *unrel_addr)
{
- struct obj_section *iter;
-
- ALL_OBJFILE_OSECTIONS (objfile, iter)
+ for (obj_section *iter : objfile->sections ())
{
if (pc >= iter->addr () && pc < iter->endaddr ())
{
get_objfile_pspace_data (objfile->pspace)->section_map_dirty = 1;
/* Update the table in exec_ops, used to read memory. */
- struct obj_section *s;
- ALL_OBJFILE_OSECTIONS (objfile, s)
+ for (obj_section *s : objfile->sections ())
{
int idx = s - objfile->sections_start;
second case shouldn't occur during normal use, but std::sort
does check that '!(a < a)' when compiled in debug mode. */
- const struct obj_section *osect;
-
- ALL_OBJFILE_OSECTIONS (objfile1, osect)
+ for (const obj_section *osect : objfile1->sections ())
if (osect == sect2)
return false;
else if (osect == sect1)
{
struct objfile_pspace_info *pspace_info;
int alloc_size, map_size, i;
- struct obj_section *s, **map;
+ struct obj_section **map;
pspace_info = get_objfile_pspace_data (pspace);
gdb_assert (pspace_info->section_map_dirty != 0
alloc_size = 0;
for (objfile *objfile : pspace->objfiles ())
- ALL_OBJFILE_OSECTIONS (objfile, s)
+ for (obj_section *s : objfile->sections ())
if (insert_section_p (objfile->obfd.get (), s->the_bfd_section))
alloc_size += 1;
i = 0;
for (objfile *objfile : pspace->objfiles ())
- ALL_OBJFILE_OSECTIONS (objfile, s)
+ for (obj_section *s : objfile->sections ())
if (insert_section_p (objfile->obfd.get (), s->the_bfd_section))
map[i++] = s;
bool
is_addr_in_objfile (CORE_ADDR addr, const struct objfile *objfile)
{
- struct obj_section *osect;
-
if (objfile == NULL)
return false;
- ALL_OBJFILE_OSECTIONS (objfile, osect)
+ for (obj_section *osect : objfile->sections ())
{
if (section_is_overlay (osect) && !section_is_mapped (osect))
continue;
unsigned initialized : 1;
};
-#define ALL_OBJFILE_OSECTIONS(objfile, osect) \
- for (osect = objfile->sections_start; 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 (_("sect_index_data not initialized")), -1) \
typedef iterator_range<separate_debug_iterator> separate_debug_range;
+/* 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;
+
+ /* Set the relocation offset applied to the section. */
+ void set_offset (CORE_ADDR 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;
+};
+
/* Master structure for keeping track of each file from which
gdb reads symbols. There are several ways these get allocated: 1.
The main symbol file, symfile_objfile, set by the symbol-file command,
this->section_offsets[idx] = offset;
}
+ class section_iterator
+ {
+ public:
+ section_iterator (const section_iterator &) = default;
+ section_iterator (section_iterator &&) = default;
+ section_iterator &operator= (const section_iterator &) = default;
+ section_iterator &operator= (section_iterator &&) = default;
+
+ typedef section_iterator self_type;
+ typedef obj_section *value_type;
+
+ value_type operator* ()
+ { return m_iter; }
+
+ section_iterator &operator++ ()
+ {
+ ++m_iter;
+ skip_null ();
+ return *this;
+ }
+
+ bool operator== (const section_iterator &other) const
+ { return m_iter == other.m_iter && m_end == other.m_end; }
+
+ bool operator!= (const section_iterator &other) const
+ { return !(*this == other); }
+
+ private:
+
+ friend class objfile;
+
+ section_iterator (obj_section *iter, obj_section *end)
+ : m_iter (iter),
+ m_end (end)
+ {
+ skip_null ();
+ }
+
+ void skip_null ()
+ {
+ while (m_iter < m_end && m_iter->the_bfd_section == nullptr)
+ ++m_iter;
+ }
+
+ value_type m_iter;
+ value_type m_end;
+ };
+
+ iterator_range<section_iterator> sections ()
+ {
+ return (iterator_range<section_iterator>
+ (section_iterator (sections_start, sections_end),
+ section_iterator (sections_end, sections_end)));
+ }
+
+ iterator_range<section_iterator> sections () const
+ {
+ return (iterator_range<section_iterator>
+ (section_iterator (sections_start, sections_end),
+ section_iterator (sections_end, sections_end)));
+ }
+
private:
/* Ensure that partial symbols have been read and return the "quick" (aka
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. */
+inline CORE_ADDR
+obj_section::offset () const
{
- /* 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;
+ return this->objfile->section_offset (this->the_bfd_section);
+}
- /* True if this "overlay section" is mapped into an "overlay region". */
- int ovly_mapped;
-};
+/* Set the relocation offset applied to the section. */
+inline void
+obj_section::set_offset (CORE_ADDR offset)
+{
+ this->objfile->set_section_offset (this->the_bfd_section, offset);
+}
/* Declarations for functions defined in objfiles.c */
info_symbol_command (const char *arg, int from_tty)
{
struct minimal_symbol *msymbol;
- struct obj_section *osect;
CORE_ADDR addr, sect_addr;
int matches = 0;
unsigned int offset;
addr = parse_and_eval_address (arg);
for (objfile *objfile : current_program_space->objfiles ())
- ALL_OBJFILE_OSECTIONS (objfile, osect)
+ for (obj_section *osect : objfile->sections ())
{
/* Only process each object file once, even if there's a separate
debug file. */
static struct obj_section *
data_obj_section_from_objfile (struct objfile *objfile)
{
- struct obj_section *osect;
-
- ALL_OBJFILE_OSECTIONS (objfile, osect)
+ for (obj_section *osect : objfile->sections ())
if (strcmp (bfd_section_name (osect->the_bfd_section), ".data") == 0)
return osect;
{
struct int_elf32_dsbt_loadmap *ldm;
int changed;
- struct obj_section *osect;
struct dsbt_info *info = get_dsbt_info ();
dsbt_get_initial_loadmaps ();
section_offsets new_offsets (objf->section_offsets.size ());
changed = 0;
- ALL_OBJFILE_OSECTIONS (objf, osect)
+ for (obj_section *osect : objf->sections ())
{
CORE_ADDR orig_addr, addr, offset;
int osect_idx;
CORE_ADDR exec_addr, interp_addr;
struct int_elf32_fdpic_loadmap *ldm;
int changed;
- struct obj_section *osect;
status = frv_fdpic_loadmap_addresses (target_gdbarch (),
&interp_addr, &exec_addr);
section_offsets new_offsets (objf->section_offsets.size ());
changed = 0;
- ALL_OBJFILE_OSECTIONS (objf, osect)
+ for (obj_section *osect : objf->sections ())
{
CORE_ADDR orig_addr, addr, offset;
int osect_idx;
if (ei->entry_point_p)
{
- struct obj_section *osect;
CORE_ADDR entry_point = ei->entry_point;
int found;
= gdbarch_addr_bits_remove (objfile->arch (), entry_point);
found = 0;
- ALL_OBJFILE_OSECTIONS (objfile, osect)
+ for (obj_section *osect : objfile->sections ())
{
struct bfd_section *sect = osect->the_bfd_section;
static void
overlay_invalidate_all (void)
{
- struct obj_section *sect;
-
for (objfile *objfile : current_program_space->objfiles ())
- ALL_OBJFILE_OSECTIONS (objfile, sect)
+ for (obj_section *sect : objfile->sections ())
if (section_is_overlay (sect))
sect->ovly_mapped = -1;
}
struct obj_section *
find_pc_overlay (CORE_ADDR pc)
{
- struct obj_section *osect, *best_match = NULL;
+ struct obj_section *best_match = NULL;
if (overlay_debugging)
{
for (objfile *objfile : current_program_space->objfiles ())
- ALL_OBJFILE_OSECTIONS (objfile, osect)
+ for (obj_section *osect : objfile->sections ())
if (section_is_overlay (osect))
{
if (pc_in_mapped_range (pc, osect))
struct obj_section *
find_pc_mapped_section (CORE_ADDR pc)
{
- struct obj_section *osect;
-
if (overlay_debugging)
{
for (objfile *objfile : current_program_space->objfiles ())
- ALL_OBJFILE_OSECTIONS (objfile, osect)
+ for (obj_section *osect : objfile->sections ())
if (pc_in_mapped_range (pc, osect) && section_is_mapped (osect))
return osect;
}
list_overlays_command (const char *args, int from_tty)
{
int nmapped = 0;
- struct obj_section *osect;
if (overlay_debugging)
{
for (objfile *objfile : current_program_space->objfiles ())
- ALL_OBJFILE_OSECTIONS (objfile, osect)
+ for (obj_section *osect : objfile->sections ())
if (section_is_mapped (osect))
{
struct gdbarch *gdbarch = objfile->arch ();
static void
map_overlay_command (const char *args, int from_tty)
{
- struct obj_section *sec, *sec2;
-
if (!overlay_debugging)
error (_("Overlay debugging not enabled. Use "
"either the 'overlay auto' or\n"
/* First, find a section matching the user supplied argument. */
for (objfile *obj_file : current_program_space->objfiles ())
- ALL_OBJFILE_OSECTIONS (obj_file, sec)
+ for (obj_section *sec : obj_file->sections ())
if (!strcmp (bfd_section_name (sec->the_bfd_section), args))
{
/* Now, check to see if the section is an overlay. */
/* Next, make a pass and unmap any sections that are
overlapped by this new section: */
for (objfile *objfile2 : current_program_space->objfiles ())
- ALL_OBJFILE_OSECTIONS (objfile2, sec2)
+ for (obj_section *sec2 : objfile2->sections ())
if (sec2->ovly_mapped && sec != sec2 && sections_overlap (sec,
sec2))
{
static void
unmap_overlay_command (const char *args, int from_tty)
{
- struct obj_section *sec = NULL;
-
if (!overlay_debugging)
error (_("Overlay debugging not enabled. "
"Use either the 'overlay auto' or\n"
/* First, find a section matching the user supplied argument. */
for (objfile *objfile : current_program_space->objfiles ())
- ALL_OBJFILE_OSECTIONS (objfile, sec)
+ for (obj_section *sec : objfile->sections ())
if (!strcmp (bfd_section_name (sec->the_bfd_section), args))
{
if (!sec->ovly_mapped)
/* Now may as well update all sections, even if only one was requested. */
for (objfile *objfile : current_program_space->objfiles ())
- ALL_OBJFILE_OSECTIONS (objfile, osect)
- if (section_is_overlay (osect))
+ for (obj_section *sect : objfile->sections ())
+ if (section_is_overlay (sect))
{
int i;
- asection *bsect = osect->the_bfd_section;
+ asection *bsect = sect->the_bfd_section;
for (i = 0; i < cache_novlys; i++)
if (cache_ovly_table[i][VMA] == bfd_section_vma (bsect)
&& cache_ovly_table[i][LMA] == bfd_section_lma (bsect))
{ /* obj_section matches i'th entry in ovly_table. */
- osect->ovly_mapped = cache_ovly_table[i][MAPPED];
+ sect->ovly_mapped = cache_ovly_table[i][MAPPED];
break; /* finished with inner for loop: break out. */
}
}
this reason, we still attempt a lookup by name prior to doing
a search of the section table. */
- struct obj_section *s;
-
- ALL_OBJFILE_OSECTIONS (objfile, s)
+ for (obj_section *s : objfile->sections ())
{
if ((bfd_section_flags (s->the_bfd_section) & SEC_ALLOC) == 0)
continue;
if (faddr_sect)
{
- struct obj_section *osect;
-
/* Return faddr if it's already a pointer to a jump table entry. */
if (!strcmp (faddr_sect->the_bfd_section->name, ".plt"))
return faddr;
- ALL_OBJFILE_OSECTIONS (faddr_sect->objfile, osect)
- {
- if (!strcmp (osect->the_bfd_section->name, ".plt"))
- break;
- }
-
- if (osect < faddr_sect->objfile->sections_end)
+ for (obj_section *osect : faddr_sect->objfile->sections ())
{
- CORE_ADDR addr, endaddr;
-
- addr = osect->addr ();
- endaddr = osect->endaddr ();
-
- for (; addr < endaddr; addr += 2 * xstormy16_inst_size)
+ if (!strcmp (osect->the_bfd_section->name, ".plt"))
{
- LONGEST inst, inst2, faddr2;
- gdb_byte buf[2 * xstormy16_inst_size];
+ CORE_ADDR addr, endaddr;
+
+ addr = osect->addr ();
+ endaddr = osect->endaddr ();
+
+ for (; addr < endaddr; addr += 2 * xstormy16_inst_size)
+ {
+ LONGEST inst, inst2, faddr2;
+ gdb_byte buf[2 * xstormy16_inst_size];
+
+ if (target_read_memory (addr, buf, sizeof buf))
+ return 0;
+ inst = extract_unsigned_integer (buf,
+ xstormy16_inst_size,
+ byte_order);
+ inst2 = extract_unsigned_integer (buf + xstormy16_inst_size,
+ xstormy16_inst_size,
+ byte_order);
+ faddr2 = inst2 << 8 | (inst & 0xff);
+ if (faddr == faddr2)
+ return addr;
+ }
- if (target_read_memory (addr, buf, sizeof buf))
- return 0;
- inst = extract_unsigned_integer (buf,
- xstormy16_inst_size,
- byte_order);
- inst2 = extract_unsigned_integer (buf + xstormy16_inst_size,
- xstormy16_inst_size,
- byte_order);
- faddr2 = inst2 << 8 | (inst & 0xff);
- if (faddr == faddr2)
- return addr;
+ break;
}
}
}
/* we have interest for sections with same VMA */
for (objfile *objfile : current_program_space->objfiles ())
- ALL_OBJFILE_OSECTIONS (objfile, osect)
- if (section_is_overlay (osect))
+ for (obj_section *sect : objfile->sections ())
+ if (section_is_overlay (sect))
{
- osect->ovly_mapped = (lma == bfd_section_lma (osect->the_bfd_section));
- i |= osect->ovly_mapped; /* true, if at least one section is mapped */
+ sect->ovly_mapped = (lma == bfd_section_lma (sect->the_bfd_section));
+ i |= sect->ovly_mapped; /* true, if at least one section is mapped */
}
return i;
}
/* Update all sections, even if only one was requested. */
for (objfile *objfile : current_program_space->objfiles ())
- ALL_OBJFILE_OSECTIONS (objfile, osect)
+ for (obj_section *sect : objfile->sections ())
{
- if (!section_is_overlay (osect))
+ if (!section_is_overlay (sect))
continue;
- asection *bsect = osect->the_bfd_section;
+ asection *bsect = sect->the_bfd_section;
bfd_vma lma = bfd_section_lma (bsect);
bfd_vma vma = bfd_section_vma (bsect);
for (int i = 0; i < cache_novly_regions; ++i)
if (cache_ovly_region_table[i][Z80_VMA] == vma)
- osect->ovly_mapped =
+ sect->ovly_mapped =
(cache_ovly_region_table[i][Z80_MAPPED_TO_LMA] == lma);
}
}