Bug 10479 - Too strict checks for addw / subw instructions
Summary: Too strict checks for addw / subw instructions
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gas (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Daniel Gutson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-08-04 21:30 UTC by Anton Korobeynikov
Modified: 2015-10-13 20:18 UTC (History)
5 users (show)

See Also:
Host:
Target: arm-none-linux-gnueabi
Build:
Last reconfirmed:


Attachments
proposed fix (2.13 KB, patch)
2009-08-09 20:27 UTC, Daniel Gutson
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Anton Korobeynikov 2009-08-04 21:30:21 UTC
The following patch introduces bunch of checks for usage of sp and pc registers
as operands for thumb instructions:
http://sourceware.org/ml/binutils/2009-01/msg00363.html

In particular, it rejects, for example, the following two instructions:

addw sp, sp, #0
subw sp, sp, #0

here sp is used as destination register and this is perfectly allowed according
to ARM documentation. Only pc as destination register lead to unpredictable
results. See e.g. A8.6.215 SUB (SP minus immediate) of ARMv7-A / ARMv7-R
Architecture Reference Manual.
Comment 1 Daniel Gutson 2009-08-09 20:27:05 UTC
Created attachment 4124 [details]
proposed fix

Hi, please review this proposed patch, which attempts to fix the validation
checks that wrongly reject good instructions.
I tested this by running the GAS test suite, and including the new test case I
included in the patch. Despite the original report mentioned addw/subw, I
wanted to extend the testing to other instructions as well, in order to ensure
that no other SP/PC-related operands were broken.
Please commit this for me if accepted, since I don't have write access.

Daniel Gutson  <dgutson@codesourcery.com>

	* config/tc-arm.c (do_t_add_sub_w): Fixed constraints. 

	gas/testsuite/ 
	* gas/arm/sp-pc-usage-t.d: New test case.
	* gas/arm/sp-pc-usage-t.s: New file.
Comment 2 Anton Korobeynikov 2009-08-09 20:52:40 UTC
(In reply to comment #1)
> Created an attachment (id=4124)
> proposed fix
> 
> Hi, please review this proposed patch, which attempts to fix the validation
> checks that wrongly reject good instructions.
Looks ok for me!
Comment 3 Daniel Gutson 2009-08-10 13:25:46 UTC
Fix provided in the attachment.
Please note that I don't have write access, so I'm asking someone to commit it
for me please.
Comment 4 Anton Korobeynikov 2009-08-10 13:41:55 UTC
Daniel, I think this should marked as 'fixed' after the commit
Comment 5 Nick Clifton 2009-08-10 14:43:48 UTC
Hi Anton,

  I have applied Daniel's patch (thanks Daniel!) together with a few tweaks to
make sure that the new testcase will work on non-ELF ARM targets.

Cheers
  Nick
Comment 6 Anton Korobeynikov 2009-08-10 15:16:28 UTC
(In reply to comment #5)
>   I have applied Daniel's patch (thanks Daniel!) together with a few tweaks to
> make sure that the new testcase will work on non-ELF ARM targets.
Awesome! Thanks, Nick!
Comment 7 Gilbie Rivas 2015-10-06 16:03:29 UTC
Creative discussion . I learned a lot from the information - Does someone know where my assistant might be able to get a sample armv7 r architecture reference manual copy to type on?
Comment 8 chastity red 2015-10-13 20:18:46 UTC
(In reply to Gilbie Rivas from comment #7)
> Creative discussion . I learned a lot from the information - Does someone
> know where my assistant might be able to get a sample armv7 r architecture
> reference manual copy to type on?

Greetings Gilbie! I got access to an armv7 r architecture reference manual  using this link:  http://goo.gl/Ms4ebj