aboutsummaryrefslogtreecommitdiff
path: root/gas/expr.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2023-01-26 18:44:51 +1030
committerAlan Modra <amodra@gmail.com>2023-01-27 08:18:46 +1030
commit44a178cc69a05d03bcde37a4f46e4e8e81287b84 (patch)
treec90ffb0fc95dc31f51cf42c4b07965e23bfac026 /gas/expr.c
parentc37de2981558eb7ba4aa473ab214d8f2fb0c9876 (diff)
downloadgdb-44a178cc69a05d03bcde37a4f46e4e8e81287b84.zip
gdb-44a178cc69a05d03bcde37a4f46e4e8e81287b84.tar.gz
gdb-44a178cc69a05d03bcde37a4f46e4e8e81287b84.tar.bz2
resolve gas shift expressions with large exponents to zero
* expr.c (resolve_expression <O_left_shift, O_right_shift>): Resolve shifts exceeding bits in a valueT to zero.
Diffstat (limited to 'gas/expr.c')
-rw-r--r--gas/expr.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/gas/expr.c b/gas/expr.c
index ba3d210..794be6f 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;