ubsan: integer overflow in tc-i386.c:offset_in_range

Alan Modra amodra@gmail.com
Wed May 21 21:54:17 GMT 2025
or $9223372036854775808,%eax
runtime error: negation of -9223372036854775808 cannot be represented
in type 'offsetT' (aka 'long'); cast to an unsigned type to negate
this value to itself

Nothing in this function needs a signed type, despite the value under
test being signed.

	* config/tc-i386.c (offset_in_range): Make "val" unsigned.

diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index 162e28e0325..e1f30d4b133 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -2975,7 +2975,7 @@ smallest_imm_type (offsetT num)
 }
 
 static offsetT
-offset_in_range (offsetT val, int size)
+offset_in_range (addressT val, int size)
 {
   addressT mask;
 

-- 
Alan Modra


More information about the Binutils mailing list