From: Alan Modra Date: Mon, 31 Aug 2020 06:21:24 +0000 (+0930) Subject: PR26479 UBSAN: tc-nios2.c:244 left shift cannot be represented X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=baeb994f3f6bf2b416676ad269f262675ab9d774;p=binutils-gdb.git PR26479 UBSAN: tc-nios2.c:244 left shift cannot be represented PR 26479 * config/tc-nios2.c (md_chars_to_number): Cast buf[i] before shifting. --- diff --git a/gas/ChangeLog b/gas/ChangeLog index 3d696a9d75b..3f615cf8304 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,8 @@ +2020-08-31 Alan Modra + + PR 26479 + * config/tc-nios2.c (md_chars_to_number): Cast buf[i] before shifting. + 2020-08-31 Alan Modra PR 26472 diff --git a/gas/config/tc-nios2.c b/gas/config/tc-nios2.c index 467e2c95003..16695c5c063 100644 --- a/gas/config/tc-nios2.c +++ b/gas/config/tc-nios2.c @@ -238,10 +238,10 @@ md_chars_to_number (char *buf, int n) val = 0; if (target_big_endian) for (i = 0; i < n; ++i) - val = val | ((buf[i] & 0xff) << 8 * (n - (i + 1))); + val = val | ((valueT) (buf[i] & 0xff) << 8 * (n - (i + 1))); else for (i = 0; i < n; ++i) - val = val | ((buf[i] & 0xff) << 8 * i); + val = val | ((valueT) (buf[i] & 0xff) << 8 * i); return val; }