This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb] binutils: Fix left shift of negative value.
- From: Andreas Krebbel <krebbel at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 9 Nov 2015 16:14:07 -0000
- Subject: [binutils-gdb] binutils: Fix left shift of negative value.
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c4e0beacd71d4a65cfbe27466ae3d0403c39ead5
commit c4e0beacd71d4a65cfbe27466ae3d0403c39ead5
Author: Dominik Vogt <vogt@linux.vnet.ibm.com>
Date: Mon Nov 9 17:12:56 2015 +0100
binutils: Fix left shift of negative value.
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.
Diff:
---
binutils/ChangeLog | 4 ++++
binutils/dwarf.c | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 8779082..bcbad22 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -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
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index c14049a..9f1baea 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -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;
}