ubsan: ia64: left shift of negative value
authorAlan Modra <amodra@gmail.com>
Tue, 10 Dec 2019 07:27:14 +0000 (17:57 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 11 Dec 2019 01:03:36 +0000 (11:33 +1030)
Here, since val is signed:
   *valuep = (val << scale);

* cpu-ia64-opc.c (ext_imms_scaled): Avoid undefined left shift
of negative values by using unsigned vars.

bfd/ChangeLog
bfd/cpu-ia64-opc.c

index 50c878b29df6dffc84316bdbd471b1978e482a92..17ad44160a43f1517acbece28a42098bd4c76f6f 100644 (file)
@@ -1,3 +1,8 @@
+2019-12-11  Alan Modra  <amodra@gmail.com>
+
+       * cpu-ia64-opc.c (ext_imms_scaled): Avoid undefined left shift
+       of negative values by using unsigned vars.
+
 2019-12-07  Alan Modra  <amodra@gmail.com>
 
        PR 25236
index 84ee0e2e4a9fdd28b2e93f6d37ff79f276476a9b..8df90befe39300ae6cc5e2f582b60c41d7c16b77 100644 (file)
@@ -186,7 +186,7 @@ ext_imms_scaled (const struct ia64_operand *self, ia64_insn code,
                 ia64_insn *valuep, int scale)
 {
   int i, bits = 0, total = 0;
-  BFD_HOST_64_BIT val = 0, sign;
+  BFD_HOST_U_64_BIT val = 0, sign;
 
   for (i = 0; i < NELEMS (self->field) && self->field[i].bits; ++i)
     {
@@ -196,10 +196,10 @@ ext_imms_scaled (const struct ia64_operand *self, ia64_insn code,
       total += bits;
     }
   /* sign extend: */
-  sign = (BFD_HOST_64_BIT) 1 << (total - 1);
+  sign = (BFD_HOST_U_64_BIT) 1 << (total - 1);
   val = (val ^ sign) - sign;
 
-  *valuep = (val << scale);
+  *valuep = val << scale;
   return 0;
 }
 
This page took 0.028509 seconds and 4 git commands to generate.