From: Alan Modra Date: Thu, 26 Jan 2023 08:14:51 +0000 (+1030) Subject: resolve gas shift expressions with large exponents to zero X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=44a178cc69a05d03bcde37a4f46e4e8e81287b84;p=binutils-gdb.git resolve gas shift expressions with large exponents to zero * expr.c (resolve_expression ): Resolve shifts exceeding bits in a valueT to zero. --- diff --git a/gas/expr.c b/gas/expr.c index ba3d2109b9d..794be6f09d8 100644 --- a/gas/expr.c +++ b/gas/expr.c @@ -2320,8 +2320,18 @@ resolve_expression (expressionS *expressionP) return 0; left = (offsetT) left % (offsetT) right; break; - case O_left_shift: left <<= right; break; - case O_right_shift: left >>= right; break; + case O_left_shift: + if (right >= sizeof (left) * CHAR_BIT) + left = 0; + else + left <<= right; + break; + case O_right_shift: + if (right >= sizeof (left) * CHAR_BIT) + left = 0; + else + left >>= right; + break; case O_bit_inclusive_or: left |= right; break; case O_bit_or_not: left |= ~right; break; case O_bit_exclusive_or: left ^= right; break;