[binutils-gdb] x86: don't accept base architectures as extensions

Jan Beulich jbeulich@sourceware.org
Thu Mar 17 10:06:13 GMT 2022


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ed971d9fa65b91a91101d23a968e6244b93d008d

commit ed971d9fa65b91a91101d23a968e6244b93d008d
Author: Jan Beulich <jbeulich@suse.com>
Date:   Thu Mar 17 11:05:56 2022 +0100

    x86: don't accept base architectures as extensions
    
    The -march= intentions are quite clear: A base architecture may be
    followed by any number of extensions. Accepting a base architecture in
    place of an extension will at best result in confusion, as the first of
    the two (or more) items specified simply would not take effect, due to
    being overridden by the later one(s).

Diff:
---
 gas/config/tc-i386.c               | 2 +-
 gas/testsuite/gas/i386/arch-10-5.l | 2 ++
 gas/testsuite/gas/i386/arch-10-5.s | 1 +
 gas/testsuite/gas/i386/i386.exp    | 1 +
 4 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index 1ff5fd8e453..1cc14feeccf 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -13262,7 +13262,7 @@ md_parse_option (int c, const char *arg)
 	    *next++ = '\0';
 	  for (j = 0; j < ARRAY_SIZE (cpu_arch); j++)
 	    {
-	      if (strcmp (arch, cpu_arch [j].name) == 0)
+	      if (arch == saved && strcmp (arch, cpu_arch [j].name) == 0)
 		{
 		  /* Processor.  */
 		  if (! cpu_arch[j].flags.bitfield.cpui386)
diff --git a/gas/testsuite/gas/i386/arch-10-5.l b/gas/testsuite/gas/i386/arch-10-5.l
new file mode 100644
index 00000000000..25dc404a0da
--- /dev/null
+++ b/gas/testsuite/gas/i386/arch-10-5.l
@@ -0,0 +1,2 @@
+Assembler messages:
+Fatal error: .*
diff --git a/gas/testsuite/gas/i386/arch-10-5.s b/gas/testsuite/gas/i386/arch-10-5.s
new file mode 100644
index 00000000000..09cc1e1f7cd
--- /dev/null
+++ b/gas/testsuite/gas/i386/arch-10-5.s
@@ -0,0 +1 @@
+	.text
diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp
index da5c2f6b806..3c157e9eb1e 100644
--- a/gas/testsuite/gas/i386/i386.exp
+++ b/gas/testsuite/gas/i386/i386.exp
@@ -199,6 +199,7 @@ if [gas_32_check] then {
     run_list_test "arch-10-2" "-march=i686 -I${srcdir}/$subdir -al"
     run_list_test "arch-10-3" "-march=i686+mmx+sse4.2 -I${srcdir}/$subdir -al"
     run_list_test "arch-10-4" "-march=i686+mmx+sse4+vmx+smx -I${srcdir}/$subdir -al"
+    run_list_test "arch-10-5" "-march=generic32+i686 -al"
     run_dump_test "arch-11"
     run_dump_test "arch-12"
     run_dump_test "arch-13"


More information about the Binutils-cvs mailing list