]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/mips: replace bfd_map_over_sections with gdb_bfd_sections (2)
authorSimon Marchi <simon.marchi@polymtl.ca>
Fri, 16 Jan 2026 18:35:54 +0000 (13:35 -0500)
committerSimon Marchi <simon.marchi@polymtl.ca>
Fri, 16 Jan 2026 20:46:36 +0000 (15:46 -0500)
Replace bfd_map_over_sections with iteration over gdb_bfd_sections.

Change-Id: I34182a67ee52da479c1868a5880709c401cbf34e
Approved-By: Tom Tromey <tom@tromey.com>
gdb/mips-tdep.c

index c2913c87c0e2645d3803b91c6de0cabafc1b8800..aa52c0b245845295df8c2cfffa1c71af1ac1904b 100644 (file)
@@ -7988,18 +7988,22 @@ mips_find_abi_from_sections (bfd *abfd)
   return MIPS_ABI_UNKNOWN;
 }
 
-static void
-mips_find_long_section (bfd *abfd, asection *sect, void *obj)
+static int
+mips_find_long_bit_from_sections (bfd *abfd)
 {
-  int *lbp = (int *) obj;
-  const char *name = bfd_section_name (sect);
+  for (asection *sect : gdb_bfd_sections (abfd))
+    {
+      const char *name = bfd_section_name (sect);
+
+      if (startswith (name, ".gcc_compiled_long32"))
+       return 32;
+      else if (startswith (name, ".gcc_compiled_long64"))
+       return 64;
+      else if (startswith (name, ".gcc_compiled_long"))
+       warning (_("unrecognized section %s."), name);
+    }
 
-  if (startswith (name, ".gcc_compiled_long32"))
-    *lbp = 32;
-  else if (startswith (name, ".gcc_compiled_long64"))
-    *lbp = 64;
-  else if (startswith (name, ".gcc_compiled_long"))
-    warning (_("unrecognized .gcc_compiled_longXX"));
+  return 0;
 }
 
 static enum mips_abi
@@ -8614,10 +8618,9 @@ mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   if (info.abfd != NULL)
     {
-      int long_bit = 0;
+      int long_bit = mips_find_long_bit_from_sections (info.abfd);
 
-      bfd_map_over_sections (info.abfd, mips_find_long_section, &long_bit);
-      if (long_bit)
+      if (long_bit != 0)
        {
          set_gdbarch_long_bit (gdbarch, long_bit);
          switch (mips_abi)