[binutils-gdb] gas/x86: reduce / correct target checks for --64 command line option
Jan Beulich
jbeulich@sourceware.org
Mon Dec 22 10:09:31 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b36bcf1edd063c5c8bca74be0d2a84b72a7862e8
commit b36bcf1edd063c5c8bca74be0d2a84b72a7862e8
Author: Jan Beulich <jbeulich@suse.com>
Date: Mon Dec 22 11:06:35 2025 +0100
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:
---
gas/config/tc-i386.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
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;
More information about the Binutils-cvs
mailing list