Bug 12296 - cortex-m3: SVC is not permitted on this architecture
Summary: cortex-m3: SVC is not permitted on this architecture
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gas (show other bugs)
Version: 2.21
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-08 12:44 UTC by Enrico Scholz
Modified: 2014-05-28 19:45 UTC (History)
6 users (show)

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


Attachments
update ARM_AEXT_V7_ARM macro to include ARM_OS_EXT flag (310 bytes, patch)
2011-03-29 19:52 UTC, Dan McDonald
Details | Diff
Mark ARMv7 as having OS extension, add testcase, fix 1/5 regressions (652 bytes, patch)
2011-03-31 19:22 UTC, Dan McDonald
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Enrico Scholz 2010-12-08 12:44:44 UTC
While building code like

$ echo 'svc 0' > /tmp/x.s
$ arm-linux-gnueabi-as -mcpu=cortex-m3 /tmp/x.s
/tmp/x.s: Assembler messages:
/tmp/x.s:1: Error: SVC is not permitted on this architecture


'svc' is a valid operation on Cortex-M3 cpus and code was accepted by previous binutils version.

Report is against 63afe4ed46b5b8c21445192c9046d1c3de2859ec
Comment 1 Claudio 2010-12-17 22:42:05 UTC
I have the same issue while compiling freertos for cortex-m3 (that uses the 'svc 0' instruction) with binutils 2.21:
"Error: SVC is not permitted on this architecture"

building with binutils 2.20.1 works fine.
Comment 2 Dan McDonald 2011-03-29 19:52:08 UTC
Created attachment 5340 [details]
update ARM_AEXT_V7_ARM macro to include ARM_OS_EXT flag

This also affects target arm-none-eabi. Like Claudio, I am also trying to compile FreeRTOS. 

It looks like the v7 processor profile (which the Cortex-M3 is an example of) neglects to mark the "os" extension as being available.

I attached a diff against CVS that fixes this issue for me. The patch updates the ARM_AEXT_V7_ARM macro to also include the ARM_OS_EXT flag. I believe that all v7 processors have the SVC instruction (based on the v7-M and v7-AR reference manuals).

$ echo 'svc 0' > /tmp/x.s
$ arm-none-eabi-as -mcpu=cortex-m3 /tmp/x.s -o /tmp/x.o
$ arm-none-eabi-objdump -d /tmp/x.o

/tmp/x.o:     file format elf32-littlearm


Disassembly of section .text:

00000000 <.text>:
   0:	df00      	svc	0
Comment 3 Matthew Gretton-Dann 2011-03-30 09:32:31 UTC
(In reply to comment #2)
> It looks like the v7 processor profile (which the Cortex-M3 is an example of)
> neglects to mark the "os" extension as being available.

This is indeed the case.  Mistake on my part when creating the initial patch.

Please submit a patch - with testcase - to the binutils mailing list.
Comment 4 Dan McDonald 2011-03-31 19:22:01 UTC
Created attachment 5347 [details]
Mark ARMv7 as having OS extension, add testcase, fix 1/5 regressions

The previous patch introduced 5 test failure regressions. 

Failure #1: 
The patch somehow changed the armv7 attr table to include a new line, "Tag_CPU_arch_profile: Microcontroller". This new patch modifies the expect script to allow this change, but I don't know if this is correct behavior.

Failures #2-5:
Instructions of the form "msr APSR_<bits>,<imm|reg>" now generate syntax errors. Previously, using an immediate for the operand would generate a different error that was explicitly checked for, and registers as the second operand would assemble into valid instructions. I spent some time with it (I think the problem manifests in parse_operands(), but probably doesn't originate there) but this takes more effort that I can commit to figure out what is going wrong. This patch makes no attempt to fix these problems.

Finally, this patch enhances a testcase to verify the svc instruction compiles correctly.
Comment 5 Sourceware Commits 2011-04-11 15:23:12 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	nickc@sourceware.org	2011-04-11 15:23:09

Modified files:
	gas/testsuite  : ChangeLog 
	gas/testsuite/gas/arm: arch7.d arch7.s attr-march-armv7.d 
	include/opcode : ChangeLog arm.h 

Log message:
	PR gas/12296
	* arm.h (ARM_AEXT_V7_ARM): Add ARM_EXT_OS.
	
	* gas/arm/arch7.s: Add SVC insn.
	* gas/arm/arch7.d: Add disassembly of SVC insn.
	* gas/arm/attr-march-armv7.d: Add arch profile tag.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/testsuite/ChangeLog.diff?cvsroot=src&r1=1.1879&r2=1.1880
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/testsuite/gas/arm/arch7.d.diff?cvsroot=src&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/testsuite/gas/arm/arch7.s.diff?cvsroot=src&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/testsuite/gas/arm/attr-march-armv7.d.diff?cvsroot=src&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/src/include/opcode/ChangeLog.diff?cvsroot=src&r1=1.435&r2=1.436
http://sourceware.org/cgi-bin/cvsweb.cgi/src/include/opcode/arm.h.diff?cvsroot=src&r1=1.24&r2=1.25
Comment 6 Matthew.Gretton-Dann 2011-04-11 15:24:00 UTC
Hi,

I am out of the office until Monday 18th April 2011, and will not be reading email.

If you have an urgent issue please get in touch with Richard Earnshaw.

Otherwise, I will get back to you as soon as possible after I am back in the office on Monday 18th April 2011.

Thanks,

Matt
Comment 7 Nick Clifton 2011-04-11 15:24:41 UTC
Hi Dan,

  Thanks very much for revised patch.  I have now checked it in along with these changelog entries.

Cheers
  Nick

include/opcode/ChangeLog
2011-04-11  Dan McDonald  <dan@wellkeeper.com>

	PR gas/12296
	* arm.h (ARM_AEXT_V7_ARM): Add ARM_EXT_OS.

gas/testsuite/ChangeLog
2011-04-11  Dan McDonald  <dan@wellkeeper.com>

	PR gas/12296
	* gas/arm/arch7.s: Add SVC insn.
	* gas/arm/arch7.d: Add disassembly of SVC insn.
	* gas/arm/attr-march-armv7.d: Add arch profile tag.
Comment 8 Nick Clifton 2011-04-11 15:25:17 UTC
patch applied
Comment 9 Jackie Rosen 2014-02-16 16:59:34 UTC Comment hidden (spam)