]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/hppa: replace bfd_map_over_sections with gdb_bfd_sections
authorSimon Marchi <simon.marchi@polymtl.ca>
Fri, 16 Jan 2026 18:35:58 +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: I92ba6b5ef9e9ab3d2ebe364373aeaf459fd6e34c
Approved-By: Tom Tromey <tom@tromey.com>
gdb/hppa-tdep.c

index 58d0cf1cb65cfc9837001c90ee7cdca518649d8b..7d74c82534fcdc099f9ed84a513e65a3fd3bdbf8 100644 (file)
@@ -232,18 +232,22 @@ compare_unwind_entries (const void *arg1, const void *arg2)
     return 0;
 }
 
-static void
-record_text_segment_lowaddr (bfd *abfd, asection *section, void *data)
+static CORE_ADDR
+record_text_segment_lowaddr (bfd *abfd)
 {
-  if ((section->flags & (SEC_ALLOC | SEC_LOAD | SEC_READONLY))
-       == (SEC_ALLOC | SEC_LOAD | SEC_READONLY))
-    {
-      bfd_vma value = section->vma - section->filepos;
-      CORE_ADDR *low_text_segment_address = (CORE_ADDR *)data;
+  CORE_ADDR lowaddr = -1;
 
-      if (value < *low_text_segment_address)
-         *low_text_segment_address = value;
-    }
+  for (asection *section : gdb_bfd_sections (abfd))
+    if ((section->flags & (SEC_ALLOC | SEC_LOAD | SEC_READONLY))
+       == (SEC_ALLOC | SEC_LOAD | SEC_READONLY))
+      {
+       bfd_vma value = section->vma - section->filepos;
+
+       if (value < lowaddr)
+         lowaddr = value;
+      }
+
+  return lowaddr;
 }
 
 static void
@@ -261,7 +265,6 @@ internalize_unwinds (struct objfile *objfile, struct unwind_table_entry *table,
       unsigned long tmp;
       unsigned i;
       char *buf = (char *) alloca (size);
-      CORE_ADDR low_text_segment_address;
 
       /* For ELF targets, then unwinds are supposed to
         be segment relative offsets instead of absolute addresses.
@@ -270,19 +273,9 @@ internalize_unwinds (struct objfile *objfile, struct unwind_table_entry *table,
         unwinds are already relative to the text_offset that will be
         passed in.  */
       if (tdep->is_elf && text_offset == 0)
-       {
-         low_text_segment_address = -1;
-
-         bfd_map_over_sections (objfile->obfd.get (),
-                                record_text_segment_lowaddr,
-                                &low_text_segment_address);
-
-         text_offset = low_text_segment_address;
-       }
+       text_offset = record_text_segment_lowaddr (objfile->obfd.get ());
       else if (tdep->solib_get_text_base)
-       {
-         text_offset = tdep->solib_get_text_base (objfile);
-       }
+       text_offset = tdep->solib_get_text_base (objfile);
 
       bfd_get_section_contents (objfile->obfd.get (), section, buf, 0, size);