[binutils-gdb] Re: ubsan: undefined shift in frag_align_code

Alan Modra amodra@sourceware.org
Fri Jun 3 14:02:58 GMT 2022


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7e6ba6a2a56e6195da36329bdeb1654e20aad198

commit 7e6ba6a2a56e6195da36329bdeb1654e20aad198
Author: Alan Modra <amodra@gmail.com>
Date:   Fri Jun 3 22:40:21 2022 +0930

    Re: ubsan: undefined shift in frag_align_code
    
    This one needs the same fix too.
    
            * config/tc-i386.h (MAX_MEM_FOR_RS_ALIGN_CODE): Avoid signed
            integer overflow.

Diff:
---
 gas/config/tc-i386.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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)


More information about the Binutils-cvs mailing list