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.
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.
(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!
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.
Daniel, I think this should marked as 'fixed' after the commit
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
(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!
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?
(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