[PATCH][Binutils][Arm] gas: fix out of range conditional branch (PR/24991)
Nick Clifton
nickc@redhat.com
Mon Sep 23 10:06:00 GMT 2019
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
More information about the Binutils
mailing list