mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2025-01-18 12:24:38 +08:00
ubsan: undefined shift in sign_extend
* libhppa.h (sign_extend): Avoid undefined behaviour.
This commit is contained in:
parent
8c68d88cc4
commit
9effb9f15f
@ -162,7 +162,7 @@ enum hppa_reloc_expr_type_alt
|
||||
static inline unsigned ATTRIBUTE_UNUSED
|
||||
sign_extend (unsigned x, unsigned len)
|
||||
{
|
||||
unsigned signbit = (1 << (len - 1));
|
||||
unsigned signbit = (1u << (len - 1));
|
||||
unsigned mask = (signbit << 1) - 1;
|
||||
return ((x & mask) ^ signbit) - signbit;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user