Re: ubsan: undefined shift in frag_align_code
authorAlan Modra <amodra@gmail.com>
Fri, 3 Jun 2022 13:10:21 +0000 (22:40 +0930)
committerAlan Modra <amodra@gmail.com>
Fri, 3 Jun 2022 14:02:39 +0000 (23:32 +0930)
This one needs the same fix too.

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

gas/config/tc-i386.h

index d7c6b33c778e639384f3389c0790f135becaa089..817539ea560fcbf50cdba2ecea371707e1ed7401 100644 (file)
@@ -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)