aboutsummaryrefslogtreecommitdiff
path: root/gas/config
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2021-06-18 22:27:01 +0930
committerAlan Modra <amodra@gmail.com>2021-06-19 11:08:55 +0930
commit03e689aaac95da0b22f7689a2c307e8ddd99ae2c (patch)
tree3d400c00985b288b6cde2b2a356112d20bc107b8 /gas/config
parent43f71bc5df211f424e7dfafbdfb644cd03bfcd34 (diff)
downloadgdb-03e689aaac95da0b22f7689a2c307e8ddd99ae2c.zip
gdb-03e689aaac95da0b22f7689a2c307e8ddd99ae2c.tar.gz
gdb-03e689aaac95da0b22f7689a2c307e8ddd99ae2c.tar.bz2
ubsan errors when 32-bit bfd
A shift count exceeding the size of the value is undefined behaviour, and so is negating a signed LONG_MIN. * config/tc-z80.c (signed_overflow, unsigned_overflow): Avoid UB.
Diffstat (limited to 'gas/config')
-rw-r--r--gas/config/tc-z80.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/gas/config/tc-z80.c b/gas/config/tc-z80.c
index 47d1405..303296b 100644
--- a/gas/config/tc-z80.c
+++ b/gas/config/tc-z80.c
@@ -3703,14 +3703,14 @@ md_assemble (char *str)
static int
signed_overflow (signed long value, unsigned bitsize)
{
- signed long max = (signed long)(1UL << (bitsize-1));
- return value < -max || value >= max;
+ signed long max = (signed long) ((1UL << (bitsize - 1)) - 1);
+ return value < -max - 1 || value > max;
}
static int
unsigned_overflow (unsigned long value, unsigned bitsize)
{
- return (value >> bitsize) != 0;
+ return value >> (bitsize - 1) >> 1 != 0;
}
static int