diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2020-10-15 11:00:56 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2020-10-19 09:58:30 +0200 |
commit | b5260d5134fd57b0b07edf2605b33047dc1406e0 (patch) | |
tree | 86f63094a380755d5a847cba241447875ec36c34 | |
parent | ceb5431a2feccc0bbe7e650c90946056513cba88 (diff) | |
download | barebox-b5260d5134fd57b0b07edf2605b33047dc1406e0.tar.gz barebox-b5260d5134fd57b0b07edf2605b33047dc1406e0.tar.xz |
Revert "common: ubsan: ignore shifting one into sign bit"
With the previous commit, we now explicitly tell GCC not to optimize
constructs like (1 << 31) under assumption that they are undefined
anyway. GCC >= 8.0 -fsanitize=undefined should now not warn any longer
about (1 << 31) instances, so remove our work around.
This reverts commit 55397b9ebe3a21a3aeb6a98131c0991bff0f7123.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | lib/ubsan.c | 20 |
1 files changed, 0 insertions, 20 deletions
diff --git a/lib/ubsan.c b/lib/ubsan.c index 085d470cf7..648c7cc48a 100644 --- a/lib/ubsan.c +++ b/lib/ubsan.c @@ -382,26 +382,6 @@ void __ubsan_handle_shift_out_of_bounds(struct shift_out_of_bounds_data *data, if (suppress_report(&data->location)) return; - /* This handler would be called for code shifting a one into the - * sign bit like (1 << 31), which is all too common in barebox. - * It's technically UB, but it's so prevalent that it's highly - * unlikely to be treated by a compiler as anything else than the - * standard-compliant (1U << 31). Thus check for this case here - * and ignore it selectively - */ - if (type_is_signed(lhs_type)) { - s_max lhs_int, rhs_int; - - lhs_int = get_signed_val(lhs_type, lhs); - rhs_int = get_signed_val(rhs_type, rhs); - - if (fls(lhs_int) + rhs_int == type_bit_width(lhs_type)) { - pr_debug("signed left shift of %lld by %lld ignored.\n", - (s64)lhs_int, (s64)rhs_int); - return; - } - } - ubsan_prologue(&data->location, &flags); val_to_string(rhs_str, sizeof(rhs_str), rhs_type, rhs); |