This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb] gas: microblaze: fix shift overflow
- From: Michael Frysinger <vapier at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 17 Nov 2015 04:21:56 -0000
- Subject: [binutils-gdb] gas: microblaze: fix shift overflow
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=58a345fe1f0407cb2743da0b295ef28cc7f23c72
commit 58a345fe1f0407cb2743da0b295ef28cc7f23c72
Author: Mike Frysinger <vapier@gentoo.org>
Date: Sun Nov 15 02:46:03 2015 -0500
gas: microblaze: fix shift overflow
This code tries to shift an integer 31 bits which triggers a werror:
gas/config/tc-microblaze.c:742:21: error: integer overflow in expression [-Werror=overflow]
e->X_add_number |= -(1 << 31);
Cast the 1 to offsetT to match X_add_number to fix things.
Diff:
---
gas/ChangeLog | 4 ++++
gas/config/tc-microblaze.c | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 955fd2e..41e44b5 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,7 @@
+2015-11-16 Mike Frysinger <vapier@gentoo.org>
+
+ * config/tc-microblaze.c (parse_imm): Add an offsetT cast.
+
2015-11-13 Tristan Gingold <gingold@adacore.com>
* configure: Regenerate.
diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
index ac7c828..0ec24f8 100644
--- a/gas/config/tc-microblaze.c
+++ b/gas/config/tc-microblaze.c
@@ -739,7 +739,7 @@ parse_imm (char * s, expressionS * e, offsetT min, offsetT max)
{
/* Special case: sign extend negative 32-bit values to 64-bits. */
if ((e->X_add_number >> 31) == 1)
- e->X_add_number |= -(1 << 31);
+ e->X_add_number |= -((offsetT) 1 << 31);
if (e->X_add_number < min || e->X_add_number > max)
{