This is the mail archive of the binutils@sourceware.org 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][Binutils][Arm] gas: fix out of range conditional branch (PR/24991)


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




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