This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH, ARM]: Fix diagnostics & disallow ARM instructions on V7M cores
- From: Julian Brown <julian at codesourcery dot com>
- To: Richard Earnshaw <Richard dot Earnshaw at arm dot com>
- Cc: Paul Brook <paul at codesourcery dot com>, binutils at sourceware dot org
- Date: Wed, 19 Jul 2006 21:31:15 +0100
- Subject: Re: [PATCH, ARM]: Fix diagnostics & disallow ARM instructions on V7M cores
- References: <4463AB5D.6070108@codesourcery.com> <200605112321.35247.paul@codesourcery.com> <4463D557.2020905@codesourcery.com> <200605121554.48773.paul@codesourcery.com> <1147446329.7011.3.camel@pc960.cambridge.arm.com>
Richard Earnshaw wrote:
On Fri, 2006-05-12 at 15:54, Paul Brook wrote:
On Friday 12 May 2006 01:22, Julian Brown wrote:
+ as_bad (_("attempt to use ARM instruction on Thumb-only core --`%s'"),
+ str);
Other error messages talk about the "selected processor" rather than "core".
Other than that it looks ok. Someone else will have to approve this for
mainline.
I think the message should be
'attempt to use an ARM instruction on a Thumb-only processor'
ie *an* ARM, and *a* Thumb.
Sorry, I think I forgot about this one: is this version OK for head now?
Cheers,
Julian
ChangeLog:
ChangeLog (gas):
* config/tc-arm.c (md_assemble): Improve diagnostic when attempting
to use ARM instructions on non-ARM-supporting cores.
(autoselect_thumb_from_cpu_variant): New function. Switch on Thumb
mode automatically based on cpu variant.
(md_begin): Call above function.
ChangeLog (gas/testsuite):
* gas/arm/noarm.s: Add test for disabled ARM insns.
* gas/arm/noarm.d: Drive test for above.
* gas/arm/noarm.l: Expected error output.
Index: gas/config/tc-arm.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-arm.c,v
retrieving revision 1.250.2.20
diff -c -p -r1.250.2.20 tc-arm.c
*** gas/config/tc-arm.c 19 Jul 2006 13:08:20 -0000 1.250.2.20
--- gas/config/tc-arm.c 19 Jul 2006 20:29:55 -0000
*************** md_assemble (char *str)
*** 13729,13735 ****
ARM_MERGE_FEATURE_SETS (thumb_arch_used, thumb_arch_used,
arm_ext_v6t2);
}
! else
{
/* Check that this instruction is supported for this CPU. */
if (!opcode->avariant ||
--- 13729,13735 ----
ARM_MERGE_FEATURE_SETS (thumb_arch_used, thumb_arch_used,
arm_ext_v6t2);
}
! else if (ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v1))
{
/* Check that this instruction is supported for this CPU. */
if (!opcode->avariant ||
*************** md_assemble (char *str)
*** 13762,13767 ****
--- 13762,13773 ----
ARM_MERGE_FEATURE_SETS (arm_arch_used, arm_arch_used,
*opcode->avariant);
}
+ else
+ {
+ as_bad (_("attempt to use an ARM instruction on a Thumb-only processor "
+ "-- `%s'"), str);
+ return;
+ }
output_inst (str);
}
*************** set_constant_flonums (void)
*** 18766,18771 ****
--- 18772,18787 ----
abort ();
}
+ /* Auto-select Thumb mode if it's the only available instruction set for the
+ given architecture. */
+
+ static void
+ autoselect_thumb_from_cpu_variant (void)
+ {
+ if (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v1))
+ opcode_select (16);
+ }
+
void
md_begin (void)
{
*************** md_begin (void)
*** 18866,18871 ****
--- 18882,18889 ----
ARM_MERGE_FEATURE_SETS (cpu_variant, *mcpu_cpu_opt, *mfpu_opt);
+ autoselect_thumb_from_cpu_variant ();
+
arm_arch_used = thumb_arch_used = arm_arch_none;
#if defined OBJ_COFF || defined OBJ_ELF
Index: gas/testsuite/gas/arm/noarm.d
===================================================================
RCS file: gas/testsuite/gas/arm/noarm.d
diff -N gas/testsuite/gas/arm/noarm.d
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- gas/testsuite/gas/arm/noarm.d 19 Jul 2006 20:29:55 -0000
***************
*** 0 ****
--- 1,3 ----
+ # name: Disallow ARM instructions on V7M
+ # as:
+ # error-output: noarm.l
Index: gas/testsuite/gas/arm/noarm.l
===================================================================
RCS file: gas/testsuite/gas/arm/noarm.l
diff -N gas/testsuite/gas/arm/noarm.l
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- gas/testsuite/gas/arm/noarm.l 19 Jul 2006 20:29:55 -0000
***************
*** 0 ****
--- 1,3 ----
+ [^:]*: Assembler messages:
+ [^:]*:12: Error: selected processor does not support ARM opcodes
+ [^:]*:13: Error: attempt to use an ARM instruction on a Thumb-only processor -- `nop'
Index: gas/testsuite/gas/arm/noarm.s
===================================================================
RCS file: gas/testsuite/gas/arm/noarm.s
diff -N gas/testsuite/gas/arm/noarm.s
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- gas/testsuite/gas/arm/noarm.s 19 Jul 2006 20:29:55 -0000
***************
*** 0 ****
--- 1,13 ----
+ .arch armv7a
+ .syntax unified
+ .text
+ func:
+ nop
+ movw r0, #0
+
+ .arch armv7
+ .thumb
+ nop
+ movw r0, #0
+ .arm
+ nop