From 40f246e36c27a521661a926536e1cfceb18cd957 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Thu, 9 Sep 2010 09:09:43 +0000 Subject: [PATCH] * config/tc-arm.c (md_apply_fix): Check if widened add, sub are 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 | 5 +++++ gas/config/tc-arm.c | 21 ++++++++++++--------- gas/testsuite/ChangeLog | 6 ++++++ gas/testsuite/gas/arm/addsw-bad.d | 3 +++ gas/testsuite/gas/arm/addsw-bad.l | 3 +++ gas/testsuite/gas/arm/addsw-bad.s | 6 ++++++ 6 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 gas/testsuite/gas/arm/addsw-bad.d create mode 100644 gas/testsuite/gas/arm/addsw-bad.l create mode 100644 gas/testsuite/gas/arm/addsw-bad.s diff --git a/gas/ChangeLog b/gas/ChangeLog index cef0c184b4..ff4f4a87bb 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,8 @@ +2010-09-09 Tejas Belagod + + * config/tc-arm.c (md_apply_fix): Check if widened add, sub are + flag-setting and handle accordingly. + 2010-09-09 Nick Clifton PR gas/11972 diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c index ce32aef54e..50df78a244 100644 --- a/gas/config/tc-arm.c +++ b/gas/config/tc-arm.c @@ -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) diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog index 73eee887d5..8d50f3c222 100644 --- a/gas/testsuite/ChangeLog +++ b/gas/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2010-09-09 Tejas Belagod + + * 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 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 index 0000000000..686570257f --- /dev/null +++ b/gas/testsuite/gas/arm/addsw-bad.d @@ -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 index 0000000000..fa62b95a00 --- /dev/null +++ b/gas/testsuite/gas/arm/addsw-bad.l @@ -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 index 0000000000..69013be8db --- /dev/null +++ b/gas/testsuite/gas/arm/addsw-bad.s @@ -0,0 +1,6 @@ +.text +.thumb +.cpu cortex-a8 +.syntax unified +subs r4, r6, #0x496 +adds r4, r6, #0x496