This is the mail archive of the binutils@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]

Commit: Microblaze: sign extend immediates before checking


Hi Guys,

  My fix for PR 18189 has had an unintended consequence.  Parsing a
  constant such as 0xffffffff fails because it is not sign extended to
  64-bits before it is checked.  So I am checking in the patch below to
  address this issue.

Cheers
  Nick

gas/ChangeLog
2015-04-02  Nick Clifton  <nickc@redhat.com>

	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 --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]