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


Ian Lance Taylor <ian@wasabisystems.com> writes:

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

Specifically, see this comment in expr.c:

	    if (c == '-')
	      {
		expressionP->X_add_number = - expressionP->X_add_number;
		/* Notice: '-' may overflow: no warning is given.
		   This is compatible with other people's
		   assemblers.  Sigh.  */
		expressionP->X_unsigned = 0;

I don't see any particularly obvious to fix this problem.  One fix
would seem to be to change expr() to pass in the size of the desired
result.  Then use that when doing arithmetic.  In other words, handle
these differently within expr() and operand():
  .8byte -3378511873
  .4byte -3378511873

Another fix might be to not resolve constant expressions as we go, and
instead resolve them using the desired size, although that would tend
to slow down the assembler.

Neither of these sound quite right, somehow.

Ian


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