static struct obj_section *
arm_obj_section_from_vma (struct objfile *objfile, bfd_vma vma)
{
- for (obj_section *osect : objfile->sections ())
- if (bfd_section_flags (osect->the_bfd_section) & SEC_ALLOC)
+ for (obj_section &osect : objfile->sections ())
+ if (bfd_section_flags (osect.the_bfd_section) & SEC_ALLOC)
{
bfd_vma start, size;
- start = bfd_section_vma (osect->the_bfd_section);
- size = bfd_section_size (osect->the_bfd_section);
+ start = bfd_section_vma (osect.the_bfd_section);
+ size = bfd_section_size (osect.the_bfd_section);
if (start <= vma && vma < start + size)
- return osect;
+ return &osect;
}
return NULL;
gdb_assert (objfile != nullptr);
/* Compute the number of sections to add. */
- for (obj_section *osect : objfile->sections ())
+ for (obj_section &osect : objfile->sections ())
{
- if (bfd_section_size (osect->the_bfd_section) == 0)
+ if (bfd_section_size (osect.the_bfd_section) == 0)
continue;
- m_target_sections.emplace_back (osect->addr (), osect->endaddr (),
- osect->the_bfd_section, objfile);
+ m_target_sections.emplace_back (osect.addr (), osect.endaddr (),
+ osect.the_bfd_section, objfile);
}
}
If so, we can avoid copying its contents by clearing SEC_LOAD. */
for (objfile *objfile : current_program_space->objfiles ())
- for (obj_section *objsec : objfile->sections ())
+ for (obj_section &objsec : objfile->sections ())
{
bfd *abfd = objfile->obfd.get ();
- asection *asec = objsec->the_bfd_section;
+ asection *asec = objsec.the_bfd_section;
bfd_vma align = (bfd_vma) 1 << bfd_section_alignment (asec);
- bfd_vma start = objsec->addr () & -align;
- bfd_vma end = (objsec->endaddr () + align - 1) & -align;
+ bfd_vma start = objsec.addr () & -align;
+ bfd_vma end = (objsec.endaddr () + align - 1) & -align;
/* Match if either the entire memory region lies inside the
section (i.e. a mapping covering some pages of a large
/* Call callback function for each objfile section. */
for (objfile *objfile : current_program_space->objfiles ())
- for (obj_section *objsec : objfile->sections ())
+ for (obj_section &objsec : objfile->sections ())
{
- asection *isec = objsec->the_bfd_section;
+ asection *isec = objsec.the_bfd_section;
flagword flags = bfd_section_flags (isec);
/* Separate debug info files are irrelevant for gcore. */
int size = bfd_section_size (isec);
int ret;
- ret = (*func) (objsec->addr (), size,
+ ret = (*func) (objsec.addr (), size,
1, /* All sections will be readable. */
(flags & SEC_READONLY) == 0, /* Writable. */
(flags & SEC_CODE) != 0, /* Executable. */
faddr_sec = find_pc_section (faddr);
if (faddr_sec != NULL)
{
- for (struct obj_section *sec : faddr_sec->objfile->sections ())
+ for (struct obj_section &sec : faddr_sec->objfile->sections ())
{
- if (strcmp (sec->the_bfd_section->name, ".dynamic") == 0)
+ if (strcmp (sec.the_bfd_section->name, ".dynamic") == 0)
{
- CORE_ADDR addr = sec->addr ();
- CORE_ADDR endaddr = sec->endaddr ();
+ CORE_ADDR addr = sec.addr ();
+ CORE_ADDR endaddr = sec.endaddr ();
while (addr < endaddr)
{
DT_PLTGOT, so we have to do it ourselves. */
pltgot = extract_unsigned_integer (buf, sizeof buf,
byte_order);
- pltgot += sec->objfile->text_section_offset ();
+ pltgot += sec.objfile->text_section_offset ();
return pltgot;
}
faddr_sect = find_pc_section (faddr);
if (faddr_sect != NULL)
{
- for (obj_section *osect : faddr_sect->objfile->sections ())
+ for (obj_section &osect : faddr_sect->objfile->sections ())
{
- if (strcmp (osect->the_bfd_section->name, ".dynamic") == 0)
+ if (strcmp (osect.the_bfd_section->name, ".dynamic") == 0)
{
CORE_ADDR addr, endaddr;
- addr = osect->addr ();
- endaddr = osect->endaddr ();
+ addr = osect.addr ();
+ endaddr = osect.endaddr ();
while (addr < endaddr)
{
if (!(sec->the_bfd_section->flags & SEC_CODE))
return code;
- for (obj_section *opd : sec->objfile->sections ())
+ for (obj_section &opd : sec->objfile->sections ())
{
- if (strcmp (opd->the_bfd_section->name, ".opd") == 0)
+ if (strcmp (opd.the_bfd_section->name, ".opd") == 0)
{
- for (CORE_ADDR addr = opd->addr ();
- addr < opd->endaddr ();
+ for (CORE_ADDR addr = opd.addr ();
+ addr < opd.endaddr ();
addr += 2 * 8)
{
ULONGEST opdaddr;
faddr_sect = find_pc_section (faddr);
if (faddr_sect != NULL)
{
- for (obj_section *osect : faddr_sect->objfile->sections ())
+ for (obj_section &osect : faddr_sect->objfile->sections ())
{
- if (strcmp (osect->the_bfd_section->name, ".dynamic") == 0)
+ if (strcmp (osect.the_bfd_section->name, ".dynamic") == 0)
{
- CORE_ADDR addr = osect->addr ();
- CORE_ADDR endaddr = osect->endaddr ();
+ CORE_ADDR addr = osect.addr ();
+ CORE_ADDR endaddr = osect.endaddr ();
while (addr < endaddr)
{
if (faddr_sect != NULL)
{
- for (obj_section *osect : faddr_sect->objfile->sections ())
+ for (obj_section &osect : faddr_sect->objfile->sections ())
{
- if (strcmp (osect->the_bfd_section->name, ".opd") == 0)
+ if (strcmp (osect.the_bfd_section->name, ".opd") == 0)
{
- CORE_ADDR addr = osect->addr ();
- CORE_ADDR endaddr = osect->endaddr ();
+ CORE_ADDR addr = osect.addr ();
+ CORE_ADDR endaddr = osect.endaddr ();
while (addr < endaddr)
{
for (i = 0; i < addrs.size (); i++)
{
- for (obj_section *osect : objfile->sections ())
+ for (obj_section &osect : objfile->sections ())
{
- const char *bfd_sect_name = osect->the_bfd_section->name;
+ const char *bfd_sect_name = osect.the_bfd_section->name;
if (bfd_sect_name == addrs[i].name)
{
- osect->set_offset (addrs[i].addr);
+ osect.set_offset (addrs[i].addr);
break;
}
}
objfile->sect_index_text = 0;
- for (obj_section *osect : objfile->sections ())
+ for (obj_section &osect : objfile->sections ())
{
- const char *bfd_sect_name = osect->the_bfd_section->name;
- int sect_index = osect - objfile->sections_start;
+ const char *bfd_sect_name = osect.the_bfd_section->name;
+ int sect_index = &osect - objfile->sections_start;
if (startswith (bfd_sect_name, "LC_SEGMENT."))
bfd_sect_name += 11;
p = skip_spaces (p + 1);
for (objfile *objfile : current_program_space->objfiles ())
- for (obj_section *iter : objfile->sections ())
+ for (obj_section &iter : objfile->sections ())
{
- if (strncmp (iter->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)
{
- for (obj_section *iter : objfile->sections ())
+ for (obj_section &iter : objfile->sections ())
{
- if (iter->contains (pc))
+ if (iter.contains (pc))
{
- *unrel_addr = unrelocated_addr (pc - iter->offset ());
+ *unrel_addr = unrelocated_addr (pc - iter.offset ());
return 1;
}
}
get_objfile_pspace_data (objfile->pspace ())->section_map_dirty = 1;
/* Update the table in exec_ops, used to read memory. */
- for (obj_section *s : objfile->sections ())
+ for (obj_section &s : objfile->sections ())
{
- int idx = s - objfile->sections_start;
+ int idx = &s - objfile->sections_start;
exec_set_section_address (bfd_get_filename (objfile->obfd.get ()), idx,
- s->addr ());
+ s.addr ());
}
/* Data changed. */
second case shouldn't occur during normal use, but std::sort
does check that '!(a < a)' when compiled in debug mode. */
- for (const obj_section *osect : objfile1->sections ())
- if (osect == sect2)
+ for (const obj_section &osect : objfile1->sections ())
+ if (&osect == sect2)
return false;
- else if (osect == sect1)
+ else if (&osect == sect1)
return true;
/* We should have found one of the sections before getting here. */
alloc_size = 0;
for (objfile *objfile : pspace->objfiles ())
- for (obj_section *s : objfile->sections ())
- if (insert_section_p (objfile->obfd.get (), s->the_bfd_section))
+ for (obj_section &s : objfile->sections ())
+ if (insert_section_p (objfile->obfd.get (), s.the_bfd_section))
alloc_size += 1;
/* This happens on detach/attach (e.g. in gdb.base/attach.exp). */
i = 0;
for (objfile *objfile : pspace->objfiles ())
- for (obj_section *s : objfile->sections ())
- if (insert_section_p (objfile->obfd.get (), s->the_bfd_section))
- map[i++] = s;
+ for (obj_section &s : objfile->sections ())
+ if (insert_section_p (objfile->obfd.get (), s.the_bfd_section))
+ map[i++] = &s;
std::sort (map, map + alloc_size, sort_cmp);
map_size = filter_debuginfo_sections(map, alloc_size);
if (objfile == NULL)
return false;
- for (obj_section *osect : objfile->sections ())
+ for (obj_section &osect : objfile->sections ())
{
- if (section_is_overlay (osect) && !section_is_mapped (osect))
+ if (section_is_overlay (&osect) && !section_is_mapped (&osect))
continue;
- if (osect->contains (addr))
+ if (osect.contains (addr))
return true;
}
return false;
section_iterator &operator= (const section_iterator &) = default;
section_iterator &operator= (section_iterator &&) = default;
- typedef section_iterator self_type;
- typedef obj_section *value_type;
+ using self_type = section_iterator;
+ using reference = obj_section &;
- value_type operator* ()
- { return m_iter; }
+ reference operator* ()
+ { return *m_iter; }
section_iterator &operator++ ()
{
++m_iter;
}
- value_type m_iter;
- value_type m_end;
+ obj_section *m_iter;
+ obj_section *m_end;
};
iterator_range<section_iterator> sections ()
addr = parse_and_eval_address (arg);
for (objfile *objfile : current_program_space->objfiles ())
- for (obj_section *osect : objfile->sections ())
+ for (obj_section &osect : objfile->sections ())
{
/* Only process each object file once, even if there's a separate
debug file. */
if (objfile->separate_debug_objfile_backlink)
continue;
- sect_addr = overlay_mapped_address (addr, osect);
+ sect_addr = overlay_mapped_address (addr, &osect);
- if (osect->contains (sect_addr)
+ if (osect.contains (sect_addr)
&& (msymbol
= lookup_minimal_symbol_by_pc_section (sect_addr,
- osect).minsym))
+ &osect).minsym))
{
const char *obj_name, *mapped, *sec_name, *msym_name;
const char *loc_string;
matches = 1;
offset = sect_addr - msymbol->value_address (objfile);
- mapped = section_is_mapped (osect) ? _("mapped") : _("unmapped");
- sec_name = osect->the_bfd_section->name;
+ mapped = section_is_mapped (&osect) ? _("mapped") : _("unmapped");
+ sec_name = osect.the_bfd_section->name;
msym_name = msymbol->print_name ();
/* Don't print the offset if it is zero.
else
loc_string = msym_name;
- gdb_assert (osect->objfile && objfile_name (osect->objfile));
- obj_name = objfile_name (osect->objfile);
+ gdb_assert (osect.objfile && objfile_name (osect.objfile));
+ obj_name = objfile_name (osect.objfile);
if (current_program_space->multi_objfile_p ())
- if (pc_in_unmapped_range (addr, osect))
- if (section_is_overlay (osect))
+ if (pc_in_unmapped_range (addr, &osect))
+ if (section_is_overlay (&osect))
gdb_printf (_("%s in load address range of "
"%s overlay section %s of %s\n"),
loc_string, mapped, sec_name, obj_name);
"section %s of %s\n"),
loc_string, sec_name, obj_name);
else
- if (section_is_overlay (osect))
+ if (section_is_overlay (&osect))
gdb_printf (_("%s in %s overlay section %s of %s\n"),
loc_string, mapped, sec_name, obj_name);
else
gdb_printf (_("%s in section %s of %s\n"),
loc_string, sec_name, obj_name);
else
- if (pc_in_unmapped_range (addr, osect))
- if (section_is_overlay (osect))
+ if (pc_in_unmapped_range (addr, &osect))
+ if (section_is_overlay (&osect))
gdb_printf (_("%s in load address range of %s overlay "
"section %s\n"),
loc_string, mapped, sec_name);
(_("%s in load address range of section %s\n"),
loc_string, sec_name);
else
- if (section_is_overlay (osect))
+ if (section_is_overlay (&osect))
gdb_printf (_("%s in %s overlay section %s\n"),
loc_string, mapped, sec_name);
else
static struct obj_section *
data_obj_section_from_objfile (struct objfile *objfile)
{
- for (obj_section *osect : objfile->sections ())
- if (strcmp (bfd_section_name (osect->the_bfd_section), ".data") == 0)
- return osect;
+ for (obj_section &osect : objfile->sections ())
+ if (strcmp (bfd_section_name (osect.the_bfd_section), ".data") == 0)
+ return &osect;
return NULL;
}
section_offsets new_offsets (objf->section_offsets.size ());
changed = 0;
- for (obj_section *osect : objf->sections ())
+ for (obj_section &osect : objf->sections ())
{
CORE_ADDR orig_addr, addr, offset;
int osect_idx;
int seg;
- osect_idx = osect - objf->sections_start;
+ osect_idx = &osect - objf->sections_start;
/* Current address of section. */
- addr = osect->addr ();
+ addr = osect.addr ();
/* Offset from where this section started. */
offset = objf->section_offsets[osect_idx];
/* Original address prior to any past relocations. */
section_offsets new_offsets (objf->section_offsets.size ());
changed = 0;
- for (obj_section *osect : objf->sections ())
+ for (obj_section &osect : objf->sections ())
{
CORE_ADDR orig_addr, addr, offset;
int osect_idx;
int seg;
-
- osect_idx = osect - objf->sections_start;
+
+ osect_idx = &osect - objf->sections_start;
/* Current address of section. */
- addr = osect->addr ();
+ addr = osect.addr ();
/* Offset from where this section started. */
offset = objf->section_offsets[osect_idx];
/* Original address prior to any past relocations. */
static bool
has_thread_local_section (const objfile *objf)
{
- for (obj_section *objsec : objf->sections ())
- if (is_thread_local_section (objsec->the_bfd_section))
+ for (obj_section &objsec : objf->sections ())
+ if (is_thread_local_section (objsec.the_bfd_section))
return true;
return false;
}
= gdbarch_addr_bits_remove (objfile->arch (), entry_point);
found = 0;
- for (obj_section *osect : objfile->sections ())
+ for (obj_section &osect : objfile->sections ())
{
- struct bfd_section *sect = osect->the_bfd_section;
+ struct bfd_section *sect = osect.the_bfd_section;
if (entry_point >= bfd_section_vma (sect)
&& entry_point < (bfd_section_vma (sect)
overlay_invalidate_all (program_space *pspace)
{
for (objfile *objfile : pspace->objfiles ())
- for (obj_section *sect : objfile->sections ())
- if (section_is_overlay (sect))
- sect->ovly_mapped = -1;
+ for (obj_section § : objfile->sections ())
+ if (section_is_overlay (§))
+ sect.ovly_mapped = -1;
}
/* Function: section_is_mapped (SECTION)
if (overlay_debugging)
{
for (objfile *objfile : current_program_space->objfiles ())
- for (obj_section *osect : objfile->sections ())
- if (section_is_overlay (osect))
+ for (obj_section &osect : objfile->sections ())
+ if (section_is_overlay (&osect))
{
- if (pc_in_mapped_range (pc, osect))
+ if (pc_in_mapped_range (pc, &osect))
{
- if (section_is_mapped (osect))
- return osect;
+ if (section_is_mapped (&osect))
+ return &osect;
else
- best_match = osect;
+ best_match = &osect;
}
- else if (pc_in_unmapped_range (pc, osect))
- best_match = osect;
+ else if (pc_in_unmapped_range (pc, &osect))
+ best_match = &osect;
}
}
return best_match;
if (overlay_debugging)
{
for (objfile *objfile : current_program_space->objfiles ())
- for (obj_section *osect : objfile->sections ())
- if (pc_in_mapped_range (pc, osect) && section_is_mapped (osect))
- return osect;
+ for (obj_section &osect : objfile->sections ())
+ if (pc_in_mapped_range (pc, &osect) && section_is_mapped (&osect))
+ return &osect;
}
return NULL;
if (overlay_debugging)
{
for (objfile *objfile : current_program_space->objfiles ())
- for (obj_section *osect : objfile->sections ())
- if (section_is_mapped (osect))
+ for (obj_section &osect : objfile->sections ())
+ if (section_is_mapped (&osect))
{
struct gdbarch *gdbarch = objfile->arch ();
const char *name;
bfd_vma lma, vma;
int size;
- vma = bfd_section_vma (osect->the_bfd_section);
- lma = bfd_section_lma (osect->the_bfd_section);
- size = bfd_section_size (osect->the_bfd_section);
- name = bfd_section_name (osect->the_bfd_section);
+ vma = bfd_section_vma (osect.the_bfd_section);
+ lma = bfd_section_lma (osect.the_bfd_section);
+ size = bfd_section_size (osect.the_bfd_section);
+ name = bfd_section_name (osect.the_bfd_section);
gdb_printf ("Section %s, loaded at ", name);
gdb_puts (paddress (gdbarch, lma));
/* First, find a section matching the user supplied argument. */
for (objfile *obj_file : current_program_space->objfiles ())
- for (obj_section *sec : obj_file->sections ())
- if (!strcmp (bfd_section_name (sec->the_bfd_section), args))
+ 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. */
- if (!section_is_overlay (sec))
+ if (!section_is_overlay (&sec))
continue; /* not an overlay section */
/* Mark the overlay as "mapped". */
- sec->ovly_mapped = 1;
+ sec.ovly_mapped = 1;
/* Next, make a pass and unmap any sections that are
overlapped by this new section: */
for (objfile *objfile2 : current_program_space->objfiles ())
- for (obj_section *sec2 : objfile2->sections ())
- if (sec2->ovly_mapped && sec != sec2 && sections_overlap (sec,
- sec2))
+ for (obj_section &sec2 : objfile2->sections ())
+ if (sec2.ovly_mapped && &sec != &sec2 && sections_overlap (&sec,
+ &sec2))
{
if (info_verbose)
gdb_printf (_("Note: section %s unmapped by overlap\n"),
- bfd_section_name (sec2->the_bfd_section));
- sec2->ovly_mapped = 0; /* sec2 overlaps sec: unmap sec2. */
+ bfd_section_name (sec2.the_bfd_section));
+ sec2.ovly_mapped = 0; /* sec2 overlaps sec: unmap sec2. */
}
return;
}
/* First, find a section matching the user supplied argument. */
for (objfile *objfile : current_program_space->objfiles ())
- for (obj_section *sec : objfile->sections ())
- if (!strcmp (bfd_section_name (sec->the_bfd_section), args))
+ for (obj_section &sec : objfile->sections ())
+ if (!strcmp (bfd_section_name (sec.the_bfd_section), args))
{
- if (!sec->ovly_mapped)
+ if (!sec.ovly_mapped)
error (_("Section %s is not mapped"), args);
- sec->ovly_mapped = 0;
+ sec.ovly_mapped = 0;
return;
}
error (_("No overlay section called %s"), args);
/* Now may as well update all sections, even if only one was requested. */
for (objfile *objfile : current_program_space->objfiles ())
- for (obj_section *sect : objfile->sections ())
- if (section_is_overlay (sect))
+ for (obj_section § : objfile->sections ())
+ if (section_is_overlay (§))
{
int i;
- asection *bsect = sect->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. */
- sect->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. */
- for (obj_section *s : objfile->sections ())
+ for (obj_section &s : objfile->sections ())
{
- if ((bfd_section_flags (s->the_bfd_section) & SEC_ALLOC) == 0)
+ if ((bfd_section_flags (s.the_bfd_section) & SEC_ALLOC) == 0)
continue;
- int idx = s - objfile->sections_start;
+ int idx = &s - objfile->sections_start;
CORE_ADDR offset = objfile->section_offsets[idx];
if (fallback == -1)
fallback = idx;
- if (s->addr () - offset <= addr && addr < s->endaddr () - offset)
+ if (s.addr () - offset <= addr && addr < s.endaddr () - offset)
{
sym->set_section_index (idx);
return;
if (!strcmp (faddr_sect->the_bfd_section->name, ".plt"))
return faddr;
- for (obj_section *osect : faddr_sect->objfile->sections ())
+ for (obj_section &osect : faddr_sect->objfile->sections ())
{
- if (!strcmp (osect->the_bfd_section->name, ".plt"))
+ if (!strcmp (osect.the_bfd_section->name, ".plt"))
{
CORE_ADDR addr, endaddr;
- addr = osect->addr ();
- endaddr = osect->endaddr ();
+ addr = osect.addr ();
+ endaddr = osect.endaddr ();
for (; addr < endaddr; addr += 2 * xstormy16_inst_size)
{
/* we have interest for sections with same VMA */
for (objfile *objfile : current_program_space->objfiles ())
- for (obj_section *sect : objfile->sections ())
- if (section_is_overlay (sect))
+ for (obj_section § : objfile->sections ())
+ if (section_is_overlay (§))
{
- sect->ovly_mapped = (lma == bfd_section_lma (sect->the_bfd_section));
- i |= sect->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 ())
- for (obj_section *sect : objfile->sections ())
+ for (obj_section § : objfile->sections ())
{
- if (!section_is_overlay (sect))
+ if (!section_is_overlay (§))
continue;
- asection *bsect = sect->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)
- sect->ovly_mapped =
+ sect.ovly_mapped =
(cache_ovly_region_table[i][Z80_MAPPED_TO_LMA] == lma);
}
}