From: Jan Beulich Date: Mon, 22 Dec 2025 10:06:35 +0000 (+0100) Subject: gas/x86: reduce / correct target checks for --64 command line option X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b36bcf1edd063c5c8bca74be0d2a84b72a7862e8;p=thirdparty%2Fbinutils-gdb.git gas/x86: reduce / correct target checks for --64 command line option 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". --- diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index 54c66789522..93261935263 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -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;