]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Revert "PR26337, Malloc size error in objdump"
authorAlan Modra <amodra@gmail.com>
Wed, 5 Aug 2020 08:08:26 +0000 (17:38 +0930)
committerAlan Modra <amodra@gmail.com>
Wed, 5 Aug 2020 08:10:02 +0000 (17:40 +0930)
This reverts commit 0b97e818464a42305c8243a980a5c13967554fd9.

binutils/ChangeLog
binutils/objdump.c

index a924ae2618dfd9c5f00d71a34859bd5b23de0233..0aab6a276e44871787be951589162d90219c487c 100644 (file)
@@ -1,3 +1,8 @@
+2020-08-05  Alan Modra  <amodra@gmail.com>
+
+       PR 26337
+       * objdump.c (load_specific_debug_section): Revert last change.
+
 2020-08-05  Alan Modra  <amodra@gmail.com>
 
        PR 26337
index 1b48cd3efdc9c19e80a79663ba814f16abc2a96a..79ef05185637ecddbe0514c17ae34699ebddc8db 100644 (file)
@@ -3545,7 +3545,6 @@ load_specific_debug_section (enum dwarf_section_display_enum debug,
       if (streq (section->filename, bfd_get_filename (abfd)))
        return TRUE;
       free (section->start);
-      section->start = NULL;
     }
 
   section->filename = bfd_get_filename (abfd);
@@ -3558,20 +3557,22 @@ load_specific_debug_section (enum dwarf_section_display_enum debug,
   alloced = amt = section->size + 1;
   if (alloced != amt || alloced == 0)
     {
+      section->start = NULL;
       free_debug_section (debug);
       printf (_("\nSection '%s' has an invalid size: %#llx.\n"),
              sanitize_string (section->name),
              (unsigned long long) section->size);
       return FALSE;
     }
-  if (!bfd_malloc_and_get_section (abfd, sec, &contents))
+  section->start = contents = malloc (alloced);
+  if (section->start == NULL
+      || !bfd_get_full_section_contents (abfd, sec, &contents))
     {
       free_debug_section (debug);
       printf (_("\nCan't get contents for section '%s'.\n"),
              sanitize_string (section->name));
       return FALSE;
     }
-  section->start = contents;
   /* Ensure any string section has a terminating NUL.  */
   section->start[section->size] = 0;