diff options
-rw-r--r-- | gdb/arm-tdep.c | 4 | ||||
-rw-r--r-- | gdb/exec.c | 4 | ||||
-rw-r--r-- | gdb/gcore.c | 6 | ||||
-rw-r--r-- | gdb/hppa-bsd-tdep.c | 59 | ||||
-rw-r--r-- | gdb/hppa-linux-tdep.c | 64 | ||||
-rw-r--r-- | gdb/hppa-tdep.c | 29 | ||||
-rw-r--r-- | gdb/ia64-tdep.c | 99 | ||||
-rw-r--r-- | gdb/machoread.c | 5 | ||||
-rw-r--r-- | gdb/maint.c | 4 | ||||
-rw-r--r-- | gdb/minsyms.c | 4 | ||||
-rw-r--r-- | gdb/objfiles.c | 17 | ||||
-rw-r--r-- | gdb/objfiles.h | 153 | ||||
-rw-r--r-- | gdb/printcmd.c | 3 | ||||
-rw-r--r-- | gdb/solib-aix.c | 4 | ||||
-rw-r--r-- | gdb/solib-dsbt.c | 3 | ||||
-rw-r--r-- | gdb/solib-frv.c | 3 | ||||
-rw-r--r-- | gdb/symfile.c | 36 | ||||
-rw-r--r-- | gdb/symtab.c | 4 | ||||
-rw-r--r-- | gdb/xstormy16-tdep.c | 53 | ||||
-rw-r--r-- | gdb/z80-tdep.c | 16 |
20 files changed, 294 insertions, 276 deletions
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index a49a8b7..40f7e23 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -2491,9 +2491,7 @@ static const registry<bfd>::key<arm_exidx_data> arm_exidx_data_key; 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; @@ -625,12 +625,10 @@ program_space::add_target_sections (void *owner, 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; diff --git a/gdb/gcore.c b/gdb/gcore.c index 973abad..05cad94 100644 --- a/gdb/gcore.c +++ b/gdb/gcore.c @@ -406,10 +406,9 @@ gcore_create_callback (CORE_ADDR vaddr, unsigned long size, int read, { /* 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; @@ -513,12 +512,11 @@ objfile_find_memory_regions (struct target_ops *self, 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); diff --git a/gdb/hppa-bsd-tdep.c b/gdb/hppa-bsd-tdep.c index c8b044f..7469567 100644 --- a/gdb/hppa-bsd-tdep.c +++ b/gdb/hppa-bsd-tdep.c @@ -54,48 +54,45 @@ hppabsd_find_global_pointer (struct gdbarch *gdbarch, struct value *function) 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; } } } diff --git a/gdb/hppa-linux-tdep.c b/gdb/hppa-linux-tdep.c index 32b13ae..1f440d8 100644 --- a/gdb/hppa-linux-tdep.c +++ b/gdb/hppa-linux-tdep.c @@ -360,49 +360,47 @@ hppa_linux_find_global_pointer (struct gdbarch *gdbarch, 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; } } } diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c index d054e80..b7c96e8 100644 --- a/gdb/hppa-tdep.c +++ b/gdb/hppa-tdep.c @@ -910,7 +910,7 @@ static CORE_ADDR 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); @@ -921,25 +921,24 @@ hppa64_convert_code_addr_to_fptr (struct gdbarch *gdbarch, CORE_ADDR 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; + } } } diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c index 37e5ce9..27da839 100644 --- a/gdb/ia64-tdep.c +++ b/gdb/ia64-tdep.c @@ -3431,48 +3431,47 @@ ia64_find_global_pointer_from_dynamic_section (struct gdbarch *gdbarch, 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; } } } @@ -3513,33 +3512,31 @@ find_extant_func_descr (struct gdbarch *gdbarch, CORE_ADDR 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, ".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; } } } diff --git a/gdb/machoread.c b/gdb/machoread.c index dc841c3..daf6256 100644 --- a/gdb/machoread.c +++ b/gdb/machoread.c @@ -893,7 +893,6 @@ macho_symfile_offsets (struct objfile *objfile, 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); @@ -909,7 +908,7 @@ macho_symfile_offsets (struct objfile *objfile, 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; @@ -923,7 +922,7 @@ macho_symfile_offsets (struct objfile *objfile, 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; diff --git a/gdb/maint.c b/gdb/maint.c index 3cd2c5e..c5f2e5c 100644 --- a/gdb/maint.c +++ b/gdb/maint.c @@ -566,9 +566,9 @@ maintenance_translate_address (const char *arg, int from_tty) 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; } diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 07e83e8..c062344 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -679,9 +679,7 @@ static int 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 ()) { diff --git a/gdb/objfiles.c b/gdb/objfiles.c index e3fa691..3fefc4a 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -657,8 +657,7 @@ objfile_relocate1 (struct objfile *objfile, 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; @@ -876,9 +875,7 @@ sort_cmp (const struct obj_section *sect1, const obj_section *sect2) 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) @@ -1071,7 +1068,7 @@ update_section_map (struct program_space *pspace, { 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 @@ -1082,7 +1079,7 @@ update_section_map (struct program_space *pspace, 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; @@ -1098,7 +1095,7 @@ update_section_map (struct program_space *pspace, 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; @@ -1214,12 +1211,10 @@ inhibit_section_map_updates (struct program_space *pspace) 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; diff --git a/gdb/objfiles.h b/gdb/objfiles.h index 1b059dd..189856f 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -127,14 +127,6 @@ struct entry_info 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) \ @@ -379,6 +371,40 @@ private: 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, @@ -609,6 +635,68 @@ public: 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 @@ -800,46 +888,19 @@ struct objfile_deleter 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 */ diff --git a/gdb/printcmd.c b/gdb/printcmd.c index e903bf4..679a24e 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -1541,7 +1541,6 @@ static void 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; @@ -1551,7 +1550,7 @@ info_symbol_command (const char *arg, int from_tty) 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. */ diff --git a/gdb/solib-aix.c b/gdb/solib-aix.c index d3119db..93aa6c4 100644 --- a/gdb/solib-aix.c +++ b/gdb/solib-aix.c @@ -662,9 +662,7 @@ solib_aix_bfd_open (const char *pathname) 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; diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c index 8106c34..6dcb8d2 100644 --- a/gdb/solib-dsbt.c +++ b/gdb/solib-dsbt.c @@ -802,7 +802,6 @@ dsbt_relocate_main_executable (void) { struct int_elf32_dsbt_loadmap *ldm; int changed; - struct obj_section *osect; struct dsbt_info *info = get_dsbt_info (); dsbt_get_initial_loadmaps (); @@ -816,7 +815,7 @@ dsbt_relocate_main_executable (void) 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; diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c index 7cce11d..8b0e3a6 100644 --- a/gdb/solib-frv.c +++ b/gdb/solib-frv.c @@ -727,7 +727,6 @@ frv_relocate_main_executable (void) 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); @@ -751,7 +750,7 @@ frv_relocate_main_executable (void) 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; diff --git a/gdb/symfile.c b/gdb/symfile.c index d1ab3cc..9623967 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -832,7 +832,6 @@ init_entry_point_info (struct objfile *objfile) if (ei->entry_point_p) { - struct obj_section *osect; CORE_ADDR entry_point = ei->entry_point; int found; @@ -847,7 +846,7 @@ init_entry_point_info (struct objfile *objfile) = 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; @@ -2999,10 +2998,8 @@ section_is_overlay (struct obj_section *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; } @@ -3174,12 +3171,12 @@ symbol_overlayed_address (CORE_ADDR address, struct obj_section *section) 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)) @@ -3203,12 +3200,10 @@ find_pc_overlay (CORE_ADDR pc) 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; } @@ -3223,12 +3218,11 @@ static void 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 (); @@ -3264,8 +3258,6 @@ list_overlays_command (const char *args, int from_tty) 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" @@ -3276,7 +3268,7 @@ map_overlay_command (const char *args, int from_tty) /* 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. */ @@ -3289,7 +3281,7 @@ map_overlay_command (const char *args, int from_tty) /* 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)) { @@ -3310,8 +3302,6 @@ map_overlay_command (const char *args, int from_tty) 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" @@ -3322,7 +3312,7 @@ unmap_overlay_command (const char *args, int from_tty) /* 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) @@ -3581,17 +3571,17 @@ simple_overlay_update (struct obj_section *osect) /* 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. */ } } diff --git a/gdb/symtab.c b/gdb/symtab.c index 594b13f..5e85c53 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -1770,9 +1770,7 @@ fixup_symbol_section (struct symbol *sym, struct objfile *objfile) 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; diff --git a/gdb/xstormy16-tdep.c b/gdb/xstormy16-tdep.c index c505281..3f47c8d 100644 --- a/gdb/xstormy16-tdep.c +++ b/gdb/xstormy16-tdep.c @@ -541,41 +541,38 @@ xstormy16_find_jmp_table_entry (struct gdbarch *gdbarch, CORE_ADDR faddr) 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; } } } diff --git a/gdb/z80-tdep.c b/gdb/z80-tdep.c index 27cdca1..4f3ad54 100644 --- a/gdb/z80-tdep.c +++ b/gdb/z80-tdep.c @@ -962,11 +962,11 @@ z80_overlay_update_1 (struct obj_section *osect) /* 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; } @@ -985,18 +985,18 @@ z80_overlay_update (struct obj_section *osect) /* 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); } } |