ubsan: xtensa: left shift cannot be represented in type 'int'
authorAlan Modra <amodra@gmail.com>
Tue, 10 Dec 2019 07:42:28 +0000 (18:12 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 11 Dec 2019 01:05:14 +0000 (11:35 +1030)
commit567607c11fbf710513d0924192f3ed528c02d76f
tree969ff4eb4e3469519fd3926368b158c38cdb45e2
parentb8e61daa1ad56330fd8931c8a53bfa16d8e4a47a
ubsan: xtensa: left shift cannot be represented in type 'int'

In Operand_soffsetx4_decode:
  soffsetx4_0 = 0x4 + ((((int) offset_0 << 14) >> 14) << 2);
and other places.

Don't sign extend with shifts!  This file also has many occurrences of
truncation via shifts, which aren't a problem due to using uint32, but
I dislike on principle enough to fix.

* xtensa-modules.c (Field_* functions): Don't mask using shifts.
(Operand_soffsetx4_decode, Operand_simm4_decode),
(Operand_simm8_decode, Operand_simm8x256_decode),
(Operand_simm12b_decode, Operand_label8_decode),
(Operand_label12_decode, Operand_soffset_decode),
(Operand_xt_wbr15_label_decode, Operand_xt_wbr18_label_decode): Don't
sign extend using shifts.
(Operand_immrx4_decode, Operand_uimm16x4_decode): Avoid UB in
constant.
bfd/ChangeLog
bfd/xtensa-modules.c