ubsan: undefined shift in frag_align_code
authorAlan Modra <amodra@gmail.com>
Thu, 2 Jun 2022 06:40:30 +0000 (16:10 +0930)
committerAlan Modra <amodra@gmail.com>
Thu, 2 Jun 2022 06:40:30 +0000 (16:10 +0930)
* frags.c (MAX_MEM_FOR_RS_ALIGN_CODE): Avoid signed integer
overflow.

gas/frags.c

index f5afe1a49b5e536b7702d719cc369d6ee91679bc..8e88496f37c352d1b0f3648f77f92b5e50def8b3 100644 (file)
@@ -367,7 +367,7 @@ frag_align_pattern (int alignment, const char *fill_pattern,
 # ifndef HANDLE_ALIGN
 #  define MAX_MEM_FOR_RS_ALIGN_CODE  1
 # else
-#  define MAX_MEM_FOR_RS_ALIGN_CODE  ((1 << alignment) - 1)
+#  define MAX_MEM_FOR_RS_ALIGN_CODE  (((size_t) 1 << alignment) - 1)
 # endif
 #endif