]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
binutils: Fix left shift of negative value.
authorDominik Vogt <vogt@linux.vnet.ibm.com>
Mon, 9 Nov 2015 16:12:56 +0000 (17:12 +0100)
committerAndreas Krebbel <krebbel@linux.vnet.ibm.com>
Mon, 9 Nov 2015 16:12:56 +0000 (17:12 +0100)
This patch fixes all occurences of left-shifting negative constants in C code
which is undefined by the C standard.

binutils/ChangeLog:

        * dwarf.c (read_leb128): Fix left shift of negative value.

binutils/ChangeLog
binutils/dwarf.c

index 8779082c6496e244233dd43594cb4c1f5c3ab43f..bcbad22fdf37ee1db38085bc289b3778527242fd 100644 (file)
@@ -1,3 +1,7 @@
+2015-11-09  Dominik Vogt  <vogt@linux.vnet.ibm.com>
+
+       * dwarf.c (read_leb128): Fix left shift of negative value.
+
 2015-11-03  Alan Modra  <amodra@gmail.com>
 
        * readelf (process_version_sections): Check DT_VERNEED and
index c14049ac8d2aafa9c7fcbd247b0460ede6d6f79e..9f1baea831227940575eb286f8a3c7f3466e0ca5 100644 (file)
@@ -292,7 +292,7 @@ read_leb128 (unsigned char *data,
     *length_return = num_read;
 
   if (sign && (shift < 8 * sizeof (result)) && (byte & 0x40))
-    result |= (dwarf_vma) -1 << shift;
+    result |= -((dwarf_vma) 1 << shift);
 
   return result;
 }