ubsan: undefined shift in frag_align_code

Alan Modra amodra@gmail.com
Fri Jun 3 13:23:24 GMT 2022


This one needs the same fix too.

	* config/tc-i386.h (MAX_MEM_FOR_RS_ALIGN_CODE): Avoid signed
	integer overflow.

diff --git a/gas/config/tc-i386.h b/gas/config/tc-i386.h
index d7c6b33c778..817539ea560 100644
--- a/gas/config/tc-i386.h
+++ b/gas/config/tc-i386.h
@@ -207,7 +207,8 @@ if ((n)									\
     goto around;							\
   }
 
-#define MAX_MEM_FOR_RS_ALIGN_CODE  (alignment ? ((1 << alignment) - 1) : 1)
+#define MAX_MEM_FOR_RS_ALIGN_CODE \
+  (alignment ? ((size_t) 1 << alignment) - 1 : (size_t) 1)
 
 extern void i386_cons_align (int);
 #define md_cons_align(nbytes) i386_cons_align (nbytes)

-- 
Alan Modra
Australia Development Lab, IBM


More information about the Binutils mailing list