Commit: Microblaze: sign extend immediates before checking

Michael Eager eager@eagerm.com
Thu Apr 2 17:53:00 GMT 2015


On 04/02/15 09:13, Nick Clifton wrote:
> 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)

OK.


-- 
Michael Eager	 eager@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077



More information about the Binutils mailing list