static void coff_symtab_read (minimal_symbol_reader &,
file_ptr, unsigned int, struct objfile *);
-struct coff_find_targ_sec_arg
- {
- int targ_index;
- asection **resultp;
- };
-
-static void
-find_targ_sec (bfd *abfd, asection *sect, void *obj)
-{
- struct coff_find_targ_sec_arg *args = (struct coff_find_targ_sec_arg *) obj;
+/* Return the BFD section that CS points to. */
- if (sect->target_index == args->targ_index)
- *args->resultp = sect;
-}
-
-/* Return the bfd_section that CS points to. */
-static struct bfd_section*
-cs_to_bfd_section (struct coff_symbol *cs, struct objfile *objfile)
+static asection *
+cs_to_bfd_section (struct coff_symbol *cs, bfd *abfd)
{
- asection *sect = NULL;
- struct coff_find_targ_sec_arg args;
+ for (asection *sect : gdb_bfd_sections (abfd))
+ if (sect->target_index == cs->c_secnum)
+ return sect;
- args.targ_index = cs->c_secnum;
- args.resultp = §
- bfd_map_over_sections (objfile->obfd.get (), find_targ_sec, &args);
- return sect;
+ return nullptr;
}
/* Return the section number (SECT_OFF_*) that CS points to. */
static int
cs_to_section (struct coff_symbol *cs, struct objfile *objfile)
{
- asection *sect = cs_to_bfd_section (cs, objfile);
+ asection *sect = cs_to_bfd_section (cs, objfile->obfd.get ());
if (sect == NULL)
return SECT_OFF_TEXT (objfile);
static CORE_ADDR
cs_section_address (struct coff_symbol *cs, bfd *abfd)
{
- asection *sect = NULL;
- struct coff_find_targ_sec_arg args;
- CORE_ADDR addr = 0;
-
- args.targ_index = cs->c_secnum;
- args.resultp = §
- bfd_map_over_sections (abfd, find_targ_sec, &args);
- if (sect != NULL)
- addr = bfd_section_vma (sect);
- return addr;
+ asection *sect = cs_to_bfd_section (cs, abfd);
+
+ if (sect == nullptr)
+ return 0;
+
+ return bfd_section_vma (sect);
}
/* Look up a coff type-number index. Return the address of the slot
}
else
{
- asection *bfd_section = cs_to_bfd_section (cs, objfile);
+ asection *bfd_section
+ = cs_to_bfd_section (cs, objfile->obfd.get ());
sec = cs_to_section (cs, objfile);
tmpaddr = cs->c_value;