ubsan: xstormy16: left shift of negative value

Alan Modra amodra@gmail.com
Mon Dec 16 07:09:00 GMT 2019


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



More information about the Binutils mailing list