Use gdb_bfd_sections in get_stap_base_address
[deliverable/binutils-gdb.git] / gdb / stap-probe.c
index 50f6d518133a3f7e47ee46f7b2df20d287e52fbe..8af3bd7bd8cb4cc350723bd5eda767b82f8fb5a8 100644 (file)
@@ -1290,7 +1290,7 @@ stap_probe::parse_arguments (struct gdbarch *gdbarch)
 static CORE_ADDR
 relocate_address (CORE_ADDR address, struct objfile *objfile)
 {
-  return address + objfile->section_offsets[SECT_OFF_DATA (objfile)];
+  return address + objfile->data_section_offset ();
 }
 
 /* Implementation of the get_relocated_address method.  */
@@ -1517,7 +1517,7 @@ handle_stap_probe (struct objfile *objfile, struct sdt_note *el,
 {
   bfd *abfd = objfile->obfd;
   int size = bfd_get_arch_size (abfd) / 8;
-  struct gdbarch *gdbarch = get_objfile_arch (objfile);
+  struct gdbarch *gdbarch = objfile->arch ();
   struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
 
   /* Provider and the name of the probe.  */
@@ -1578,19 +1578,6 @@ handle_stap_probe (struct objfile *objfile, struct sdt_note *el,
   probesp->emplace_back (ret);
 }
 
-/* Helper function which tries to find the base address of the SystemTap
-   base section named STAP_BASE_SECTION_NAME.  */
-
-static void
-get_stap_base_address_1 (bfd *abfd, asection *sect, void *obj)
-{
-  asection **ret = (asection **) obj;
-
-  if ((sect->flags & (SEC_DATA | SEC_ALLOC | SEC_HAS_CONTENTS))
-      && sect->name && !strcmp (sect->name, STAP_BASE_SECTION_NAME))
-    *ret = sect;
-}
-
 /* Helper function which iterates over every section in the BFD file,
    trying to find the base address of the SystemTap base section.
    Returns 1 if found (setting BASE to the proper value), zero otherwise.  */
@@ -1600,13 +1587,16 @@ get_stap_base_address (bfd *obfd, bfd_vma *base)
 {
   asection *ret = NULL;
 
-  bfd_map_over_sections (obfd, get_stap_base_address_1, (void *) &ret);
+  for (asection *sect : gdb_bfd_sections (obfd))
+    if ((sect->flags & (SEC_DATA | SEC_ALLOC | SEC_HAS_CONTENTS))
+       && sect->name && !strcmp (sect->name, STAP_BASE_SECTION_NAME))
+      ret = sect;
 
   if (ret == NULL)
     {
       complaint (_("could not obtain base address for "
                                        "SystemTap section on objfile `%s'."),
-                obfd->filename);
+                bfd_get_filename (obfd));
       return 0;
     }
 
@@ -1709,8 +1699,9 @@ info_probes_stap_command (const char *arg, int from_tty)
   info_probes_for_spops (arg, from_tty, &stap_static_probe_ops);
 }
 
+void _initialize_stap_probe ();
 void
-_initialize_stap_probe (void)
+_initialize_stap_probe ()
 {
   all_static_probe_ops.push_back (&stap_static_probe_ops);
 
This page took 0.025218 seconds and 4 git commands to generate.