[PATCH] gas: fix overflow diagnostics

Jan Beulich jbeulich@suse.com
Tue Jun 15 07:33:18 GMT 2021


On 15.06.2021 09:03, Alan Modra wrote:
> On Tue, Jun 15, 2021 at 08:10:50AM +0200, Jan Beulich via Binutils wrote:
>> 	* read.c (emit_expr_with_reloc): Adjust overflow check. Drop
>> 	hibit local variable.
>> 	* write.c (fixup_segment): Differentiate signed and non-signed
>> 	relocs in overflow check.
>> 	* testsuite/gas/all/overflow.s,
>> 	testsuite/gas/all/overflow.l: New.
>> 	* testsuite/gas/all/gas.exp: Run new test.
> 
> OK, but
> 
>>        /* JF << of >= number of bits in the object is undefined.  In
>>  	 particular SPARC (Sun 4) has problems.  */
>>        if (nbytes >= sizeof (valueT))
>>  	{
>> +	  know (nbytes == sizeof (valueT));
> 
> I question the need for this assertion.  It seems to me that nothing
> goes wrong here if nbytes is larger, so what assumption is it
> protecting?

Well, I put it there to document the state at this point. If the hibit
calculation was still present (or something similar be added down the
road), it makes clear that the nbytes > sizeof() doesn't need handling
here.

I can drop it if you'd prefer it that way. I did add it because I was
expecting the question to come the other way around if it hadn't been
put there.

Jan



More information about the Binutils mailing list