From: Alan Modra Date: Thu, 27 Aug 2020 04:16:45 +0000 (+0930) Subject: PR26467 UBSAN: cgen.c:762 shift exponent 18446744073709551615 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6fbd4a8e8baa7fe5adcaa1c11c885f741fccd250;p=binutils-gdb.git PR26467 UBSAN: cgen.c:762 shift exponent 18446744073709551615 PR 26467 * cgen.c (weak_operand_overflow_check): Handle opmask for operand length zero. Use 1UL constant. --- diff --git a/gas/ChangeLog b/gas/ChangeLog index c0d9b26a29c..92dd9784d2a 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,9 @@ +2020-08-27 Alan Modra + + PR 26467 + * cgen.c (weak_operand_overflow_check): Handle opmask for + operand length zero. Use 1UL constant. + 2020-08-26 Alan Modra PR 26508 diff --git a/gas/cgen.c b/gas/cgen.c index 0bc44f6c08c..7c924d117be 100644 --- a/gas/cgen.c +++ b/gas/cgen.c @@ -759,7 +759,7 @@ weak_operand_overflow_check (const expressionS * exp, { const unsigned long len = operand->length; unsigned long mask; - unsigned long opmask = (((1L << (len - 1)) - 1) << 1) | 1; + unsigned long opmask = len == 0 ? 0 : (1UL << (len - 1) << 1) - 1; if (!exp) return NULL;