[PATCH][Binutils][Arm] gas: fix out of range conditional branch (PR/24991)

Tamar Christina Tamar.Christina@arm.com
Tue Sep 24 10:17:00 GMT 2019


Hi Nick,

Attached is updated patch which should address your and Andreas Comments.


2019-09-24  Tamar Christina  <tamar.christina@arm.com>

	PR gas/24991
	* config/tc-arm.c (out_of_range_p): New.
	(md_apply_fix): Use it in BFD_RELOC_THUMB_PCREL_BRANCH9,
	BFD_RELOC_THUMB_PCREL_BRANCH12, BFD_RELOC_THUMB_PCREL_BRANCH20,
	BFD_RELOC_THUMB_PCREL_BRANCH23, BFD_RELOC_THUMB_PCREL_BRANCH25
	* testsuite/gas/arm/pr24991.d: New test.
	* testsuite/gas/arm/pr24991.l: New test.
	* testsuite/gas/arm/pr24991.s: New test.

Ok for master?

Thanks,
Tamar

The 09/23/2019 11:06, Nick Clifton wrote:
> Hi Tamar,
> 
>   Being paranoid here....
> 
> > +/* Perform range checks on positive and negative overflows by checking if the
> > +   VALUE given fits within the range of an BITS sized immediate.  */
> > +static bfd_boolean out_of_range_p (offsetT value, bfd_vma bits)
> > +{
> > +  return (value & ~((1 << bits)-1))
> > +         && ((value & ~((1 << bits)-1)) != ~((1 << bits)-1));
> > +}
> 
> If bits is a large number then these shifts could overflow.  I would
> recommend adding a range check first.  Plus you should allow for the
> fact that sizeof (bits) and sizeof (value) could be small if the code
> is compiled for a 32-bit host...
> 
> Cheers
>   Nick
> 
> 
> 

-- 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rb11848.patch
Type: text/x-diff
Size: 4025 bytes
Desc: rb11848.patch
URL: <https://sourceware.org/pipermail/binutils/attachments/20190924/146a4822/attachment.bin>


More information about the Binutils mailing list