This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH, GAS/ARM] Fix selected_cpu with default CPU and -mcpu
- From: Thomas Preudhomme <thomas dot preudhomme at foss dot arm dot com>
- To: Richard Earnshaw <richard dot earnshaw at arm dot com>, Nick Clifton <nickc at redhat dot com>, Alan Modra <amodra at gmail dot com>, binutils at sourceware dot org
- Date: Fri, 24 Mar 2017 09:38:38 +0000
- Subject: [PATCH, GAS/ARM] Fix selected_cpu with default CPU and -mcpu
- Authentication-results: sourceware.org; auth=none
Hi,
When GAS is compiled with DEFAULT_CPU set and then run with a -mcpu or
-march option, selected_cpu will be set to the default CPU. This means
the -mcpu is ignored which is surprising behavior. This patch instead
sets selected_cpu from the value passed to -mcpu/-march.
ChangeLog entry is as follows:
*** gas/ChangeLog ***
2017-02-03 Thomas preud'homme <thomas.preudhomme@arm.com>
* config/tc-arm.: (md_begin): Set selected_cpu from *mcpu_cpu_opt when
CPU_DEFAULT is defined.
Testing: GAS was configured with CFLAGS="-DCPU_DEFAULT=ARM_ARCH_V6SM"
and then assembling gas/testsuite/gas/arm/blank.s with -mcpu=cortex-a57.
Without the patch, the build attributes are:
Tag_CPU_name: "Cortex-A57"
Tag_CPU_arch: v6S-M
Tag_CPU_arch_profile: Microcontroller
Tag_THUMB_ISA_use: Thumb-1
With the patch, the build attributes are as expected:
File Attributes
Tag_CPU_name: "Cortex-A57"
Tag_CPU_arch: v8
Tag_CPU_arch_profile: Application
Tag_ARM_ISA_use: Yes
Tag_THUMB_ISA_use: Thumb-2
Tag_MPextension_use: Allowed
Tag_Virtualization_use: TrustZone and Virtualization Extensions
Is this ok for master?
Best regards,
Thomas
diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c
index a433929ce94b515c71764c96f2df2b43b600cf98..372fca19c7af187768f71d284e2ba9be5d9ae610 100644
--- a/gas/config/tc-arm.c
+++ b/gas/config/tc-arm.c
@@ -25040,8 +25040,8 @@ md_begin (void)
mcpu_cpu_opt = &cpu_default;
selected_cpu = cpu_default;
}
- else if (no_cpu_selected ())
- selected_cpu = cpu_default;
+ else
+ selected_cpu = *mcpu_cpu_opt;
#else
if (mcpu_cpu_opt)
selected_cpu = *mcpu_cpu_opt;