This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC ARM] Fix PR12198 SVC in thumb assembler forces M-profile attribute


All,

Re: http://sourceware.org/bugzilla/show_bug.cgi?id=12198

Please can the attached patch be reviewed and approved, both for trunk
and the 2.21 branch?

This fixes an issue I introduced with the addition of the Operating
System Extension support for ARM to binutils
(http://sourceware.org/ml/binutils/2010-09/msg00413.html) whereby an
object would get marked as being architecture v6S-M if an SVC
instruction was used in Thumb mode and no CPU had been specified on the
command line.

The fix makes sure the OS extension is only noted if other v6-M features
have been used (which aren't also available in plain v6).

This is a point fix for this particular issue, which I believe is safe
for the branch and trunk.  I have come across other corner cases in my
experiments for this fix, which exist in 2.19 as well as current trunk,
but this patch does not address these, as the changes needed are large
scale and invasive.

Proposed ChangeLogs:

gas/ChangeLog:

2010-11-12  Matthew Gretton-Dann  <matthew.gretton-dann@arm.com>

	PR gas/12198
	* config/tc-arm.c (arm_arch_v6m_only): New variable.
	(aeabi_set_public_attributes): Ensure we only set the Operating 
	System Extension when we are on an M-profile core.


gas/testsuite/ChangeLog:

2010-11-12  Matthew Gretton-Dann  <matthew.gretton-dann@arm.com>

	PR gas/12198
	* gas/arm/pr12198-1.d: New test.
	* gas/arm/pr12198-1.s: Likewise.
	* gas/arm/pr12198-2.d: Likewise.
	* gas/arm/pr12198-2.s: Likewise.

include/opcode/ChangeLog:

2010-11-12  Matthew Gretton-Dann <matthew.gretton-dann@arm.com>

	PR gas/12198
	* arm.h (ARM_AEXT_V6M_ONLY): New define.
	(ARM_AEXT_V6M): Rewrite in terms of ARM_AEXT_V6M_ONLY.
	(ARM_ARCH_V6M_ONLY): New define.

Thanks,

Matt

-- 
Matthew Gretton-Dann
Principal Engineer - PDSW Tools
ARM Ltd
diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c
index 8dd342b..1f040ee 100644
--- a/gas/config/tc-arm.c
+++ b/gas/config/tc-arm.c
@@ -207,6 +207,7 @@ static const arm_feature_set arm_arch_any = ARM_ANY;
 static const arm_feature_set arm_arch_full = ARM_FEATURE (-1, -1);
 static const arm_feature_set arm_arch_t2 = ARM_ARCH_THUMB2;
 static const arm_feature_set arm_arch_none = ARM_ARCH_NONE;
+static const arm_feature_set arm_arch_v6m_only = ARM_ARCH_V6M_ONLY;
 
 static const arm_feature_set arm_cext_iwmmxt2 =
   ARM_FEATURE (0, ARM_CEXT_IWMMXT2);
@@ -23230,6 +23231,12 @@ aeabi_set_public_attributes (void)
       ARM_MERGE_FEATURE_SETS (flags, flags, *object_arch);
     }
 
+  /* We need to make sure that the attributes do not identify us as v6S-M
+     when the only v6S-M feature in use is the Operating System Extensions.  */
+  if (ARM_CPU_HAS_FEATURE (flags, arm_ext_os))
+      if (!ARM_CPU_HAS_FEATURE (flags, arm_arch_v6m_only))
+        ARM_CLEAR_FEATURE (flags, flags, arm_ext_os);
+
   tmp = flags;
   arch = 0;
   for (p = cpu_arch_ver; p->val; p++)
diff --git a/gas/testsuite/gas/arm/pr12198-1.d b/gas/testsuite/gas/arm/pr12198-1.d
new file mode 100644
index 0000000..c5f7718
--- /dev/null
+++ b/gas/testsuite/gas/arm/pr12198-1.d
@@ -0,0 +1,12 @@
+# name: PR12198 - Only select v6S-M when v6-M is selected (1)
+# source: pr12198-1.s
+# as:
+# readelf: -A
+# This test is only valid on EABI based ports.
+# target: *-*-*eabi
+
+Attribute Section: aeabi
+File Attributes
+  Tag_CPU_arch: v4T
+  Tag_THUMB_ISA_use: Thumb-1
+  Tag_DIV_use: Not allowed
diff --git a/gas/testsuite/gas/arm/pr12198-1.s b/gas/testsuite/gas/arm/pr12198-1.s
new file mode 100644
index 0000000..15c8805
--- /dev/null
+++ b/gas/testsuite/gas/arm/pr12198-1.s
@@ -0,0 +1,7 @@
+        .thumb
+        .global f
+        .type f, %function
+f:
+        svc 0xab
+        bx lr 
+
diff --git a/gas/testsuite/gas/arm/pr12198-2.d b/gas/testsuite/gas/arm/pr12198-2.d
new file mode 100644
index 0000000..39465c8
--- /dev/null
+++ b/gas/testsuite/gas/arm/pr12198-2.d
@@ -0,0 +1,13 @@
+# name: PR12198 - Only select v6S-M when v6-M is selected (2)
+# source: pr12198-2.s
+# as:
+# readelf: -A
+# This test is only valid on EABI based ports.
+# target: *-*-*eabi
+
+Attribute Section: aeabi
+File Attributes
+  Tag_CPU_arch: v6S-M
+  Tag_CPU_arch_profile: Microcontroller
+  Tag_THUMB_ISA_use: Thumb-1
+  Tag_DIV_use: Not allowed
diff --git a/gas/testsuite/gas/arm/pr12198-2.s b/gas/testsuite/gas/arm/pr12198-2.s
new file mode 100644
index 0000000..25d9353
--- /dev/null
+++ b/gas/testsuite/gas/arm/pr12198-2.s
@@ -0,0 +1,8 @@
+        .thumb
+        .global f
+        .type f, %function
+f:
+        svc 0xab
+        dsb
+        bx lr 
+
diff --git a/include/opcode/arm.h b/include/opcode/arm.h
index 0bfd302..50bc726 100644
--- a/include/opcode/arm.h
+++ b/include/opcode/arm.h
@@ -115,9 +115,10 @@
 #define ARM_AEXT_NOTM \
   (ARM_AEXT_V4 | ARM_EXT_V5ExP | ARM_EXT_V5J | ARM_EXT_V6_NOTM \
    | ARM_EXT_V6_DSP )
+#define ARM_AEXT_V6M_ONLY \
+  ((ARM_EXT_BARRIER | ARM_EXT_V6M | ARM_EXT_THUMB_MSR) & ~(ARM_AEXT_NOTM))
 #define ARM_AEXT_V6M \
-  ((ARM_AEXT_V6K | ARM_EXT_BARRIER | ARM_EXT_V6M | ARM_EXT_THUMB_MSR) \
-   & ~(ARM_AEXT_NOTM))
+  ((ARM_AEXT_V6K | ARM_AEXT_V6M_ONLY) & ~(ARM_AEXT_NOTM))
 #define ARM_AEXT_V6SM (ARM_AEXT_V6M | ARM_EXT_OS)
 #define ARM_AEXT_V7M \
   ((ARM_AEXT_V7_ARM | ARM_EXT_V6M | ARM_EXT_V7M | ARM_EXT_DIV) \
@@ -228,6 +229,8 @@
 			ARM_FEATURE (ARM_AEXT_V7A | ARM_EXT_MP | ARM_EXT_SEC \
 				     | ARM_EXT_DIV | ARM_EXT_ADIV \
 				     | ARM_EXT_VIRT, 0)
+/* Features that are present in v6M and v6S-M but not other v6 cores.  */
+#define ARM_ARCH_V6M_ONLY ARM_FEATURE (ARM_AEXT_V6M_ONLY, 0)
 
 /* There are too many feature bits to fit in a single word, so use a
    structure.  For simplicity we put all core features in one word and

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]