* config/tc-arm.c (md_apply_fix): Check if widened add, sub are
authorNick Clifton <nickc@redhat.com>
Thu, 9 Sep 2010 09:09:43 +0000 (09:09 +0000)
committerNick Clifton <nickc@redhat.com>
Thu, 9 Sep 2010 09:09:43 +0000 (09:09 +0000)
        flag-setting and handle accordingly.

        * gas/arm/addsw-bad.s: New file.
        * gas/arm/addsw-bad.l: New file.
        * gas/arm/addsw-bad.d: New file.

gas/ChangeLog
gas/config/tc-arm.c
gas/testsuite/ChangeLog
gas/testsuite/gas/arm/addsw-bad.d [new file with mode: 0644]
gas/testsuite/gas/arm/addsw-bad.l [new file with mode: 0644]
gas/testsuite/gas/arm/addsw-bad.s [new file with mode: 0644]

index cef0c18..ff4f4a8 100644 (file)
@@ -1,3 +1,8 @@
+2010-09-09 Tejas Belagod  <tejas.belagod@arm.com>
+
+       * config/tc-arm.c (md_apply_fix): Check if widened add, sub are
+       flag-setting and handle accordingly.
+
 2010-09-09  Nick Clifton  <nickc@redhat.com>
 
        PR gas/11972
index ce32aef..50df78a 100644 (file)
@@ -20252,17 +20252,20 @@ md_apply_fix (fixS *  fixP,
          /* Turn add/sum into addw/subw.  */
          if (fixP->fx_r_type == BFD_RELOC_ARM_T32_ADD_IMM)
            newval = (newval & 0xfeffffff) | 0x02000000;
-
-         /* 12 bit immediate for addw/subw.  */
-         if (value < 0)
+         /* No flat 12-bit imm encoding for addsw/subsw.  */
+         if ((newval & 0x00100000) == 0)
            {
-             value = -value;
-             newval ^= 0x00a00000;
+             /* 12 bit immediate for addw/subw.  */
+             if (value < 0)
+               {
+                 value = -value;
+                 newval ^= 0x00a00000;
+               }
+             if (value > 0xfff)
+               newimm = (unsigned int) FAIL;
+             else
+               newimm = value;
            }
-         if (value > 0xfff)
-           newimm = (unsigned int) FAIL;
-         else
-           newimm = value;
        }
 
       if (newimm == (unsigned int)FAIL)
index 73eee88..8d50f3c 100644 (file)
@@ -1,3 +1,9 @@
+2010-09-09 Tejas Belagod  <tejas.belagod@arm.com>
+
+       * gas/arm/addsw-bad.s: New file.
+       * gas/arm/addsw-bad.l: New file.
+       * gas/arm/addsw-bad.d: New file.
+
 2010-09-03  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR gas/11974
diff --git a/gas/testsuite/gas/arm/addsw-bad.d b/gas/testsuite/gas/arm/addsw-bad.d
new file mode 100644 (file)
index 0000000..6865702
--- /dev/null
@@ -0,0 +1,3 @@
+#name: Invalid Immediate field for flag-setting add,sub
+#skip: *-*-*coff *-*-pe *-*-wince *-*-*aout* *-*-netbsd
+#error-output: addsw-bad.l
diff --git a/gas/testsuite/gas/arm/addsw-bad.l b/gas/testsuite/gas/arm/addsw-bad.l
new file mode 100644 (file)
index 0000000..fa62b95
--- /dev/null
@@ -0,0 +1,3 @@
+[^:]*: Assembler messages:
+[^:]*:5: Error: invalid constant \(496\) after fixup
+[^:]*:6: Error: invalid constant \(496\) after fixup
diff --git a/gas/testsuite/gas/arm/addsw-bad.s b/gas/testsuite/gas/arm/addsw-bad.s
new file mode 100644 (file)
index 0000000..69013be
--- /dev/null
@@ -0,0 +1,6 @@
+.text
+.thumb
+.cpu cortex-a8
+.syntax unified
+subs r4, r6, #0x496
+adds r4, r6, #0x496