gas: avoid UB on signed multiplication in resolve_symbol_value()
Checks
| Context |
Check |
Description |
| linaro-tcwg-bot/tcwg_binutils_build--master-arm |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 |
success
|
Test passed
|
| linaro-tcwg-bot/tcwg_binutils_check--master-arm |
success
|
Test passed
|
Commit Message
Commit 487b0ff02dda ("ubsan: signed integer multiply overflow") touched
only one of the two affected places (the 3rd, resolve_expression(), is
already using valueT type local variables).
---
Of course it's quite bad that we have three places evaluating
expressions, all doing things a little differently. Question is whether
unifying things is (a) practical and (b) not going to cause regressions.
@@ -1721,7 +1721,8 @@ resolve_symbol_value (symbolS *symp)
switch (symp->x->value.X_op)
{
- case O_multiply: left *= right; break;
+ /* See expr() for reasons of the use of valueT casts here. */
+ case O_multiply: left *= (valueT) right; break;
case O_divide: left /= right; break;
case O_modulus: left %= right; break;
case O_left_shift: