PR 10169
authorNick Clifton <nickc@redhat.com>
Thu, 18 Jun 2009 16:36:05 +0000 (16:36 +0000)
committerNick Clifton <nickc@redhat.com>
Thu, 18 Jun 2009 16:36:05 +0000 (16:36 +0000)
        * gas/tc-arm.c (do_t_ssat): Move common code from here...
        (do_t_usat): ... and here to...
        (do_t_ssat_usat): New function: ... here.  Add code to check that
        the shift value, if present, is in range.

        * gas/arm/thumb2_bad_reg.s: Add tests for SSAT and USAT with an
        out of range shift.
        * gas/arm/thumb2_bad_reg.l: Update expected error messages.

gas/ChangeLog
gas/config/tc-arm.c
gas/testsuite/ChangeLog
gas/testsuite/gas/arm/thumb2_bad_reg.l
gas/testsuite/gas/arm/thumb2_bad_reg.s

index 3f8aa06..2f19a40 100644 (file)
@@ -1,3 +1,11 @@
+2009-06-18  Nick Clifton  <nickc@redhat.com>
+
+       PR 10169
+       * gas/tc-arm.c (do_t_ssat): Move common code from here...
+       (do_t_usat): ... and here to...
+       (do_t_ssat_usat): New function: ... here.  Add code to check that
+       the shift value, if present, is in range.
+
 2009-06-18  Dave Korn  <dave.korn.cygwin@gmail.com>
 
        Merge cegcc and mingw32ce target name changes
index 67d8cc9..1190696 100644 (file)
@@ -10654,7 +10654,7 @@ do_t_smc (void)
 }
 
 static void
-do_t_ssat (void)
+do_t_ssat_usat (int bias)
 {
   unsigned Rd, Rn;
 
@@ -10665,24 +10665,37 @@ do_t_ssat (void)
   reject_bad_reg (Rn);
 
   inst.instruction |= Rd << 8;
-  inst.instruction |= inst.operands[1].imm - 1;
+  inst.instruction |= inst.operands[1].imm - bias;
   inst.instruction |= Rn << 16;
 
   if (inst.operands[3].present)
     {
+      offsetT shift_amount = inst.reloc.exp.X_add_number;
+
+      inst.reloc.type = BFD_RELOC_UNUSED;
+
       constraint (inst.reloc.exp.X_op != O_constant,
                  _("expression too complex"));
 
-      if (inst.reloc.exp.X_add_number != 0)
+      if (shift_amount != 0)
        {
+         constraint (shift_amount > 31,
+                     _("shift expression is too large"));
+
          if (inst.operands[3].shift_kind == SHIFT_ASR)
-           inst.instruction |= 0x00200000;  /* sh bit */
-         inst.instruction |= (inst.reloc.exp.X_add_number & 0x1c) << 10;
-         inst.instruction |= (inst.reloc.exp.X_add_number & 0x03) << 6;
+           inst.instruction |= 0x00200000;  /* sh bit.  */
+
+         inst.instruction |= (shift_amount & 0x1c) << 10;
+         inst.instruction |= (shift_amount & 0x03) << 6;
        }
-      inst.reloc.type = BFD_RELOC_UNUSED;
     }
 }
+  
+static void
+do_t_ssat (void)
+{
+  do_t_ssat_usat (1);
+}
 
 static void
 do_t_ssat16 (void)
@@ -10818,32 +10831,7 @@ do_t_tb (void)
 static void
 do_t_usat (void)
 {
-  unsigned Rd, Rn;
-
-  Rd = inst.operands[0].reg;
-  Rn = inst.operands[2].reg;
-
-  reject_bad_reg (Rd);
-  reject_bad_reg (Rn);
-
-  inst.instruction |= Rd << 8;
-  inst.instruction |= inst.operands[1].imm;
-  inst.instruction |= Rn << 16;
-
-  if (inst.operands[3].present)
-    {
-      constraint (inst.reloc.exp.X_op != O_constant,
-                 _("expression too complex"));
-      if (inst.reloc.exp.X_add_number != 0)
-       {
-         if (inst.operands[3].shift_kind == SHIFT_ASR)
-           inst.instruction |= 0x00200000;  /* sh bit */
-
-         inst.instruction |= (inst.reloc.exp.X_add_number & 0x1c) << 10;
-         inst.instruction |= (inst.reloc.exp.X_add_number & 0x03) << 6;
-       }
-      inst.reloc.type = BFD_RELOC_UNUSED;
-    }
+  do_t_ssat_usat (0);
 }
 
 static void
index 5bac61e..a71903f 100644 (file)
@@ -1,5 +1,10 @@
 2009-06-18  Nick Clifton  <nickc@redhat.com>
 
+       PR 10169
+       * gas/arm/thumb2_bad_reg.s: Add tests for SSAT and USAT with an
+       out of range shift.
+       * gas/arm/thumb2_bad_reg.l: Update expected error messages.
+
        PR 10288
        * gas/arm/align.s: Add labels so that COFF based targets can
        correctly locate THUMB code.
index f22df10..1da7bac 100644 (file)
 [^:]*:[0-9]+: Error: r15 not allowed here -- `ssat r15,#1,r0'
 [^:]*:[0-9]+: Error: r13 not allowed here -- `ssat r0,#1,r13'
 [^:]*:[0-9]+: Error: r15 not allowed here -- `ssat r0,#1,r15'
+[^:]*:[0-9]+: Error: shift expression is too large -- `ssat r1,#1,r3,asr#32'
 [^:]*:[0-9]+: Error: r13 not allowed here -- `ssat16 r13,#1,r0'
 [^:]*:[0-9]+: Error: r15 not allowed here -- `ssat16 r15,#1,r0'
 [^:]*:[0-9]+: Error: r13 not allowed here -- `ssat16 r0,#1,r13'
 [^:]*:[0-9]+: Error: r15 not allowed here -- `usat r15,#1,r0'
 [^:]*:[0-9]+: Error: r13 not allowed here -- `usat r0,#1,r13'
 [^:]*:[0-9]+: Error: r15 not allowed here -- `usat r0,#1,r15'
+[^:]*:[0-9]+: Error: shift expression is too large -- `usat r1,#1,r3,asr#32'
 [^:]*:[0-9]+: Error: r13 not allowed here -- `usat16 r13,#1,r0'
 [^:]*:[0-9]+: Error: r15 not allowed here -- `usat16 r15,#1,r0'
 [^:]*:[0-9]+: Error: r13 not allowed here -- `usat16 r0,#1,r13'
index 90c82e6..20a26e0 100644 (file)
@@ -630,6 +630,7 @@ test:
        ssat r15, #1, r0
        ssat r0, #1, r13
        ssat r0, #1, r15
+       ssat r1, #1, r3,asr #32
        @ SSAT16
        ssat16 r13, #1, r0
        ssat16 r15, #1, r0
@@ -909,6 +910,7 @@ test:
        usat r15, #1, r0
        usat r0, #1, r13
        usat r0, #1, r15
+       usat r1, #1, r3,asr #32
        @ USAT16
        usat16 r13, #1, r0
        usat16 r15, #1, r0