]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Use gdb_bfd_get_full_section_contents in auto-load.c
authorTom Tromey <tom@tromey.com>
Thu, 17 Oct 2024 22:57:03 +0000 (16:57 -0600)
committerTom Tromey <tom@tromey.com>
Thu, 24 Oct 2024 20:17:47 +0000 (14:17 -0600)
This changes auto-load.c ot use gdb_bfd_get_full_section_contents.
This shouldn't change any behavior, but makes it easier to add locking
in a subsequent patch.

Reviewed-by: Kevin Buettner <kevinb@redhat.com>
gdb/auto-load.c

index e753333b1cdfe6a12b1885d1468ef92ef51776af..d4307eac6273803ed7024491169701e8a55fcc6b 100644 (file)
@@ -1114,25 +1114,22 @@ auto_load_section_scripts (struct objfile *objfile, const char *section_name)
 {
   bfd *abfd = objfile->obfd.get ();
   asection *scripts_sect;
-  bfd_byte *data = NULL;
 
   scripts_sect = bfd_get_section_by_name (abfd, section_name);
   if (scripts_sect == NULL
       || (bfd_section_flags (scripts_sect) & SEC_HAS_CONTENTS) == 0)
     return;
 
-  if (!bfd_get_full_section_contents (abfd, scripts_sect, &data))
+  gdb::byte_vector data;
+  if (!gdb_bfd_get_full_section_contents (abfd, scripts_sect, &data))
     warning (_("Couldn't read %s section of %ps"),
             section_name,
             styled_string (file_name_style.style (),
                            bfd_get_filename (abfd)));
   else
     {
-      gdb::unique_xmalloc_ptr<bfd_byte> data_holder (data);
-
-      char *p = (char *) data;
-      source_section_scripts (objfile, section_name, p,
-                             p + bfd_section_size (scripts_sect));
+      const char *p = (const char *) data.data ();
+      source_section_scripts (objfile, section_name, p, p + data.size ());
     }
 }