Fix attributation of previous delta
[deliverable/binutils-gdb.git] / binutils / readelf.c
index 4326cd00cab116106b35a5b4c973b60b47abc5d6..d2ced1e791015ae87a92d916534327f2f13a284e 100644 (file)
@@ -1629,7 +1629,8 @@ dump_relocations (Filedata *          filedata,
        {
          if (symtab == NULL || symtab_index >= nsyms)
            {
-             error (_(" bad symbol index: %08lx in reloc"), (unsigned long) symtab_index);
+             error (_(" bad symbol index: %08lx in reloc\n"),
+                    (unsigned long) symtab_index);
              res = FALSE;
            }
          else
@@ -1733,7 +1734,8 @@ dump_relocations (Filedata *          filedata,
                printf (_("<string table index: %3ld>"), psym->st_name);
              else if (psym->st_name >= strtablen)
                {
-                 error (_("<corrupt string table index: %3ld>"), psym->st_name);
+                 error (_("<corrupt string table index: %3ld>\n"),
+                        psym->st_name);
                  res = FALSE;
                }
              else
@@ -8786,7 +8788,7 @@ decode_arm_unwind_bytecode (Filedata *                 filedata,
            }
          if (i == sizeof (buf))
            {
-             error (_("corrupt change to vsp"));
+             error (_("corrupt change to vsp\n"));
              res = FALSE;
            }
          else
@@ -9877,7 +9879,8 @@ process_dynamic_section (Filedata * filedata)
          if ((bfd_size_type) section.sh_offset > filedata->file_size)
            {
              /* See PR 21379 for a reproducer.  */
-             error (_("Invalid DT_SYMTAB entry: %lx"), (long) section.sh_offset);
+             error (_("Invalid DT_SYMTAB entry: %lx\n"),
+                    (long) section.sh_offset);
              return FALSE;
            }
 
@@ -11176,7 +11179,7 @@ get_symbol_visibility (unsigned int visibility)
     case STV_HIDDEN:   return "HIDDEN";
     case STV_PROTECTED: return "PROTECTED";
     default:
-      error (_("Unrecognized visibility value: %u"), visibility);
+      error (_("Unrecognized visibility value: %u\n"), visibility);
       return _("<unknown>");
     }
 }
@@ -11189,7 +11192,7 @@ get_alpha_symbol_other (unsigned int other)
     case STO_ALPHA_NOPV:       return "NOPV";
     case STO_ALPHA_STD_GPLOAD: return "STD GPLOAD";
     default:
-      error (_("Unrecognized alpah specific other value: %u"), other);
+      error (_("Unrecognized alpha specific other value: %u\n"), other);
       return _("<unknown>");
     }
 }
@@ -13333,6 +13336,11 @@ apply_relocations (Filedata *                 filedata,
          || relsec->sh_link >= filedata->file_header.e_shnum)
        continue;
 
+      symsec = filedata->section_headers + relsec->sh_link;
+      if (symsec->sh_type != SHT_SYMTAB
+         && symsec->sh_type != SHT_DYNSYM)
+       return FALSE;
+
       is_rela = relsec->sh_type == SHT_RELA;
 
       if (is_rela)
@@ -13352,10 +13360,6 @@ apply_relocations (Filedata *                 filedata,
       if (filedata->file_header.e_machine == EM_SH)
        is_rela = FALSE;
 
-      symsec = filedata->section_headers + relsec->sh_link;
-      if (symsec->sh_type != SHT_SYMTAB
-         && symsec->sh_type != SHT_DYNSYM)
-       return FALSE;
       symtab = GET_ELF_SYMBOLS (filedata, symsec, & num_syms);
 
       for (rp = relocs; rp < relocs + num_relocs; ++rp)
@@ -14121,7 +14125,7 @@ load_specific_debug_section (enum dwarf_section_display_enum  debug,
                      ? sizeof (Elf32_External_Chdr)
                      : sizeof (Elf64_External_Chdr)))
            {
-             warn (_("compressed section %s is too small to contain a compression header"),
+             warn (_("compressed section %s is too small to contain a compression header\n"),
                    section->name);
              return FALSE;
            }
@@ -14203,7 +14207,8 @@ get_build_id (void * data)
   Elf_Internal_Shdr * shdr;
   unsigned long i;
 
-  /* Iterate through notes to find note.gnu.build-id.  */
+  /* Iterate through notes to find note.gnu.build-id.
+     FIXME: Only the first note in any note section is examined.  */
   for (i = 0, shdr = filedata->section_headers;
        i < filedata->file_header.e_shnum && shdr != NULL;
        i++, shdr++)
@@ -14239,13 +14244,10 @@ get_build_id (void * data)
           min_notesz = offsetof (Elf_External_Note, name);
           if (data_remaining < min_notesz)
             {
-              warn (ngettext ("debuginfod: Corrupt note: only %ld byte remains, "
-                              "not enough for a full note\n",
-                              "Corrupt note: only %ld bytes remain, "
-                              "not enough for a full note\n",
-                              data_remaining),
-                    (long) data_remaining);
-              break;
+             warn (_("\
+malformed note encountered in section %s whilst scanning for build-id note\n"),
+                   printable_section_name (filedata, shdr));
+              continue;
             }
           data_remaining -= min_notesz;
 
@@ -14268,13 +14270,10 @@ get_build_id (void * data)
           min_notesz = offsetof (Elf64_External_VMS_Note, name);
           if (data_remaining < min_notesz)
             {
-              warn (ngettext ("debuginfod: Corrupt note: only %ld byte remains, "
-                              "not enough for a full note\n",
-                              "Corrupt note: only %ld bytes remain, "
-                              "not enough for a full note\n",
-                              data_remaining),
-                    (long) data_remaining);
-              break;
+             warn (_("\
+malformed note encountered in section %s whilst scanning for build-id note\n"),
+                   printable_section_name (filedata, shdr));
+              continue;
             }
           data_remaining -= min_notesz;
 
@@ -14295,9 +14294,9 @@ get_build_id (void * data)
           || ((size_t) (next - inote.descdata)
               > data_remaining - (size_t) (inote.descdata - inote.namedata)))
         {
-          warn (_("debuginfod: note with invalid namesz and/or descsz found\n"));
-          warn (_(" type: 0x%lx, namesize: 0x%08lx, descsize: 0x%08lx, alignment: %u\n"),
-                inote.type, inote.namesz, inote.descsz, (int) align);
+         warn (_("\
+malformed note encountered in section %s whilst scanning for build-id note\n"),
+               printable_section_name (filedata, shdr));
           continue;
         }
 
@@ -14312,13 +14311,13 @@ get_build_id (void * data)
 
           build_id = malloc (inote.descsz * 2 + 1);
           if (build_id == NULL)
-              return NULL;
+           return NULL;
 
           for (j = 0; j < inote.descsz; ++j)
             sprintf (build_id + (j * 2), "%02x", inote.descdata[j] & 0xff);
           build_id[inote.descsz * 2] = '\0';
 
-          return (unsigned char *)build_id;
+          return (unsigned char *) build_id;
         }
     }
 
@@ -14395,6 +14394,13 @@ free_debug_section (enum dwarf_section_display_enum debug)
   section->start = NULL;
   section->address = 0;
   section->size = 0;
+
+  if (section->reloc_info != NULL)
+    {
+      free (section->reloc_info);
+      section->reloc_info = NULL;
+      section->num_relocs = 0;
+    }
 }
 
 static bfd_boolean
@@ -19341,6 +19347,7 @@ process_notes_at (Filedata *           filedata,
     {
       warn (_("Corrupt note: alignment %ld, expecting 4 or 8\n"),
            (long) align);
+      free (pnotes);
       return FALSE;
     }
 
@@ -20011,6 +20018,13 @@ process_object (Filedata * filedata)
   filedata->string_table = NULL;
   filedata->string_table_length = 0;
 
+  if (filedata->dump_sects != NULL)
+    {
+      free (filedata->dump_sects);
+      filedata->dump_sects = NULL;
+      filedata->num_dump_sects = 0;
+    }
+
   if (dynamic_strings)
     {
       free (dynamic_strings);
@@ -20316,13 +20330,6 @@ process_archive (Filedata * filedata, bfd_boolean is_thin_archive)
            ret = FALSE;
         }
 
-      if (filedata->dump_sects != NULL)
-       {
-         free (filedata->dump_sects);
-         filedata->dump_sects = NULL;
-         filedata->num_dump_sects = 0;
-       }
-
       free (qualified_name);
     }
 
This page took 0.033438 seconds and 4 git commands to generate.