https://sourceware.org/bugzilla/show_bug.cgi?id=28619
Bug ID: 28619 Summary: -m option is not ignored when is immediately preceded by -o option Product: binutils Version: unspecified Status: UNCONFIRMED Severity: normal Priority: P2 Component: ld Assignee: unassigned at sourceware dot org Reporter: egor_suvorov at mail dot ru Target Milestone: --- Here are upstream bugs for GCC and Clang: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103362 https://bugs.llvm.org/show_bug.cgi?id=52583 And the initial StackOverflow question: https://stackoverflow.com/questions/70069809/unrecognized-emulation-mode-ain-when-compiling-with-gcc-on-ubuntu Steps to reproduce: 1. Take an arbitrary small C program, compile it to an object file e.g. `a.o`. I've used the following incorrect one compiled with `gcc main.c -c`: `void _start(){} 2. `ld main.o -o -main` - note that the dash before `main` is not a typo. Expected result: linking is successful, output is written to a file name `-main`. Real result: ld: unrecognised emulation mode: ain Supported emulations: elf_x86_64 elf32_x86_64 elf_i386 elf_iamcu elf_l1om elf_k1om i386pep i386pe Extra details: It seems to me that the `-main` command line argument is parsed twice: once as an argument for the `-o` option, and once as a `-m` flag. For example, if I run `ld main.o -o -melf_x86_64`, linking succeeds and output is written to `./-melf_x86_64`. If I try `ld main.o -o -mi386` it fails with the following message: ld: i386:x86-64 architecture of input file `main.o' is incompatible with i386 output -- You are receiving this mail because: You are on the CC list for the bug.