]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gas/x86: reduce / correct target checks for --64 command line option
authorJan Beulich <jbeulich@suse.com>
Mon, 22 Dec 2025 10:06:35 +0000 (11:06 +0100)
committerJan Beulich <jbeulich@suse.com>
Mon, 22 Dec 2025 10:06:35 +0000 (11:06 +0100)
First, pei-x86-64 is meaningless for gas; it's a linker output target, not
one object files would use. Next, coff-x86-64 is meaningless for TE_PE
(and really coff-x86-64 isn't currently provided by any libbfd
configuration anyway). Then, of the three ones left exactly one is a
possible candidate for a given gas configuration. Checking others as well
would only lead to (possibly cryptic) errors later. And finally, even for
ELF we want to check for the one target which i386_target_format() would
also use. This last aspect then applies to --x32 handling as well (just
that there it's benign right now, as only one target exists starting
"elf32-x86-64".

gas/config/tc-i386.c

index 54c66789522850058b09fd8f2ca4c173c37bb2a1..93261935263e08e00d7732cdb4c890b65e9ddae2 100644 (file)
@@ -17280,11 +17280,13 @@ md_parse_option (int c, const char *arg)
 
        list = bfd_target_list ();
        for (l = list; *l != NULL; l++)
-         if (startswith (*l, "elf64-x86-64")
-             || strcmp (*l, "coff-x86-64") == 0
-             || strcmp (*l, "pe-x86-64") == 0
-             || strcmp (*l, "pei-x86-64") == 0
-             || strcmp (*l, "mach-o-x86-64") == 0)
+#if defined (OBJ_ELF)
+         if (strcmp (*l, ELF_TARGET_FORMAT64) == 0)
+#elif defined (TE_PE)
+         if (strcmp (*l, "pe-x86-64") == 0)
+#else
+         if (strcmp (*l, "mach-o-x86-64") == 0)
+#endif
            {
              default_arch = "x86_64";
              break;
@@ -17303,7 +17305,7 @@ md_parse_option (int c, const char *arg)
 
        list = bfd_target_list ();
        for (l = list; *l != NULL; l++)
-         if (startswith (*l, "elf32-x86-64"))
+         if (strcmp (*l, ELF_TARGET_FORMAT32) == 0)
            {
              default_arch = "x86_64:32";
              break;