[PR gdb/25939] Move push_target call earlier in procfs.c
[deliverable/binutils-gdb.git] / binutils / readelf.c
index 25c2cce21ae8ecbc84a3519d5e01d6310a664ffa..101fd66ccb76999f9e7171ff7b17a44b705a98b3 100644 (file)
@@ -231,7 +231,6 @@ static bfd_boolean do_ctf = FALSE;
 static bfd_boolean do_arch = FALSE;
 static bfd_boolean do_notes = FALSE;
 static bfd_boolean do_archive_index = FALSE;
-static bfd_boolean do_checks = FALSE;
 static bfd_boolean check_all = FALSE;
 static bfd_boolean is_32bit_elf = FALSE;
 static bfd_boolean decompress_dumps = FALSE;
@@ -268,8 +267,10 @@ typedef struct filedata
   bfd_size_type        dynamic_size;
   size_t               dynamic_nent;
   Elf_Internal_Dyn *   dynamic_section;
+  Elf_Internal_Shdr *  dynamic_strtab_section;
   char *               dynamic_strings;
   unsigned long        dynamic_strings_length;
+  Elf_Internal_Shdr *  dynamic_symtab_section;
   unsigned long        num_dynamic_syms;
   Elf_Internal_Sym *   dynamic_symbols;
   bfd_vma              version_info[16];
@@ -387,25 +388,6 @@ bfd_vmatoa (char *fmtch, bfd_vma value)
   return ret;
 }
 
-/* A version of the warn() function that is disabled if do_checks is not active.  */
-
-void
-warn (const char *message, ...)
-{
-  va_list args;
-
-  if (!do_checks)
-    return;
-
-  /* Try to keep warning messages in sync with the program's normal output.  */
-  fflush (stdout);
-
-  va_start (args, message);
-  fprintf (stderr, _("%s: Warning: "), program_name);
-  vfprintf (stderr, message, args);
-  va_end (args);
-}
-
 /* Retrieve NMEMB structures, each SIZE bytes long from FILEDATA starting at
    OFFSET + the offset of the current archive member, if we are examining an
    archive.  Put the retrieved data into VAR, if it is not NULL.  Otherwise
@@ -5383,13 +5365,13 @@ process_program_headers (Filedata * filedata)
              filedata->dynamic_addr = sec->sh_offset;
              filedata->dynamic_size = sec->sh_size;
 
-             if (filedata->dynamic_addr < segment->p_offset
-                 || filedata->dynamic_addr > segment->p_offset + segment->p_filesz)
-               warn (_("the .dynamic section is not contained"
-                       " within the dynamic segment\n"));
-             else if (filedata->dynamic_addr > segment->p_offset)
-               warn (_("the .dynamic section is not the first section"
-                       " in the dynamic segment.\n"));
+             /* The PT_DYNAMIC segment, which is used by the run-time
+                loader,  should exactly match the .dynamic section.  */
+             if (do_checks
+                 && (filedata->dynamic_addr != segment->p_offset
+                     || filedata->dynamic_size != segment->p_filesz))
+               warn (_("\
+the .dynamic section is not the same as the dynamic segment\n"));
            }
 
          /* PR binutils/17512: Avoid corrupt dynamic section info in the
@@ -6339,6 +6321,7 @@ process_section_headers (Filedata * filedata)
          CHECK_ENTSIZE (section, i, Sym);
          filedata->dynamic_symbols
            = GET_ELF_SYMBOLS (filedata, section, &filedata->num_dynamic_syms);
+         filedata->dynamic_symtab_section = section;
          break;
 
        case SHT_STRTAB:
@@ -6355,6 +6338,7 @@ process_section_headers (Filedata * filedata)
                                     1, section->sh_size, _("dynamic strings"));
              filedata->dynamic_strings_length
                = filedata->dynamic_strings == NULL ? 0 : section->sh_size;
+             filedata->dynamic_strtab_section = section;
            }
          break;
 
@@ -6378,21 +6362,22 @@ process_section_headers (Filedata * filedata)
 
        case SHT_REL:
          CHECK_ENTSIZE (section, i, Rel);
-         if (section->sh_size == 0)
+         if (do_checks && section->sh_size == 0)
            warn (_("Section '%s': zero-sized relocation section\n"), name);
          break;
 
        case SHT_RELA:
          CHECK_ENTSIZE (section, i, Rela);
-         if (section->sh_size == 0)
+         if (do_checks && section->sh_size == 0)
            warn (_("Section '%s': zero-sized relocation section\n"), name);
          break;
 
        case SHT_NOTE:
        case SHT_PROGBITS:
-         if (section->sh_size == 0)
-           /* This is not illegal according to the ELF standard, but
-              it might be an indication that something is wrong.  */
+         /* Having a zero sized section is not illegal according to the
+            ELF standard, but it might be an indication that something
+            is wrong.  So issue a warning if we are running in lint mode.  */
+         if (do_checks && section->sh_size == 0)
            warn (_("Section '%s': has a size of zero - is this intended ?\n"), name);
          break;
 
@@ -7025,8 +7010,7 @@ process_section_groups (Filedata * filedata)
          if (symtab_sec != sec)
            {
              symtab_sec = sec;
-             if (symtab)
-               free (symtab);
+             free (symtab);
              symtab = GET_ELF_SYMBOLS (filedata, symtab_sec, & num_syms);
            }
 
@@ -7055,8 +7039,7 @@ process_section_groups (Filedata * filedata)
 
              group_name = SECTION_NAME (filedata->section_headers + sym->st_shndx);
              strtab_sec = NULL;
-             if (strtab)
-               free (strtab);
+             free (strtab);
              strtab = NULL;
              strtab_size = 0;
            }
@@ -7066,8 +7049,7 @@ process_section_groups (Filedata * filedata)
              if (symtab_sec->sh_link >= filedata->file_header.e_shnum)
                {
                  strtab_sec = NULL;
-                 if (strtab)
-                   free (strtab);
+                 free (strtab);
                  strtab = NULL;
                  strtab_size = 0;
                }
@@ -7075,8 +7057,7 @@ process_section_groups (Filedata * filedata)
                       != (sec = filedata->section_headers + symtab_sec->sh_link))
                {
                  strtab_sec = sec;
-                 if (strtab)
-                   free (strtab);
+                 free (strtab);
 
                  strtab = (char *) get_data (NULL, filedata, strtab_sec->sh_offset,
                                              1, strtab_sec->sh_size,
@@ -7184,17 +7165,14 @@ process_section_groups (Filedata * filedata)
              group->root = g;
            }
 
-         if (start)
-           free (start);
+         free (start);
 
          group++;
        }
     }
 
-  if (symtab)
-    free (symtab);
-  if (strtab)
-    free (strtab);
+  free (symtab);
+  free (strtab);
   return TRUE;
 }
 
@@ -7382,8 +7360,7 @@ process_ia64_vms_dynamic_relocs (Filedata * filedata)
        }
     }
 
-  if (strtab != NULL)
-    free (strtab);
+  free (strtab);
 
   return res;
 }
@@ -7529,8 +7506,7 @@ process_relocs (Filedata * filedata)
                                    symtab, nsyms, strtab, strtablen,
                                    is_rela,
                                    symsec->sh_type == SHT_DYNSYM);
-                 if (strtab)
-                   free (strtab);
+                 free (strtab);
                  free (symtab);
                }
              else
@@ -8056,19 +8032,15 @@ ia64_process_unwind (Filedata * filedata)
              && aux.table_len > 0)
            dump_ia64_unwind (filedata, & aux);
 
-         if (aux.table)
-           free ((char *) aux.table);
-         if (aux.info)
-           free ((char *) aux.info);
+         free ((char *) aux.table);
+         free ((char *) aux.info);
          aux.table = NULL;
          aux.info = NULL;
        }
     }
 
-  if (aux.symtab)
-    free (aux.symtab);
-  if (aux.strtab)
-    free ((char *) aux.strtab);
+  free (aux.symtab);
+  free ((char *) aux.strtab);
 
   return res;
 }
@@ -8438,16 +8410,13 @@ hppa_process_unwind (Filedata * filedata)
                res = FALSE;
            }
 
-         if (aux.table)
-           free ((char *) aux.table);
+         free ((char *) aux.table);
          aux.table = NULL;
        }
     }
 
-  if (aux.symtab)
-    free (aux.symtab);
-  if (aux.strtab)
-    free ((char *) aux.strtab);
+  free (aux.symtab);
+  free ((char *) aux.strtab);
 
   return res;
 }
@@ -8507,11 +8476,8 @@ arm_print_vma_and_name (Filedata *                 filedata,
 static void
 arm_free_section (struct arm_section *arm_sec)
 {
-  if (arm_sec->data != NULL)
-    free (arm_sec->data);
-
-  if (arm_sec->rela != NULL)
-    free (arm_sec->rela);
+  free (arm_sec->data);
+  free (arm_sec->rela);
 }
 
 /* 1) If SEC does not match the one cached in ARM_SEC, then free the current
@@ -9545,10 +9511,8 @@ arm_process_unwind (Filedata * filedata)
          }
       }
 
-  if (aux.symtab)
-    free (aux.symtab);
-  if (aux.strtab)
-    free ((char *) aux.strtab);
+  free (aux.symtab);
+  free ((char *) aux.strtab);
 
   return res;
 }
@@ -10077,16 +10041,10 @@ get_num_dynamic_syms (Filedata * filedata)
     no_hash:
       if (num_of_syms == 0)
        {
-         if (filedata->buckets)
-           {
-             free (filedata->buckets);
-             filedata->buckets = NULL;
-           }
-         if (filedata->chains)
-           {
-             free (filedata->chains);
-             filedata->chains = NULL;
-           }
+         free (filedata->buckets);
+         filedata->buckets = NULL;
+         free (filedata->chains);
+         filedata->chains = NULL;
          filedata->nbuckets = 0;
        }
     }
@@ -10226,7 +10184,8 @@ get_num_dynamic_syms (Filedata * filedata)
              {
                if (filedata->dynamic_info_DT_MIPS_XHASH)
                  {
-                   if (filedata->mipsxlat[off] >= num_of_syms)
+                   if (off < filedata->ngnuchains
+                       && filedata->mipsxlat[off] >= num_of_syms)
                      num_of_syms = filedata->mipsxlat[off] + 1;
                  }
                else
@@ -10243,21 +10202,12 @@ get_num_dynamic_syms (Filedata * filedata)
       if (num_of_syms == 0)
        {
        no_gnu_hash:
-         if (filedata->mipsxlat)
-           {
-             free (filedata->mipsxlat);
-             filedata->mipsxlat = NULL;
-           }
-         if (filedata->gnuchains)
-           {
-             free (filedata->gnuchains);
-             filedata->gnuchains = NULL;
-           }
-         if (filedata->gnubuckets)
-           {
-             free (filedata->gnubuckets);
-             filedata->gnubuckets = NULL;
-           }
+         free (filedata->mipsxlat);
+         filedata->mipsxlat = NULL;
+         free (filedata->gnuchains);
+         filedata->gnuchains = NULL;
+         free (filedata->gnubuckets);
+         filedata->gnubuckets = NULL;
          filedata->ngnubuckets = 0;
          filedata->ngnuchains = 0;
        }
@@ -10360,6 +10310,18 @@ process_dynamic_section (Filedata * filedata)
                  section.sh_size = (num_of_syms
                                     * filedata->dynamic_info[DT_SYMENT]);
                  section.sh_entsize = filedata->dynamic_info[DT_SYMENT];
+
+                 if (do_checks
+                     && filedata->dynamic_symtab_section != NULL
+                     && ((filedata->dynamic_symtab_section->sh_offset
+                          != section.sh_offset)
+                         || (filedata->dynamic_symtab_section->sh_size
+                             != section.sh_size)
+                         || (filedata->dynamic_symtab_section->sh_entsize
+                             != section.sh_entsize)))
+                   warn (_("\
+the .dynsym section doesn't match the DT_SYMTAB and DT_SYMENT tags\n"));
+
                  section.sh_name = filedata->string_table_length;
                  filedata->dynamic_symbols
                    = GET_ELF_SYMBOLS (filedata, &section,
@@ -10397,6 +10359,15 @@ process_dynamic_section (Filedata * filedata)
            offset = offset_from_vma (filedata,
                                      filedata->dynamic_info[DT_STRTAB],
                                      str_tab_len);
+           if (do_checks
+               && filedata->dynamic_strtab_section
+               && ((filedata->dynamic_strtab_section->sh_offset
+                    != (file_ptr) offset)
+                   || (filedata->dynamic_strtab_section->sh_size
+                       != str_tab_len)))
+             warn (_("\
+the .dynstr section doesn't match the DT_STRTAB and DT_STRSZ tags\n"));
+
            filedata->dynamic_strings
              = (char *) get_data (NULL, filedata, offset, 1, str_tab_len,
                                   _("dynamic string table"));
@@ -14647,12 +14618,9 @@ free_debug_section (enum dwarf_section_display_enum debug)
   section->address = 0;
   section->size = 0;
 
-  if (section->reloc_info != NULL)
-    {
-      free (section->reloc_info);
-      section->reloc_info = NULL;
-      section->num_relocs = 0;
-    }
+  free (section->reloc_info);
+  section->reloc_info = NULL;
+  section->num_relocs = 0;
 }
 
 static bfd_boolean
@@ -16756,8 +16724,7 @@ process_mips_specific (Filedata * filedata)
            }
 
        sgot_print_fail:
-         if (data)
-           free (data);
+         free (data);
        }
       return res;
     }
@@ -16927,47 +16894,28 @@ process_mips_specific (Filedata * filedata)
                                                 sect->sh_size, _("options"));
       if (eopt)
        {
-         Elf_Internal_Options * iopt;
-         Elf_Internal_Options * option;
-         Elf_Internal_Options * iopt_end;
-
-         iopt = (Elf_Internal_Options *)
-              cmalloc ((sect->sh_size / sizeof (eopt)), sizeof (* iopt));
-         if (iopt == NULL)
-           {
-             error (_("Out of memory allocating space for MIPS options\n"));
-             free (eopt);
-             return FALSE;
-           }
+         Elf_Internal_Options option;
 
          offset = cnt = 0;
-         option = iopt;
-         iopt_end = iopt + (sect->sh_size / sizeof (eopt));
-         
          while (offset <= sect->sh_size - sizeof (* eopt))
            {
              Elf_External_Options * eoption;
+             unsigned int optsize;
 
              eoption = (Elf_External_Options *) ((char *) eopt + offset);
 
-             option->kind = BYTE_GET (eoption->kind);
-             option->size = BYTE_GET (eoption->size);
-             option->section = BYTE_GET (eoption->section);
-             option->info = BYTE_GET (eoption->info);
+             optsize = BYTE_GET (eoption->size);
 
              /* PR 17531: file: ffa0fa3b.  */
-             if (option->size < sizeof (* eopt)
-                 || offset + option->size > sect->sh_size)
+             if (optsize < sizeof (* eopt)
+                 || optsize > sect->sh_size - offset)
                {
                  error (_("Invalid size (%u) for MIPS option\n"),
-                        option->size);
-                 free (iopt);
+                        optsize);
                  free (eopt);
                  return FALSE;
                }
-             offset += option->size;
-
-             ++option;
+             offset += optsize;
              ++cnt;
            }
 
@@ -16976,18 +16924,25 @@ process_mips_specific (Filedata * filedata)
                            cnt),
                  printable_section_name (filedata, sect), cnt);
 
-         option = iopt;
          offset = 0;
-
          while (cnt-- > 0)
            {
              size_t len;
+             Elf_External_Options * eoption;
 
-             switch (option->kind)
+             eoption = (Elf_External_Options *) ((char *) eopt + offset);
+
+             option.kind = BYTE_GET (eoption->kind);
+             option.size = BYTE_GET (eoption->size);
+             option.section = BYTE_GET (eoption->section);
+             option.info = BYTE_GET (eoption->info);
+
+             switch (option.kind)
                {
                case ODK_NULL:
                  /* This shouldn't happen.  */
-                 printf (" NULL       %d %lx", option->section, option->info);
+                 printf (" NULL       %" PRId16 " %" PRIx32,
+                         option.section, option.info);
                  break;
 
                case ODK_REGINFO:
@@ -16998,7 +16953,8 @@ process_mips_specific (Filedata * filedata)
                      Elf32_RegInfo reginfo;
 
                      /* 32bit form.  */
-                     if (option + 2 > iopt_end)
+                     if (option.size < (sizeof (Elf_External_Options)
+                                        + sizeof (Elf32_External_RegInfo)))
                        {
                          printf (_("<corrupt>\n"));
                          error (_("Truncated MIPS REGINFO option\n"));
@@ -17006,7 +16962,7 @@ process_mips_specific (Filedata * filedata)
                          break;
                        }
 
-                     ereg = (Elf32_External_RegInfo *) (option + 1);
+                     ereg = (Elf32_External_RegInfo *) (eoption + 1);
 
                      reginfo.ri_gprmask = BYTE_GET (ereg->ri_gprmask);
                      reginfo.ri_cprmask[0] = BYTE_GET (ereg->ri_cprmask[0]);
@@ -17015,10 +16971,11 @@ process_mips_specific (Filedata * filedata)
                      reginfo.ri_cprmask[3] = BYTE_GET (ereg->ri_cprmask[3]);
                      reginfo.ri_gp_value = BYTE_GET (ereg->ri_gp_value);
 
-                     printf ("GPR %08lx  GP 0x%lx\n",
-                             reginfo.ri_gprmask,
-                             (unsigned long) reginfo.ri_gp_value);
-                     printf ("            CPR0 %08lx  CPR1 %08lx  CPR2 %08lx  CPR3 %08lx\n",
+                     printf ("GPR %08" PRIx32 "  GP 0x%" PRIx32 "\n",
+                             reginfo.ri_gprmask, reginfo.ri_gp_value);
+                     printf ("          "
+                             "  CPR0 %08" PRIx32 "  CPR1 %08" PRIx32
+                             "  CPR2 %08" PRIx32 "  CPR3 %08" PRIx32 "\n",
                              reginfo.ri_cprmask[0], reginfo.ri_cprmask[1],
                              reginfo.ri_cprmask[2], reginfo.ri_cprmask[3]);
                    }
@@ -17028,7 +16985,8 @@ process_mips_specific (Filedata * filedata)
                      Elf64_External_RegInfo * ereg;
                      Elf64_Internal_RegInfo reginfo;
 
-                     if (option + 2 > iopt_end)
+                     if (option.size < (sizeof (Elf_External_Options)
+                                        + sizeof (Elf64_External_RegInfo)))
                        {
                          printf (_("<corrupt>\n"));
                          error (_("Truncated MIPS REGINFO option\n"));
@@ -17036,7 +16994,7 @@ process_mips_specific (Filedata * filedata)
                          break;
                        }
 
-                     ereg = (Elf64_External_RegInfo *) (option + 1);
+                     ereg = (Elf64_External_RegInfo *) (eoption + 1);
                      reginfo.ri_gprmask    = BYTE_GET (ereg->ri_gprmask);
                      reginfo.ri_cprmask[0] = BYTE_GET (ereg->ri_cprmask[0]);
                      reginfo.ri_cprmask[1] = BYTE_GET (ereg->ri_cprmask[1]);
@@ -17044,54 +17002,53 @@ process_mips_specific (Filedata * filedata)
                      reginfo.ri_cprmask[3] = BYTE_GET (ereg->ri_cprmask[3]);
                      reginfo.ri_gp_value   = BYTE_GET (ereg->ri_gp_value);
 
-                     printf ("GPR %08lx  GP 0x",
-                             reginfo.ri_gprmask);
-                     printf_vma (reginfo.ri_gp_value);
-                     printf ("\n");
-
-                     printf ("            CPR0 %08lx  CPR1 %08lx  CPR2 %08lx  CPR3 %08lx\n",
+                     printf ("GPR %08" PRIx32 "  GP 0x%" PRIx64 "\n",
+                             reginfo.ri_gprmask, reginfo.ri_gp_value);
+                     printf ("          "
+                             "  CPR0 %08" PRIx32 "  CPR1 %08" PRIx32
+                             "  CPR2 %08" PRIx32 "  CPR3 %08" PRIx32 "\n",
                              reginfo.ri_cprmask[0], reginfo.ri_cprmask[1],
                              reginfo.ri_cprmask[2], reginfo.ri_cprmask[3]);
                    }
-                 ++option;
+                 offset += option.size;
                  continue;
 
                case ODK_EXCEPTIONS:
                  fputs (" EXCEPTIONS fpe_min(", stdout);
-                 process_mips_fpe_exception (option->info & OEX_FPU_MIN);
+                 process_mips_fpe_exception (option.info & OEX_FPU_MIN);
                  fputs (") fpe_max(", stdout);
-                 process_mips_fpe_exception ((option->info & OEX_FPU_MAX) >> 8);
+                 process_mips_fpe_exception ((option.info & OEX_FPU_MAX) >> 8);
                  fputs (")", stdout);
 
-                 if (option->info & OEX_PAGE0)
+                 if (option.info & OEX_PAGE0)
                    fputs (" PAGE0", stdout);
-                 if (option->info & OEX_SMM)
+                 if (option.info & OEX_SMM)
                    fputs (" SMM", stdout);
-                 if (option->info & OEX_FPDBUG)
+                 if (option.info & OEX_FPDBUG)
                    fputs (" FPDBUG", stdout);
-                 if (option->info & OEX_DISMISS)
+                 if (option.info & OEX_DISMISS)
                    fputs (" DISMISS", stdout);
                  break;
 
                case ODK_PAD:
                  fputs (" PAD       ", stdout);
-                 if (option->info & OPAD_PREFIX)
+                 if (option.info & OPAD_PREFIX)
                    fputs (" PREFIX", stdout);
-                 if (option->info & OPAD_POSTFIX)
+                 if (option.info & OPAD_POSTFIX)
                    fputs (" POSTFIX", stdout);
-                 if (option->info & OPAD_SYMBOL)
+                 if (option.info & OPAD_SYMBOL)
                    fputs (" SYMBOL", stdout);
                  break;
 
                case ODK_HWPATCH:
                  fputs (" HWPATCH   ", stdout);
-                 if (option->info & OHW_R4KEOP)
+                 if (option.info & OHW_R4KEOP)
                    fputs (" R4KEOP", stdout);
-                 if (option->info & OHW_R8KPFETCH)
+                 if (option.info & OHW_R8KPFETCH)
                    fputs (" R8KPFETCH", stdout);
-                 if (option->info & OHW_R5KEOP)
+                 if (option.info & OHW_R5KEOP)
                    fputs (" R5KEOP", stdout);
-                 if (option->info & OHW_R5KCVTL)
+                 if (option.info & OHW_R5KCVTL)
                    fputs (" R5KCVTL", stdout);
                  break;
 
@@ -17107,43 +17064,43 @@ process_mips_specific (Filedata * filedata)
 
                case ODK_HWAND:
                  fputs (" HWAND     ", stdout);
-                 if (option->info & OHWA0_R4KEOP_CHECKED)
+                 if (option.info & OHWA0_R4KEOP_CHECKED)
                    fputs (" R4KEOP_CHECKED", stdout);
-                 if (option->info & OHWA0_R4KEOP_CLEAN)
+                 if (option.info & OHWA0_R4KEOP_CLEAN)
                    fputs (" R4KEOP_CLEAN", stdout);
                  break;
 
                case ODK_HWOR:
                  fputs (" HWOR      ", stdout);
-                 if (option->info & OHWA0_R4KEOP_CHECKED)
+                 if (option.info & OHWA0_R4KEOP_CHECKED)
                    fputs (" R4KEOP_CHECKED", stdout);
-                 if (option->info & OHWA0_R4KEOP_CLEAN)
+                 if (option.info & OHWA0_R4KEOP_CLEAN)
                    fputs (" R4KEOP_CLEAN", stdout);
                  break;
 
                case ODK_GP_GROUP:
-                 printf (" GP_GROUP  %#06lx  self-contained %#06lx",
-                         option->info & OGP_GROUP,
-                         (option->info & OGP_SELF) >> 16);
+                 printf (" GP_GROUP  %#06x  self-contained %#06x",
+                         option.info & OGP_GROUP,
+                         (option.info & OGP_SELF) >> 16);
                  break;
 
                case ODK_IDENT:
-                 printf (" IDENT     %#06lx  self-contained %#06lx",
-                         option->info & OGP_GROUP,
-                         (option->info & OGP_SELF) >> 16);
+                 printf (" IDENT     %#06x  self-contained %#06x",
+                         option.info & OGP_GROUP,
+                         (option.info & OGP_SELF) >> 16);
                  break;
 
                default:
                  /* This shouldn't happen.  */
-                 printf (" %3d ???     %d %lx",
-                         option->kind, option->section, option->info);
+                 printf (" %3d ???     %" PRId16 " %" PRIx32,
+                         option.kind, option.section, option.info);
                  break;
                }
 
              len = sizeof (* eopt);
-             while (len < option->size)
+             while (len < option.size)
                {
-                 unsigned char datum = * ((unsigned char *) eopt + offset + len);
+                 unsigned char datum = *((unsigned char *) eoption + len);
 
                  if (ISPRINT (datum))
                    printf ("%c", datum);
@@ -17153,10 +17110,8 @@ process_mips_specific (Filedata * filedata)
                }
              fputs ("\n", stdout);
 
-             offset += option->size;
-             ++option;
+             offset += option.size;
            }
-         free (iopt);
          free (eopt);
        }
       else
@@ -17389,8 +17344,7 @@ process_mips_specific (Filedata * filedata)
        }
 
     got_print_fail:
-      if (data)
-       free (data);
+      free (data);
     }
 
   if (mips_pltgot != 0 && jmprel != 0 && pltrel != 0 && pltrelsz != 0)
@@ -17467,8 +17421,7 @@ process_mips_specific (Filedata * filedata)
        }
       printf ("\n");
 
-      if (data)
-       free (data);
+      free (data);
       free (rels);
     }
 
@@ -19740,11 +19693,8 @@ process_notes_at (Filedata *           filedata,
       if (! process_note (& inote, filedata))
        res = FALSE;
 
-      if (temp != NULL)
-       {
-         free (temp);
-         temp = NULL;
-       }
+      free (temp);
+      temp = NULL;
     }
 
   free (pnotes);
@@ -20298,38 +20248,23 @@ process_object (Filedata * filedata)
   filedata->string_table = NULL;
   filedata->string_table_length = 0;
 
-  if (filedata->dump.dump_sects != NULL)
-    {
-      free (filedata->dump.dump_sects);
-      filedata->dump.dump_sects = NULL;
-      filedata->dump.num_dump_sects = 0;
-    }
+  free (filedata->dump.dump_sects);
+  filedata->dump.dump_sects = NULL;
+  filedata->dump.num_dump_sects = 0;
 
-  if (filedata->dynamic_strings)
-    {
-      free (filedata->dynamic_strings);
-      filedata->dynamic_strings = NULL;
-      filedata->dynamic_strings_length = 0;
-    }
+  free (filedata->dynamic_strings);
+  filedata->dynamic_strings = NULL;
+  filedata->dynamic_strings_length = 0;
 
-  if (filedata->dynamic_symbols)
-    {
-      free (filedata->dynamic_symbols);
-      filedata->dynamic_symbols = NULL;
-      filedata->num_dynamic_syms = 0;
-    }
+  free (filedata->dynamic_symbols);
+  filedata->dynamic_symbols = NULL;
+  filedata->num_dynamic_syms = 0;
 
-  if (filedata->dynamic_syminfo)
-    {
-      free (filedata->dynamic_syminfo);
-      filedata->dynamic_syminfo = NULL;
-    }
+  free (filedata->dynamic_syminfo);
+  filedata->dynamic_syminfo = NULL;
 
-  if (filedata->dynamic_section)
-    {
-      free (filedata->dynamic_section);
-      filedata->dynamic_section = NULL;
-    }
+  free (filedata->dynamic_section);
+  filedata->dynamic_section = NULL;
 
   while (filedata->symtab_shndx_list != NULL)
     {
@@ -20338,11 +20273,8 @@ process_object (Filedata * filedata)
       filedata->symtab_shndx_list = next;
     }
 
-  if (filedata->section_headers_groups)
-    {
-      free (filedata->section_headers_groups);
-      filedata->section_headers_groups = NULL;
-    }
+  free (filedata->section_headers_groups);
+  filedata->section_headers_groups = NULL;
 
   if (filedata->section_groups)
     {
@@ -20803,8 +20735,7 @@ main (int argc, char ** argv)
     if (! process_file (argv[optind++]))
       err = TRUE;
 
-  if (cmdline.dump_sects != NULL)
-    free (cmdline.dump_sects);
+  free (cmdline.dump_sects);
 
   free (dump_ctf_symtab_name);
   free (dump_ctf_strtab_name);
This page took 0.03844 seconds and 4 git commands to generate.