Overflow fix (was Problems with trampoline.S with 64 bit binutils)

Alan Modra alan@SPRI.Levels.UniSA.Edu.Au
Wed Jul 28 02:09:00 GMT 1999


Is it OK for me to check this one in, Ian?  It's almost in the "obvious
fix" category...

On Tue, 27 Jul 1999, I wrote:

> This is more elegant, and the concern voiced in the comment is no longer
> relevant as we check for size < sizof(valueT)
> 
> --- binutils-current/gas/write.c~	Fri Jul 16 17:57:19 1999
> +++ binutils-current/gas/write.c	Tue Jul 27 20:32:04 1999
> @@ -2733,24 +2733,13 @@
>  	{
>  	  if ((size_t) size < sizeof (valueT))
>  	    {
> -	      valueT mask, hibit;
> +	      valueT mask;
>  
> -	      /* set all bits to one */
>  	      mask = 0;
> -	      mask--;
> -	      /* Technically, combining these produces an undefined result
> -		 if size is sizeof (valueT), though I think these two
> -		 half-way operations should both be defined.  And the
> -		 compiler should be able to combine them if it's valid on
> -		 the host architecture.  */
> -	      mask <<= size * 4;
> -	      mask <<= size * 4;
> -	      hibit = (valueT) 1 << (size * 8 - 1);
> -	      if (((add_number & mask) != 0
> -		   || (fixP->fx_signed
> -		       && (add_number & hibit) != 0))
> -		  && ((add_number & mask) != mask
> -		      || (add_number & hibit) == 0))
> +	      mask--;	      /* set all bits to one */
> +	      mask <<= size * 8 - (fixP->fx_signed ? 1 : 0);
> +	      if ((add_number & mask) != 0
> +		  && (add_number & mask) != mask)
>  		{
>  		  char buf[50], buf2[50];
>  		  sprint_value (buf, fragP->fr_address + where);





More information about the Binutils mailing list