aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2022-08-13 14:07:31 +0930
committerAlan Modra <amodra@gmail.com>2022-08-13 14:11:27 +0930
commit9effb9f15f4811a80169801b5d2938961424a7d4 (patch)
tree6fbf5f262ec977d6dd23ea8ce5298cf501db5f70 /bfd
parent8c68d88cc44ec476125e30835f79865e8eb32358 (diff)
downloadgdb-9effb9f15f4811a80169801b5d2938961424a7d4.zip
gdb-9effb9f15f4811a80169801b5d2938961424a7d4.tar.gz
gdb-9effb9f15f4811a80169801b5d2938961424a7d4.tar.bz2
ubsan: undefined shift in sign_extend
* libhppa.h (sign_extend): Avoid undefined behaviour.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/libhppa.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/bfd/libhppa.h b/bfd/libhppa.h
index 1de2d5c..ebaffe6 100644
--- a/bfd/libhppa.h
+++ b/bfd/libhppa.h
@@ -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;
}