ubsan: spu: left shift of negative value
authorAlan Modra <amodra@gmail.com>
Wed, 8 Jan 2020 20:14:16 +0000 (06:44 +1030)
committerAlan Modra <amodra@gmail.com>
Fri, 10 Jan 2020 07:02:33 +0000 (17:32 +1030)
commit8948cc6971fb82feffc49e2d21747111466ad642
treec71b8b40324ce83b2fb5396f2134f21169da1b21
parent71780f455fbf35ed4c48e94b4228c55c11a213c8
ubsan: spu: left shift of negative value

Also fixes a real bug.  The DECODE_INSN_I9a and DECODE_INSN_I9b both
use UNSIGNED_EXTRACT for 7 low bits of the result, but this was an
unsigned value due to "insn" being unsigned.  DECODE_INSN_I9* is
therefore unsigned too, leading to a zero extension in an expression
using a bfd_vma if bfd_vma is 64 bits.

* opcode/spu.h: Formatting.
(UNSIGNED_EXTRACT): Use 1u.
(SIGNED_EXTRACT): Don't sign extend with shifts.
(DECODE_INSN_I9a, DECODE_INSN_I9b): Avoid left shift of signed value.
Keep result signed.
(DECODE_INSN_U9a, DECODE_INSN_U9b): Delete.
include/ChangeLog
include/opcode/spu.h