This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
ubsan: xstormy16: left shift of negative value
- From: Alan Modra <amodra at gmail dot com>
- To: binutils at sourceware dot org
- Date: Mon, 16 Dec 2019 17:38:54 +1030
- Subject: ubsan: xstormy16: left shift of negative value
I suspect problems with cgen ports would be better addressed by making
cgen itself a little more clever. Fixing the cpu files like this will
probably be an unending task.
cpu/
* xstormy16.cpu (f-rel12a): Avoid signed overflow.
opcodes/
* xstormy16-ibld.c: Regenerate.
diff --git a/cpu/xstormy16.cpu b/cpu/xstormy16.cpu
index ae7e042c92..aa5a464fa6 100644
--- a/cpu/xstormy16.cpu
+++ b/cpu/xstormy16.cpu
@@ -393,7 +393,7 @@
(length 11)
(mode INT)
(encode (value pc) (sra SI (sub SI value (add SI pc 2)) 1))
- (decode (value pc) (add SI (sll value 1) (add SI pc 2)))
+ (decode (value pc) (add SI (mul value 2) (add SI pc 2)))
)
(dnop rel12a "12 bit relative address" () h-uint f-rel12a)
--
Alan Modra
Australia Development Lab, IBM