Yaakov Selkowitz: fixes for in-tree libiconv
[deliverable/binutils-gdb.git] / binutils / readelf.c
index a0c20a386125dd7f192f1a9412b671c06a46bafb..6298f1e29d8a298010078a7d1b23a9a0a5fa1519 100644 (file)
@@ -1608,12 +1608,9 @@ dump_relocations (FILE * file,
 
              if (is_rela)
                {
-                 bfd_signed_vma off = rels[i].r_addend;
+                 bfd_vma off = rels[i].r_addend;
 
-                 /* PR 17531: file: 2e63226f.  */
-                 if (off == ((bfd_signed_vma) 1) << ((sizeof (bfd_signed_vma) * 8) - 1))
-                   printf (" + %" BFD_VMA_FMT "x", off);
-                 else if (off < 0)
+                 if ((bfd_signed_vma) off < 0)
                    printf (" - %" BFD_VMA_FMT "x", - off);
                  else
                    printf (" + %" BFD_VMA_FMT "x", off);
@@ -1622,13 +1619,10 @@ dump_relocations (FILE * file,
        }
       else if (is_rela)
        {
-         bfd_signed_vma off = rels[i].r_addend;
+         bfd_vma off = rels[i].r_addend;
 
          printf ("%*c", is_32bit_elf ? 12 : 20, ' ');
-         /* PR 17531: file: 2e63226f.  */
-         if (off == ((bfd_signed_vma) 1) << ((sizeof (bfd_signed_vma) * 8) - 1))
-           printf ("%" BFD_VMA_FMT "x", off);
-         else if (off < 0)
+         if ((bfd_signed_vma) off < 0)
            printf ("-%" BFD_VMA_FMT "x", - off);
          else
            printf ("%" BFD_VMA_FMT "x", off);
@@ -1695,6 +1689,7 @@ get_mips_dynamic_type (unsigned long type)
     case DT_MIPS_GOTSYM: return "MIPS_GOTSYM";
     case DT_MIPS_HIPAGENO: return "MIPS_HIPAGENO";
     case DT_MIPS_RLD_MAP: return "MIPS_RLD_MAP";
+    case DT_MIPS_RLD_MAP_REL: return "MIPS_RLD_MAP_REL";
     case DT_MIPS_DELTA_CLASS: return "MIPS_DELTA_CLASS";
     case DT_MIPS_DELTA_CLASS_NO: return "MIPS_DELTA_CLASS_NO";
     case DT_MIPS_DELTA_INSTANCE: return "MIPS_DELTA_INSTANCE";
@@ -8682,7 +8677,7 @@ get_32bit_dynamic_section (FILE * file)
      might not have the luxury of section headers.  Look for the DT_NULL
      terminator to determine the number of entries.  */
   for (ext = edyn, dynamic_nent = 0;
-       (char *) ext < (char *) edyn + dynamic_size - sizeof (* entry);
+       (char *) (ext + 1) <= (char *) edyn + dynamic_size;
        ext++)
     {
       dynamic_nent++;
@@ -8730,8 +8725,8 @@ get_64bit_dynamic_section (FILE * file)
      might not have the luxury of section headers.  Look for the DT_NULL
      terminator to determine the number of entries.  */
   for (ext = edyn, dynamic_nent = 0;
-       /* PR 17533 file: 033-67080-0.004 - do not read off the end of the buffer.  */
-       (char *) ext < ((char *) edyn) + dynamic_size - sizeof (* ext);
+       /* PR 17533 file: 033-67080-0.004 - do not read past end of buffer.  */
+       (char *) (ext + 1) <= (char *) edyn + dynamic_size;
        ext++)
     {
       dynamic_nent++;
@@ -12029,13 +12024,21 @@ dump_section_as_strings (Elf_Internal_Shdr * section, FILE * file)
          unsigned int compression_header_size
            = get_compression_header (& chdr, (unsigned char *) start);
 
-         if (chdr.ch_type == ELFCOMPRESS_ZLIB
-             && chdr.ch_addralign == section->sh_addralign)
+         if (chdr.ch_type != ELFCOMPRESS_ZLIB)
+           {
+             warn (_("section '%s' has unsupported compress type: %d\n"),
+                   printable_section_name (section), chdr.ch_type);
+             return;
+           }
+         else if (chdr.ch_addralign != section->sh_addralign)
            {
-             uncompressed_size = chdr.ch_size;
-             start += compression_header_size;
-             new_size -= compression_header_size;
+             warn (_("compressed section '%s' is corrupted\n"),
+                   printable_section_name (section));
+             return;
            }
+         uncompressed_size = chdr.ch_size;
+         start += compression_header_size;
+         new_size -= compression_header_size;
        }
       else if (new_size > 12 && streq ((char *) start, "ZLIB"))
        {
@@ -12155,13 +12158,21 @@ dump_section_as_bytes (Elf_Internal_Shdr * section,
          unsigned int compression_header_size
            = get_compression_header (& chdr, start);
 
-         if (chdr.ch_type == ELFCOMPRESS_ZLIB
-             && chdr.ch_addralign == section->sh_addralign)
+         if (chdr.ch_type != ELFCOMPRESS_ZLIB)
+           {
+             warn (_("section '%s' has unsupported compress type: %d\n"),
+                   printable_section_name (section), chdr.ch_type);
+             return;
+           }
+         else if (chdr.ch_addralign != section->sh_addralign)
            {
-             uncompressed_size = chdr.ch_size;
-             start += compression_header_size;
-             new_size -= compression_header_size;
+             warn (_("compressed section '%s' is corrupted\n"),
+                   printable_section_name (section));
+             return;
            }
+         uncompressed_size = chdr.ch_size;
+         start += compression_header_size;
+         new_size -= compression_header_size;
        }
       else if (new_size > 12 && streq ((char *) start, "ZLIB"))
        {
@@ -12289,9 +12300,18 @@ load_specific_debug_section (enum dwarf_section_display_enum debug,
          Elf_Internal_Chdr chdr;
          unsigned int compression_header_size
            = get_compression_header (&chdr, start);
-         if (chdr.ch_type != ELFCOMPRESS_ZLIB
-             || chdr.ch_addralign != sec->sh_addralign)
-           return 0;
+         if (chdr.ch_type != ELFCOMPRESS_ZLIB)
+           {
+             warn (_("section '%s' has unsupported compress type: %d\n"),
+                   section->name, chdr.ch_type);
+             return 0;
+           }
+         else if (chdr.ch_addralign != sec->sh_addralign)
+           {
+             warn (_("compressed section '%s' is corrupted\n"),
+                   section->name);
+             return 0;
+           }
          uncompressed_size = chdr.ch_size;
          start += compression_header_size;
          size -= compression_header_size;
@@ -13196,6 +13216,9 @@ print_mips_fp_abi_value (int val)
     case Val_GNU_MIPS_ABI_FP_64A:
       printf (_("Hard float compat (32-bit CPU, 64-bit FPU)\n"));
       break;
+    case Val_GNU_MIPS_ABI_FP_NAN2008:
+      printf (_("NaN 2008 compatibility\n"));
+      break;
     default:
       printf ("??? (%d)\n", val);
       break;
@@ -14444,7 +14467,7 @@ process_mips_specific (FILE * file)
              len = sizeof (* eopt);
              while (len < option->size)
                {
-                 char datum = * ((char *) eopt + offset + len);
+                 unsigned char datum = * ((unsigned char *) eopt + offset + len);
 
                  if (ISPRINT (datum))
                    printf ("%c", datum);
This page took 0.029779 seconds and 4 git commands to generate.