This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Second fix for microblaze gas port's ability to parse constants.


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f66adc4eada1884cef90aa978561b9b2008cdaf2

commit f66adc4eada1884cef90aa978561b9b2008cdaf2
Author: Nick Clifton <nickc@redhat.com>
Date:   Thu Apr 2 17:13:12 2015 +0100

    Second fix for microblaze gas port's ability to parse constants.
    
    	PR gas/18189
    	* config/tc-microblaze.c (parse_imm): Use offsetT as the type for
    	min and max parameters.  Sign extend values before testing.

Diff:
---
 gas/ChangeLog              |  2 +-
 gas/config/tc-microblaze.c | 14 ++++++++++----
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/gas/ChangeLog b/gas/ChangeLog
index e08b0f7..a2383a9 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -2,7 +2,7 @@
 
 	PR gas/18189
 	* config/tc-microblaze.c (parse_imm): Use offsetT as the type for
-	min and max parameters.
+	min and max parameters.  Sign extend values before testing.
 
 2015-04-02  Renlin Li  <renlin.li@arm.com>
 
diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
index 6f0e795..3309e59 100644
--- a/gas/config/tc-microblaze.c
+++ b/gas/config/tc-microblaze.c
@@ -736,11 +736,17 @@ parse_imm (char * s, expressionS * e, offsetT min, offsetT max)
     ; /* An error message has already been emitted.  */
   else if ((e->X_op != O_constant && e->X_op != O_symbol) )
     as_fatal (_("operand must be a constant or a label"));
-  else if ((e->X_op == O_constant) && (e->X_add_number < min
-				       || e->X_add_number > max))
+  else if (e->X_op == O_constant)
     {
-      as_fatal (_("operand must be absolute in range %lx..%lx, not %lx"),
-                (long) min, (long) max, (long) e->X_add_number);
+      /* Special case: sign extend negative 32-bit values to 64-bits.  */
+      if ((e->X_add_number >> 31) == 1)
+	e->X_add_number |= (-1 << 31);
+
+      if (e->X_add_number < min || e->X_add_number > max)
+	{
+	  as_fatal (_("operand must be absolute in range %lx..%lx, not %lx"),
+		    (long) min, (long) max, (long) e->X_add_number);
+	}
     }
 
   if (atp)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]