]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
MIPS/readelf: Simplify GOT[1] data availability check
authorMaciej W. Rozycki <macro@imgtec.com>
Tue, 11 Apr 2017 23:03:41 +0000 (00:03 +0100)
committerMaciej W. Rozycki <macro@imgtec.com>
Tue, 25 Apr 2017 20:11:49 +0000 (21:11 +0100)
Unavailable data is handled gracefully in MIPS GOT processing done by
`print_mips_got_entry', so all that is needed in special GOT[1] handling
is to verify whether data can be retrieved for the purpose of the GNU
marker check done with `byte_get'.  Remove the extra error reporting
code then, introduced with commit 75ec1fdbb797 ("Fix runtime seg-fault
in readelf when parsing a corrupt MIPS binary.") in the course of
addressing PR binutils/21344, and defer the error case to regular local
GOT entry processing.

binutils/
* readelf.c (process_mips_specific): Remove error reporting from
GOT[1] processing.

binutils/ChangeLog
binutils/readelf.c

index 0b6a71268f0280b93dffa1bf2509a67049995da8..7f8e29d9eeb031a8057a1b524546358c088b2a43 100644 (file)
@@ -1,3 +1,8 @@
+2017-04-25  Maciej W. Rozycki  <macro@imgtec.com>
+
+       * readelf.c (process_mips_specific): Remove error reporting from
+       GOT[1] processing.
+
 2017-04-25  Maciej W. Rozycki  <macro@imgtec.com>
 
        * readelf.c (process_mips_specific): Remove null GOT data check.
index d4c4137d3daa233a8517785c6abe6a9843749bd6..1139f710becc2aaca216c464a3525e2e7b0896f9 100644 (file)
@@ -15500,24 +15500,20 @@ process_mips_specific (FILE * file)
       if (ent == (bfd_vma) -1)
        goto got_print_fail;
 
-      if (data)
-       {
-         /* PR 21344 */
-         if (data + ent - pltgot > data_end - addr_size)
-           {
-             error (_("Invalid got entry - %#lx - overflows GOT table\n"),
-                    (long) ent);
-             goto got_print_fail;
-           }
-         
-         if (byte_get (data + ent - pltgot, addr_size)
-             >> (addr_size * 8 - 1) != 0)
-           {
-             ent = print_mips_got_entry (data, pltgot, ent, data_end);
-             printf (_(" Module pointer (GNU extension)\n"));
-             if (ent == (bfd_vma) -1)
-               goto got_print_fail;
-           }
+      /* Check for the MSB of GOT[1] being set, denoting a GNU object.
+        This entry will be used by some runtime loaders, to store the
+        module pointer.  Otherwise this is an ordinary local entry.
+        PR 21344: Check for the entry being fully available before
+        fetching it.  */
+      if (data
+         && data + ent - pltgot + addr_size <= data_end
+         && (byte_get (data + ent - pltgot, addr_size)
+             >> (addr_size * 8 - 1)) != 0)
+       {
+         ent = print_mips_got_entry (data, pltgot, ent, data_end);
+         printf (_(" Module pointer (GNU extension)\n"));
+         if (ent == (bfd_vma) -1)
+           goto got_print_fail;
        }
       printf ("\n");