]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - binutils/objdump.c
TUI resize unification
[thirdparty/binutils-gdb.git] / binutils / objdump.c
index d9c8cea36491d8f6f400f2ecde028055d9d79d42..fffbcf876db704fbb9f5ba151a336e0dfddd329e 100644 (file)
@@ -192,8 +192,6 @@ static bfd_size_type stab_size;
 static bfd_byte *strtab;
 static bfd_size_type stabstr_size;
 
-static bfd_boolean is_relocatable = FALSE;
-
 /* Handlers for -P/--private.  */
 static const struct objdump_private_desc * const objdump_private_vectors[] =
   {
@@ -704,7 +702,26 @@ slurp_symtab (bfd *abfd)
       bfd_fatal (_("error message was"));
     }
   if (storage)
-    sy = (asymbol **) xmalloc (storage);
+    {
+      off_t filesize = bfd_get_file_size (abfd);
+
+      /* qv PR 24707.  */
+      if (filesize > 0
+         && filesize < storage
+         /* The MMO file format supports its own special compression
+            technique, so its sections can be larger than the file size.  */
+         && bfd_get_flavour (abfd) != bfd_target_mmo_flavour)    
+       {
+         bfd_nonfatal_message (bfd_get_filename (abfd), abfd, NULL,
+                               _("error: symbol table size (%#lx) is larger than filesize (%#lx)"),
+                       storage, (long) filesize);
+         exit_status = 1;
+         symcount = 0;
+         return NULL;
+       }
+
+      sy = (asymbol **) xmalloc (storage);
+    }
 
   symcount = bfd_canonicalize_symtab (abfd, sy);
   if (symcount < 0)
@@ -2730,7 +2747,8 @@ load_specific_debug_section (enum dwarf_section_display_enum debug,
   /* Ensure any string section has a terminating NUL.  */
   section->start[section->size] = 0;
 
-  if (is_relocatable && debug_displays [debug].relocate)
+  if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0
+      && debug_displays [debug].relocate)
     {
       long         reloc_size;
       bfd_boolean  ret;
@@ -2924,8 +2942,6 @@ dump_dwarf (bfd *abfd)
       return;
     }
 
-  is_relocatable = (abfd->flags & (EXEC_P | DYNAMIC)) == 0;
-
   eh_addr_size = bfd_arch_bits_per_address (abfd) / 8;
 
   switch (bfd_get_arch (abfd))
@@ -3207,10 +3223,10 @@ static char *
 dump_ctf_indent_lines (ctf_sect_names_t sect ATTRIBUTE_UNUSED,
                       char *s, void *arg)
 {
-  char *spaces = arg;
+  const char *blanks = arg;
   char *new_s;
 
-  if (asprintf (&new_s, "%s%s", spaces, s) < 0)
+  if (asprintf (&new_s, "%s%s", blanks, s) < 0)
     return s;
   return new_s;
 }