mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-11-16 12:34:43 +00:00
gdb/objfiles: make objfile::sections yield references
I wrote this as a preparatory patch while attempting to make objfile::section_iterator use filtered_iterator. It turned out not so easy, so I have put it aside for now. But now I have this patch, so I thought I'd send it by itself. Since the `obj_section *` yielded by the iterator can't be nullptr, I think it makes sense for the iterator to yield references instead. Just like you would get if you iterated on an std::vector<obj_section>. Change-Id: I7bbee50ed52599e64c4f3b06bdbbde597feba9aa
This commit is contained in:
committed by
Simon Marchi
parent
0c2b386193
commit
b340cd71e6
@@ -2504,15 +2504,15 @@ static const registry<bfd>::key<arm_exidx_data> arm_exidx_data_key;
|
|||||||
static struct obj_section *
|
static struct obj_section *
|
||||||
arm_obj_section_from_vma (struct objfile *objfile, bfd_vma vma)
|
arm_obj_section_from_vma (struct objfile *objfile, bfd_vma vma)
|
||||||
{
|
{
|
||||||
for (obj_section *osect : objfile->sections ())
|
for (obj_section &osect : objfile->sections ())
|
||||||
if (bfd_section_flags (osect->the_bfd_section) & SEC_ALLOC)
|
if (bfd_section_flags (osect.the_bfd_section) & SEC_ALLOC)
|
||||||
{
|
{
|
||||||
bfd_vma start, size;
|
bfd_vma start, size;
|
||||||
start = bfd_section_vma (osect->the_bfd_section);
|
start = bfd_section_vma (osect.the_bfd_section);
|
||||||
size = bfd_section_size (osect->the_bfd_section);
|
size = bfd_section_size (osect.the_bfd_section);
|
||||||
|
|
||||||
if (start <= vma && vma < start + size)
|
if (start <= vma && vma < start + size)
|
||||||
return osect;
|
return &osect;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
@@ -653,13 +653,13 @@ program_space::add_target_sections (struct objfile *objfile)
|
|||||||
gdb_assert (objfile != nullptr);
|
gdb_assert (objfile != nullptr);
|
||||||
|
|
||||||
/* Compute the number of sections to add. */
|
/* 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;
|
continue;
|
||||||
|
|
||||||
m_target_sections.emplace_back (osect->addr (), osect->endaddr (),
|
m_target_sections.emplace_back (osect.addr (), osect.endaddr (),
|
||||||
osect->the_bfd_section, objfile);
|
osect.the_bfd_section, objfile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
14
gdb/gcore.c
14
gdb/gcore.c
@@ -425,13 +425,13 @@ gcore_create_callback (CORE_ADDR vaddr, unsigned long size, int read,
|
|||||||
If so, we can avoid copying its contents by clearing SEC_LOAD. */
|
If so, we can avoid copying its contents by clearing SEC_LOAD. */
|
||||||
|
|
||||||
for (objfile *objfile : current_program_space->objfiles ())
|
for (objfile *objfile : current_program_space->objfiles ())
|
||||||
for (obj_section *objsec : objfile->sections ())
|
for (obj_section &objsec : objfile->sections ())
|
||||||
{
|
{
|
||||||
bfd *abfd = objfile->obfd.get ();
|
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 align = (bfd_vma) 1 << bfd_section_alignment (asec);
|
||||||
bfd_vma start = objsec->addr () & -align;
|
bfd_vma start = objsec.addr () & -align;
|
||||||
bfd_vma end = (objsec->endaddr () + 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
|
||||||
@@ -533,9 +533,9 @@ objfile_find_memory_regions (struct target_ops *self,
|
|||||||
|
|
||||||
/* Call callback function for each objfile section. */
|
/* Call callback function for each objfile section. */
|
||||||
for (objfile *objfile : current_program_space->objfiles ())
|
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);
|
flagword flags = bfd_section_flags (isec);
|
||||||
|
|
||||||
/* Separate debug info files are irrelevant for gcore. */
|
/* Separate debug info files are irrelevant for gcore. */
|
||||||
@@ -547,7 +547,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) (objsec->addr (), 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. */
|
||||||
|
|||||||
@@ -54,12 +54,12 @@ hppabsd_find_global_pointer (struct gdbarch *gdbarch, struct value *function)
|
|||||||
faddr_sec = find_pc_section (faddr);
|
faddr_sec = find_pc_section (faddr);
|
||||||
if (faddr_sec != NULL)
|
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 addr = sec.addr ();
|
||||||
CORE_ADDR endaddr = sec->endaddr ();
|
CORE_ADDR endaddr = sec.endaddr ();
|
||||||
|
|
||||||
while (addr < endaddr)
|
while (addr < endaddr)
|
||||||
{
|
{
|
||||||
@@ -81,7 +81,7 @@ hppabsd_find_global_pointer (struct gdbarch *gdbarch, struct value *function)
|
|||||||
DT_PLTGOT, so we have to do it ourselves. */
|
DT_PLTGOT, so we have to do it ourselves. */
|
||||||
pltgot = extract_unsigned_integer (buf, sizeof buf,
|
pltgot = extract_unsigned_integer (buf, sizeof buf,
|
||||||
byte_order);
|
byte_order);
|
||||||
pltgot += sec->objfile->text_section_offset ();
|
pltgot += sec.objfile->text_section_offset ();
|
||||||
|
|
||||||
return pltgot;
|
return pltgot;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -362,14 +362,14 @@ hppa_linux_find_global_pointer (struct gdbarch *gdbarch,
|
|||||||
faddr_sect = find_pc_section (faddr);
|
faddr_sect = find_pc_section (faddr);
|
||||||
if (faddr_sect != NULL)
|
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;
|
CORE_ADDR addr, endaddr;
|
||||||
|
|
||||||
addr = osect->addr ();
|
addr = osect.addr ();
|
||||||
endaddr = osect->endaddr ();
|
endaddr = osect.endaddr ();
|
||||||
|
|
||||||
while (addr < endaddr)
|
while (addr < endaddr)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -920,12 +920,12 @@ hppa64_convert_code_addr_to_fptr (struct gdbarch *gdbarch, CORE_ADDR code)
|
|||||||
if (!(sec->the_bfd_section->flags & SEC_CODE))
|
if (!(sec->the_bfd_section->flags & SEC_CODE))
|
||||||
return 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 ();
|
for (CORE_ADDR addr = opd.addr ();
|
||||||
addr < opd->endaddr ();
|
addr < opd.endaddr ();
|
||||||
addr += 2 * 8)
|
addr += 2 * 8)
|
||||||
{
|
{
|
||||||
ULONGEST opdaddr;
|
ULONGEST opdaddr;
|
||||||
|
|||||||
@@ -3432,12 +3432,12 @@ ia64_find_global_pointer_from_dynamic_section (struct gdbarch *gdbarch,
|
|||||||
faddr_sect = find_pc_section (faddr);
|
faddr_sect = find_pc_section (faddr);
|
||||||
if (faddr_sect != NULL)
|
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 addr = osect.addr ();
|
||||||
CORE_ADDR endaddr = osect->endaddr ();
|
CORE_ADDR endaddr = osect.endaddr ();
|
||||||
|
|
||||||
while (addr < endaddr)
|
while (addr < endaddr)
|
||||||
{
|
{
|
||||||
@@ -3513,12 +3513,12 @@ find_extant_func_descr (struct gdbarch *gdbarch, CORE_ADDR faddr)
|
|||||||
|
|
||||||
if (faddr_sect != NULL)
|
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 addr = osect.addr ();
|
||||||
CORE_ADDR endaddr = osect->endaddr ();
|
CORE_ADDR endaddr = osect.endaddr ();
|
||||||
|
|
||||||
while (addr < endaddr)
|
while (addr < endaddr)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -901,13 +901,13 @@ macho_symfile_offsets (struct objfile *objfile,
|
|||||||
|
|
||||||
for (i = 0; i < addrs.size (); i++)
|
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)
|
if (bfd_sect_name == addrs[i].name)
|
||||||
{
|
{
|
||||||
osect->set_offset (addrs[i].addr);
|
osect.set_offset (addrs[i].addr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -915,10 +915,10 @@ macho_symfile_offsets (struct objfile *objfile,
|
|||||||
|
|
||||||
objfile->sect_index_text = 0;
|
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;
|
const char *bfd_sect_name = osect.the_bfd_section->name;
|
||||||
int sect_index = osect - objfile->sections_start;
|
int sect_index = &osect - objfile->sections_start;
|
||||||
|
|
||||||
if (startswith (bfd_sect_name, "LC_SEGMENT."))
|
if (startswith (bfd_sect_name, "LC_SEGMENT."))
|
||||||
bfd_sect_name += 11;
|
bfd_sect_name += 11;
|
||||||
|
|||||||
@@ -582,9 +582,9 @@ maintenance_translate_address (const char *arg, int from_tty)
|
|||||||
p = skip_spaces (p + 1);
|
p = skip_spaces (p + 1);
|
||||||
|
|
||||||
for (objfile *objfile : current_program_space->objfiles ())
|
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;
|
goto found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -712,11 +712,11 @@ static int
|
|||||||
frob_address (struct objfile *objfile, CORE_ADDR pc,
|
frob_address (struct objfile *objfile, CORE_ADDR pc,
|
||||||
unrelocated_addr *unrel_addr)
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -587,12 +587,12 @@ objfile_relocate1 (struct objfile *objfile,
|
|||||||
get_objfile_pspace_data (objfile->pspace ())->section_map_dirty = 1;
|
get_objfile_pspace_data (objfile->pspace ())->section_map_dirty = 1;
|
||||||
|
|
||||||
/* Update the table in exec_ops, used to read memory. */
|
/* 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,
|
exec_set_section_address (bfd_get_filename (objfile->obfd.get ()), idx,
|
||||||
s->addr ());
|
s.addr ());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Data changed. */
|
/* Data changed. */
|
||||||
@@ -790,10 +790,10 @@ sort_cmp (const struct obj_section *sect1, const obj_section *sect2)
|
|||||||
second case shouldn't occur during normal use, but std::sort
|
second case shouldn't occur during normal use, but std::sort
|
||||||
does check that '!(a < a)' when compiled in debug mode. */
|
does check that '!(a < a)' when compiled in debug mode. */
|
||||||
|
|
||||||
for (const obj_section *osect : objfile1->sections ())
|
for (const obj_section &osect : objfile1->sections ())
|
||||||
if (osect == sect2)
|
if (&osect == sect2)
|
||||||
return false;
|
return false;
|
||||||
else if (osect == sect1)
|
else if (&osect == sect1)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
/* We should have found one of the sections before getting here. */
|
/* We should have found one of the sections before getting here. */
|
||||||
@@ -994,8 +994,8 @@ update_section_map (struct program_space *pspace,
|
|||||||
|
|
||||||
alloc_size = 0;
|
alloc_size = 0;
|
||||||
for (objfile *objfile : pspace->objfiles ())
|
for (objfile *objfile : pspace->objfiles ())
|
||||||
for (obj_section *s : objfile->sections ())
|
for (obj_section &s : objfile->sections ())
|
||||||
if (insert_section_p (objfile->obfd.get (), s->the_bfd_section))
|
if (insert_section_p (objfile->obfd.get (), s.the_bfd_section))
|
||||||
alloc_size += 1;
|
alloc_size += 1;
|
||||||
|
|
||||||
/* This happens on detach/attach (e.g. in gdb.base/attach.exp). */
|
/* This happens on detach/attach (e.g. in gdb.base/attach.exp). */
|
||||||
@@ -1010,9 +1010,9 @@ update_section_map (struct program_space *pspace,
|
|||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
for (objfile *objfile : pspace->objfiles ())
|
for (objfile *objfile : pspace->objfiles ())
|
||||||
for (obj_section *s : objfile->sections ())
|
for (obj_section &s : objfile->sections ())
|
||||||
if (insert_section_p (objfile->obfd.get (), s->the_bfd_section))
|
if (insert_section_p (objfile->obfd.get (), s.the_bfd_section))
|
||||||
map[i++] = s;
|
map[i++] = &s;
|
||||||
|
|
||||||
std::sort (map, map + alloc_size, sort_cmp);
|
std::sort (map, map + alloc_size, sort_cmp);
|
||||||
map_size = filter_debuginfo_sections(map, alloc_size);
|
map_size = filter_debuginfo_sections(map, alloc_size);
|
||||||
@@ -1127,12 +1127,12 @@ is_addr_in_objfile (CORE_ADDR addr, const struct objfile *objfile)
|
|||||||
if (objfile == NULL)
|
if (objfile == NULL)
|
||||||
return false;
|
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;
|
continue;
|
||||||
|
|
||||||
if (osect->contains (addr))
|
if (osect.contains (addr))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -665,11 +665,11 @@ public:
|
|||||||
section_iterator &operator= (const section_iterator &) = default;
|
section_iterator &operator= (const section_iterator &) = default;
|
||||||
section_iterator &operator= (section_iterator &&) = default;
|
section_iterator &operator= (section_iterator &&) = default;
|
||||||
|
|
||||||
typedef section_iterator self_type;
|
using self_type = section_iterator;
|
||||||
typedef obj_section *value_type;
|
using reference = obj_section &;
|
||||||
|
|
||||||
value_type operator* ()
|
reference operator* ()
|
||||||
{ return m_iter; }
|
{ return *m_iter; }
|
||||||
|
|
||||||
section_iterator &operator++ ()
|
section_iterator &operator++ ()
|
||||||
{
|
{
|
||||||
@@ -701,8 +701,8 @@ public:
|
|||||||
++m_iter;
|
++m_iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
value_type m_iter;
|
obj_section *m_iter;
|
||||||
value_type m_end;
|
obj_section *m_end;
|
||||||
};
|
};
|
||||||
|
|
||||||
iterator_range<section_iterator> sections ()
|
iterator_range<section_iterator> sections ()
|
||||||
|
|||||||
@@ -1494,27 +1494,27 @@ info_symbol_command (const char *arg, int from_tty)
|
|||||||
|
|
||||||
addr = parse_and_eval_address (arg);
|
addr = parse_and_eval_address (arg);
|
||||||
for (objfile *objfile : current_program_space->objfiles ())
|
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
|
/* Only process each object file once, even if there's a separate
|
||||||
debug file. */
|
debug file. */
|
||||||
if (objfile->separate_debug_objfile_backlink)
|
if (objfile->separate_debug_objfile_backlink)
|
||||||
continue;
|
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
|
&& (msymbol
|
||||||
= lookup_minimal_symbol_by_pc_section (sect_addr,
|
= lookup_minimal_symbol_by_pc_section (sect_addr,
|
||||||
osect).minsym))
|
&osect).minsym))
|
||||||
{
|
{
|
||||||
const char *obj_name, *mapped, *sec_name, *msym_name;
|
const char *obj_name, *mapped, *sec_name, *msym_name;
|
||||||
const char *loc_string;
|
const char *loc_string;
|
||||||
|
|
||||||
matches = 1;
|
matches = 1;
|
||||||
offset = sect_addr - msymbol->value_address (objfile);
|
offset = sect_addr - msymbol->value_address (objfile);
|
||||||
mapped = section_is_mapped (osect) ? _("mapped") : _("unmapped");
|
mapped = section_is_mapped (&osect) ? _("mapped") : _("unmapped");
|
||||||
sec_name = osect->the_bfd_section->name;
|
sec_name = osect.the_bfd_section->name;
|
||||||
msym_name = msymbol->print_name ();
|
msym_name = msymbol->print_name ();
|
||||||
|
|
||||||
/* Don't print the offset if it is zero.
|
/* Don't print the offset if it is zero.
|
||||||
@@ -1528,12 +1528,12 @@ info_symbol_command (const char *arg, int from_tty)
|
|||||||
else
|
else
|
||||||
loc_string = msym_name;
|
loc_string = msym_name;
|
||||||
|
|
||||||
gdb_assert (osect->objfile && objfile_name (osect->objfile));
|
gdb_assert (osect.objfile && objfile_name (osect.objfile));
|
||||||
obj_name = objfile_name (osect->objfile);
|
obj_name = objfile_name (osect.objfile);
|
||||||
|
|
||||||
if (current_program_space->multi_objfile_p ())
|
if (current_program_space->multi_objfile_p ())
|
||||||
if (pc_in_unmapped_range (addr, osect))
|
if (pc_in_unmapped_range (addr, &osect))
|
||||||
if (section_is_overlay (osect))
|
if (section_is_overlay (&osect))
|
||||||
gdb_printf (_("%s in load address range of "
|
gdb_printf (_("%s in load address range of "
|
||||||
"%s overlay section %s of %s\n"),
|
"%s overlay section %s of %s\n"),
|
||||||
loc_string, mapped, sec_name, obj_name);
|
loc_string, mapped, sec_name, obj_name);
|
||||||
@@ -1542,15 +1542,15 @@ info_symbol_command (const char *arg, int from_tty)
|
|||||||
"section %s of %s\n"),
|
"section %s of %s\n"),
|
||||||
loc_string, sec_name, obj_name);
|
loc_string, sec_name, obj_name);
|
||||||
else
|
else
|
||||||
if (section_is_overlay (osect))
|
if (section_is_overlay (&osect))
|
||||||
gdb_printf (_("%s in %s overlay section %s of %s\n"),
|
gdb_printf (_("%s in %s overlay section %s of %s\n"),
|
||||||
loc_string, mapped, sec_name, obj_name);
|
loc_string, mapped, sec_name, obj_name);
|
||||||
else
|
else
|
||||||
gdb_printf (_("%s in section %s of %s\n"),
|
gdb_printf (_("%s in section %s of %s\n"),
|
||||||
loc_string, sec_name, obj_name);
|
loc_string, sec_name, obj_name);
|
||||||
else
|
else
|
||||||
if (pc_in_unmapped_range (addr, osect))
|
if (pc_in_unmapped_range (addr, &osect))
|
||||||
if (section_is_overlay (osect))
|
if (section_is_overlay (&osect))
|
||||||
gdb_printf (_("%s in load address range of %s overlay "
|
gdb_printf (_("%s in load address range of %s overlay "
|
||||||
"section %s\n"),
|
"section %s\n"),
|
||||||
loc_string, mapped, sec_name);
|
loc_string, mapped, sec_name);
|
||||||
@@ -1559,7 +1559,7 @@ info_symbol_command (const char *arg, int from_tty)
|
|||||||
(_("%s in load address range of section %s\n"),
|
(_("%s in load address range of section %s\n"),
|
||||||
loc_string, sec_name);
|
loc_string, sec_name);
|
||||||
else
|
else
|
||||||
if (section_is_overlay (osect))
|
if (section_is_overlay (&osect))
|
||||||
gdb_printf (_("%s in %s overlay section %s\n"),
|
gdb_printf (_("%s in %s overlay section %s\n"),
|
||||||
loc_string, mapped, sec_name);
|
loc_string, mapped, sec_name);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -622,9 +622,9 @@ aix_solib_ops::bfd_open (const char *pathname) const
|
|||||||
static struct obj_section *
|
static struct obj_section *
|
||||||
data_obj_section_from_objfile (struct objfile *objfile)
|
data_obj_section_from_objfile (struct objfile *objfile)
|
||||||
{
|
{
|
||||||
for (obj_section *osect : objfile->sections ())
|
for (obj_section &osect : objfile->sections ())
|
||||||
if (strcmp (bfd_section_name (osect->the_bfd_section), ".data") == 0)
|
if (strcmp (bfd_section_name (osect.the_bfd_section), ".data") == 0)
|
||||||
return osect;
|
return &osect;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -816,16 +816,16 @@ dsbt_relocate_main_executable (void)
|
|||||||
section_offsets new_offsets (objf->section_offsets.size ());
|
section_offsets new_offsets (objf->section_offsets.size ());
|
||||||
changed = 0;
|
changed = 0;
|
||||||
|
|
||||||
for (obj_section *osect : objf->sections ())
|
for (obj_section &osect : objf->sections ())
|
||||||
{
|
{
|
||||||
CORE_ADDR orig_addr, addr, offset;
|
CORE_ADDR orig_addr, addr, offset;
|
||||||
int osect_idx;
|
int osect_idx;
|
||||||
int seg;
|
int seg;
|
||||||
|
|
||||||
osect_idx = osect - objf->sections_start;
|
osect_idx = &osect - objf->sections_start;
|
||||||
|
|
||||||
/* Current address of section. */
|
/* Current address of section. */
|
||||||
addr = osect->addr ();
|
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. */
|
||||||
|
|||||||
@@ -750,16 +750,16 @@ frv_relocate_main_executable (void)
|
|||||||
section_offsets new_offsets (objf->section_offsets.size ());
|
section_offsets new_offsets (objf->section_offsets.size ());
|
||||||
changed = 0;
|
changed = 0;
|
||||||
|
|
||||||
for (obj_section *osect : objf->sections ())
|
for (obj_section &osect : objf->sections ())
|
||||||
{
|
{
|
||||||
CORE_ADDR orig_addr, addr, offset;
|
CORE_ADDR orig_addr, addr, offset;
|
||||||
int osect_idx;
|
int osect_idx;
|
||||||
int seg;
|
int seg;
|
||||||
|
|
||||||
osect_idx = osect - objf->sections_start;
|
osect_idx = &osect - objf->sections_start;
|
||||||
|
|
||||||
/* Current address of section. */
|
/* Current address of section. */
|
||||||
addr = osect->addr ();
|
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. */
|
||||||
|
|||||||
@@ -1622,8 +1622,8 @@ is_thread_local_section (struct bfd_section *bfd_sect)
|
|||||||
static bool
|
static bool
|
||||||
has_thread_local_section (const objfile *objf)
|
has_thread_local_section (const objfile *objf)
|
||||||
{
|
{
|
||||||
for (obj_section *objsec : objf->sections ())
|
for (obj_section &objsec : objf->sections ())
|
||||||
if (is_thread_local_section (objsec->the_bfd_section))
|
if (is_thread_local_section (objsec.the_bfd_section))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -835,9 +835,9 @@ init_entry_point_info (struct objfile *objfile)
|
|||||||
= gdbarch_addr_bits_remove (objfile->arch (), entry_point);
|
= gdbarch_addr_bits_remove (objfile->arch (), entry_point);
|
||||||
|
|
||||||
found = 0;
|
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)
|
if (entry_point >= bfd_section_vma (sect)
|
||||||
&& entry_point < (bfd_section_vma (sect)
|
&& entry_point < (bfd_section_vma (sect)
|
||||||
@@ -3007,9 +3007,9 @@ static void
|
|||||||
overlay_invalidate_all (program_space *pspace)
|
overlay_invalidate_all (program_space *pspace)
|
||||||
{
|
{
|
||||||
for (objfile *objfile : pspace->objfiles ())
|
for (objfile *objfile : pspace->objfiles ())
|
||||||
for (obj_section *sect : objfile->sections ())
|
for (obj_section § : objfile->sections ())
|
||||||
if (section_is_overlay (sect))
|
if (section_is_overlay (§))
|
||||||
sect->ovly_mapped = -1;
|
sect.ovly_mapped = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Function: section_is_mapped (SECTION)
|
/* Function: section_is_mapped (SECTION)
|
||||||
@@ -3183,18 +3183,18 @@ find_pc_overlay (CORE_ADDR pc)
|
|||||||
if (overlay_debugging)
|
if (overlay_debugging)
|
||||||
{
|
{
|
||||||
for (objfile *objfile : current_program_space->objfiles ())
|
for (objfile *objfile : current_program_space->objfiles ())
|
||||||
for (obj_section *osect : objfile->sections ())
|
for (obj_section &osect : objfile->sections ())
|
||||||
if (section_is_overlay (osect))
|
if (section_is_overlay (&osect))
|
||||||
{
|
{
|
||||||
if (pc_in_mapped_range (pc, osect))
|
if (pc_in_mapped_range (pc, &osect))
|
||||||
{
|
{
|
||||||
if (section_is_mapped (osect))
|
if (section_is_mapped (&osect))
|
||||||
return osect;
|
return &osect;
|
||||||
else
|
else
|
||||||
best_match = osect;
|
best_match = &osect;
|
||||||
}
|
}
|
||||||
else if (pc_in_unmapped_range (pc, osect))
|
else if (pc_in_unmapped_range (pc, &osect))
|
||||||
best_match = osect;
|
best_match = &osect;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return best_match;
|
return best_match;
|
||||||
@@ -3210,9 +3210,9 @@ find_pc_mapped_section (CORE_ADDR pc)
|
|||||||
if (overlay_debugging)
|
if (overlay_debugging)
|
||||||
{
|
{
|
||||||
for (objfile *objfile : current_program_space->objfiles ())
|
for (objfile *objfile : current_program_space->objfiles ())
|
||||||
for (obj_section *osect : objfile->sections ())
|
for (obj_section &osect : objfile->sections ())
|
||||||
if (pc_in_mapped_range (pc, osect) && section_is_mapped (osect))
|
if (pc_in_mapped_range (pc, &osect) && section_is_mapped (&osect))
|
||||||
return osect;
|
return &osect;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -3229,18 +3229,18 @@ list_overlays_command (const char *args, int from_tty)
|
|||||||
if (overlay_debugging)
|
if (overlay_debugging)
|
||||||
{
|
{
|
||||||
for (objfile *objfile : current_program_space->objfiles ())
|
for (objfile *objfile : current_program_space->objfiles ())
|
||||||
for (obj_section *osect : objfile->sections ())
|
for (obj_section &osect : objfile->sections ())
|
||||||
if (section_is_mapped (osect))
|
if (section_is_mapped (&osect))
|
||||||
{
|
{
|
||||||
struct gdbarch *gdbarch = objfile->arch ();
|
struct gdbarch *gdbarch = objfile->arch ();
|
||||||
const char *name;
|
const char *name;
|
||||||
bfd_vma lma, vma;
|
bfd_vma lma, vma;
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
vma = bfd_section_vma (osect->the_bfd_section);
|
vma = bfd_section_vma (osect.the_bfd_section);
|
||||||
lma = bfd_section_lma (osect->the_bfd_section);
|
lma = bfd_section_lma (osect.the_bfd_section);
|
||||||
size = bfd_section_size (osect->the_bfd_section);
|
size = bfd_section_size (osect.the_bfd_section);
|
||||||
name = bfd_section_name (osect->the_bfd_section);
|
name = bfd_section_name (osect.the_bfd_section);
|
||||||
|
|
||||||
gdb_printf ("Section %s, loaded at ", name);
|
gdb_printf ("Section %s, loaded at ", name);
|
||||||
gdb_puts (paddress (gdbarch, lma));
|
gdb_puts (paddress (gdbarch, lma));
|
||||||
@@ -3275,27 +3275,27 @@ map_overlay_command (const char *args, int from_tty)
|
|||||||
|
|
||||||
/* First, find a section matching the user supplied argument. */
|
/* First, find a section matching the user supplied argument. */
|
||||||
for (objfile *obj_file : current_program_space->objfiles ())
|
for (objfile *obj_file : current_program_space->objfiles ())
|
||||||
for (obj_section *sec : obj_file->sections ())
|
for (obj_section &sec : obj_file->sections ())
|
||||||
if (!strcmp (bfd_section_name (sec->the_bfd_section), args))
|
if (!strcmp (bfd_section_name (sec.the_bfd_section), args))
|
||||||
{
|
{
|
||||||
/* Now, check to see if the section is an overlay. */
|
/* 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 */
|
continue; /* not an overlay section */
|
||||||
|
|
||||||
/* Mark the overlay as "mapped". */
|
/* Mark the overlay as "mapped". */
|
||||||
sec->ovly_mapped = 1;
|
sec.ovly_mapped = 1;
|
||||||
|
|
||||||
/* Next, make a pass and unmap any sections that are
|
/* Next, make a pass and unmap any sections that are
|
||||||
overlapped by this new section: */
|
overlapped by this new section: */
|
||||||
for (objfile *objfile2 : current_program_space->objfiles ())
|
for (objfile *objfile2 : current_program_space->objfiles ())
|
||||||
for (obj_section *sec2 : objfile2->sections ())
|
for (obj_section &sec2 : objfile2->sections ())
|
||||||
if (sec2->ovly_mapped && sec != sec2 && sections_overlap (sec,
|
if (sec2.ovly_mapped && &sec != &sec2 && sections_overlap (&sec,
|
||||||
sec2))
|
&sec2))
|
||||||
{
|
{
|
||||||
if (info_verbose)
|
if (info_verbose)
|
||||||
gdb_printf (_("Note: section %s unmapped by overlap\n"),
|
gdb_printf (_("Note: section %s unmapped by overlap\n"),
|
||||||
bfd_section_name (sec2->the_bfd_section));
|
bfd_section_name (sec2.the_bfd_section));
|
||||||
sec2->ovly_mapped = 0; /* sec2 overlaps sec: unmap sec2. */
|
sec2.ovly_mapped = 0; /* sec2 overlaps sec: unmap sec2. */
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -3319,12 +3319,12 @@ unmap_overlay_command (const char *args, int from_tty)
|
|||||||
|
|
||||||
/* First, find a section matching the user supplied argument. */
|
/* First, find a section matching the user supplied argument. */
|
||||||
for (objfile *objfile : current_program_space->objfiles ())
|
for (objfile *objfile : current_program_space->objfiles ())
|
||||||
for (obj_section *sec : objfile->sections ())
|
for (obj_section &sec : objfile->sections ())
|
||||||
if (!strcmp (bfd_section_name (sec->the_bfd_section), args))
|
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);
|
error (_("Section %s is not mapped"), args);
|
||||||
sec->ovly_mapped = 0;
|
sec.ovly_mapped = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
error (_("No overlay section called %s"), args);
|
error (_("No overlay section called %s"), args);
|
||||||
@@ -3578,17 +3578,17 @@ simple_overlay_update (struct obj_section *osect)
|
|||||||
|
|
||||||
/* Now may as well update all sections, even if only one was requested. */
|
/* Now may as well update all sections, even if only one was requested. */
|
||||||
for (objfile *objfile : current_program_space->objfiles ())
|
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 (§))
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
asection *bsect = sect->the_bfd_section;
|
asection *bsect = sect.the_bfd_section;
|
||||||
|
|
||||||
for (i = 0; i < cache_novlys; i++)
|
for (i = 0; i < cache_novlys; i++)
|
||||||
if (cache_ovly_table[i][VMA] == bfd_section_vma (bsect)
|
if (cache_ovly_table[i][VMA] == bfd_section_vma (bsect)
|
||||||
&& cache_ovly_table[i][LMA] == bfd_section_lma (bsect))
|
&& cache_ovly_table[i][LMA] == bfd_section_lma (bsect))
|
||||||
{ /* obj_section matches i'th entry in ovly_table. */
|
{ /* 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. */
|
break; /* finished with inner for loop: break out. */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1846,18 +1846,18 @@ fixup_symbol_section (struct symbol *sym, struct objfile *objfile)
|
|||||||
this reason, we still attempt a lookup by name prior to doing
|
this reason, we still attempt a lookup by name prior to doing
|
||||||
a search of the section table. */
|
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;
|
continue;
|
||||||
|
|
||||||
int idx = s - objfile->sections_start;
|
int idx = &s - objfile->sections_start;
|
||||||
CORE_ADDR offset = objfile->section_offsets[idx];
|
CORE_ADDR offset = objfile->section_offsets[idx];
|
||||||
|
|
||||||
if (fallback == -1)
|
if (fallback == -1)
|
||||||
fallback = idx;
|
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);
|
sym->set_section_index (idx);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -546,14 +546,14 @@ xstormy16_find_jmp_table_entry (struct gdbarch *gdbarch, CORE_ADDR faddr)
|
|||||||
if (!strcmp (faddr_sect->the_bfd_section->name, ".plt"))
|
if (!strcmp (faddr_sect->the_bfd_section->name, ".plt"))
|
||||||
return faddr;
|
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;
|
CORE_ADDR addr, endaddr;
|
||||||
|
|
||||||
addr = osect->addr ();
|
addr = osect.addr ();
|
||||||
endaddr = osect->endaddr ();
|
endaddr = osect.endaddr ();
|
||||||
|
|
||||||
for (; addr < endaddr; addr += 2 * xstormy16_inst_size)
|
for (; addr < endaddr; addr += 2 * xstormy16_inst_size)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -962,11 +962,11 @@ z80_overlay_update_1 (struct obj_section *osect)
|
|||||||
|
|
||||||
/* we have interest for sections with same VMA */
|
/* we have interest for sections with same VMA */
|
||||||
for (objfile *objfile : current_program_space->objfiles ())
|
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 (§))
|
||||||
{
|
{
|
||||||
sect->ovly_mapped = (lma == bfd_section_lma (sect->the_bfd_section));
|
sect.ovly_mapped = (lma == bfd_section_lma (sect.the_bfd_section));
|
||||||
i |= sect->ovly_mapped; /* true, if at least one section is mapped */
|
i |= sect.ovly_mapped; /* true, if at least one section is mapped */
|
||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@@ -985,18 +985,18 @@ z80_overlay_update (struct obj_section *osect)
|
|||||||
|
|
||||||
/* Update all sections, even if only one was requested. */
|
/* Update all sections, even if only one was requested. */
|
||||||
for (objfile *objfile : current_program_space->objfiles ())
|
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;
|
continue;
|
||||||
|
|
||||||
asection *bsect = sect->the_bfd_section;
|
asection *bsect = sect.the_bfd_section;
|
||||||
bfd_vma lma = bfd_section_lma (bsect);
|
bfd_vma lma = bfd_section_lma (bsect);
|
||||||
bfd_vma vma = bfd_section_vma (bsect);
|
bfd_vma vma = bfd_section_vma (bsect);
|
||||||
|
|
||||||
for (int i = 0; i < cache_novly_regions; ++i)
|
for (int i = 0; i < cache_novly_regions; ++i)
|
||||||
if (cache_ovly_region_table[i][Z80_VMA] == vma)
|
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);
|
(cache_ovly_region_table[i][Z80_MAPPED_TO_LMA] == lma);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user