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

Re: PATCH: Fix sign-extension of bignums


Mark Mitchell <mark@codesourcery.com> writes:

> Here's a patch for another problem with bignums.
> 
> On this input:
> 
> 	.8byte	-3378511873
> 
> which is a value that fits in 32 bits when treated as unsigned, and
> therefore makes it to emit_expr as an O_constant, we failed to
> sign-extend the value on output.  It looks like we were trying to do
> that, but the test "exp->X_add_number < 0" makes no sense; that value
> should always be tested with "> 0" or "<= 0", and, furthermore, the "<
> 0" case would be for floating-point nubmers, which is not this case.

This patch makes no sense.  The value at this point is O_constant, not
O_bignum.  Try using this patch with ".8byte 1".

The real problem is that we've already applied the negation, and the
result has overflowed so that it appears to be a positive number.

Ian

> 2004-08-10  Mark Mitchell  <mark@codesourcery.com>
> 
> 	* read.c (emit_expr): Sign-extend bignums.
> 
> Index: read.c
> ===================================================================
> RCS file: /cvs/src/src/gas/read.c,v
> retrieving revision 1.78
> diff -c -5 -p -r1.78 read.c
> *** read.c	19 Apr 2004 09:32:55 -0000	1.78
> --- read.c	11 Aug 2004 02:24:11 -0000
> *************** emit_expr (expressionS *exp, unsigned in
> *** 3486,3496 ****
>     if (op == O_constant && nbytes > sizeof (valueT))
>       {
>         valueT val;
>         int gencnt;
>   
> !       if (!exp->X_unsigned && exp->X_add_number < 0)
>   	extra_digit = (valueT) -1;
>         val = (valueT) exp->X_add_number;
>         gencnt = 0;
>         do
>   	{
> --- 3486,3496 ----
>     if (op == O_constant && nbytes > sizeof (valueT))
>       {
>         valueT val;
>         int gencnt;
>   
> !       if (!exp->X_unsigned && exp->X_add_number > 0)
>   	extra_digit = (valueT) -1;
>         val = (valueT) exp->X_add_number;
>         gencnt = 0;
>         do
>   	{


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