[prev in list] [next in list] [prev in thread] [next in thread] 

List:       binutils-cvs
Subject:    [binutils-gdb] PR26497 UBSAN: tc-sh.c:2467 left shift cannot be represented
From:       Alan Modra via Binutils-cvs <binutils-cvs () sourceware ! org>
Date:       2020-08-31 11:00:23
Message-ID: 20200831110023.9079D3951828 () sourceware ! org
[Download RAW message or body]

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8659fff005fd09cebaa1af5a76962ec77cce320c

commit 8659fff005fd09cebaa1af5a76962ec77cce320c
Author: Alan Modra <amodra@gmail.com>
Date:   Mon Aug 31 16:42:42 2020 +0930

    PR26497 UBSAN: tc-sh.c:2467 left shift cannot be represented
    
            PR 26497
            * config/tc-sh.c (assemble_ppi): Use unsigned variables.

Diff:
---
 gas/ChangeLog      |  5 +++++
 gas/config/tc-sh.c | 12 ++++++------
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/gas/ChangeLog b/gas/ChangeLog
index 0d55433db36..2265271dba7 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,8 @@
+2020-08-31  Alan Modra  <amodra@gmail.com>
+
+	PR 26497
+	* config/tc-sh.c (assemble_ppi): Use unsigned variables.
+
 2020-08-31  Alan Modra  <amodra@gmail.com>
 
 	PR 26495
diff --git a/gas/config/tc-sh.c b/gas/config/tc-sh.c
index e1e509d7d2d..ea9052286a2 100644
--- a/gas/config/tc-sh.c
+++ b/gas/config/tc-sh.c
@@ -2205,12 +2205,12 @@ find_cooked_opcode (char **str_p)
 static unsigned int
 assemble_ppi (char *op_end, sh_opcode_info *opcode)
 {
-  int movx = 0;
-  int movy = 0;
-  int cond = 0;
-  int field_b = 0;
+  unsigned int movx = 0;
+  unsigned int movy = 0;
+  unsigned int cond = 0;
+  unsigned int field_b = 0;
   char *output;
-  int move_code;
+  unsigned int move_code;
   unsigned int size;
 
   for (;;)
@@ -2464,7 +2464,7 @@ assemble_ppi (char *op_end, sh_opcode_info *opcode)
   if (field_b)
     {
       /* Parallel processing insn.  */
-      unsigned long ppi_code = (movx | movy | 0xf800) << 16 | field_b;
+      unsigned int ppi_code = (movx | movy | 0xf800) << 16 | field_b;
 
       output = frag_more (4);
       size = 4;
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic