aboutsummaryrefslogtreecommitdiff
path: root/gas/config
diff options
context:
space:
mode:
authorIlya Leoshkevich <iii@linux.ibm.com>2022-05-16 21:58:55 +0200
committerAndreas Krebbel <krebbel@linux.ibm.com>2022-05-16 22:00:17 +0200
commit973773de93a1af858e391ab413c47323b0869012 (patch)
tree05d79c1edaf57c6cea0c35afc37f914eb66d97ba /gas/config
parent187075ebbc0cba7b58685c7214028e791b5af844 (diff)
downloadgdb-973773de93a1af858e391ab413c47323b0869012.zip
gdb-973773de93a1af858e391ab413c47323b0869012.tar.gz
gdb-973773de93a1af858e391ab413c47323b0869012.tar.bz2
IBM zSystems: Fix left-shifting negative PCRel32 values (PR gas/29152)
s390_insert_operand ()'s val, min and max are encoded PCRel32 values and need to be left-shifted by 1 before being shown to the user. Left-shifting negative values is undefined behavior in C, but the current code does not try to prevent it, causing UBSan to complain. Fix by casting the values to their unsigned equivalents before shifting.
Diffstat (limited to 'gas/config')
-rw-r--r--gas/config/tc-s390.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/gas/config/tc-s390.c b/gas/config/tc-s390.c
index fb452f8..04a3c05 100644
--- a/gas/config/tc-s390.c
+++ b/gas/config/tc-s390.c
@@ -622,9 +622,9 @@ s390_insert_operand (unsigned char *insn,
if (operand->flags & S390_OPERAND_PCREL)
{
- val <<= 1;
- min <<= 1;
- max <<= 1;
+ val = (offsetT) ((addressT) val << 1);
+ min = (offsetT) ((addressT) min << 1);
+ max = (offsetT) ((addressT) max << 1);
}
if (file == (char *) NULL)
as_bad (err, (int64_t) val, (int64_t) min, (int64_t) max);