I'm using the following machine:
Linux version 5.4.0-42-generic (buildd@lgw01-amd64-038) (gcc version 9.3.0 (Ubuntu 9.3.0-10ubuntu2)) #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020
The program
int main() {
return 0;
}
when compiled
gcc -Wl,-m main.c
returns
/usr/bin/ld: unrecognised emulation mode: /tmp/ccJI1LRo.o
Supported emulations: elf_x86_64 elf32_x86_64 elf_i386 elf_iamcu elf_l1om elf_k1om i386pep i386pe
collect2: error: ld returned 1 exit status
I am not sure where to start as to knowing why.
Also, gcc and ld versions:
> gcc --version
gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> ld --version
GNU ld (GNU Binutils for Ubuntu) 2.34
Copyright (C) 2020 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
The -Wl,-m
argument specifies that gcc should pass the -m
argument to the linker.
When the linker is called, the -m
option is used, and it's followed by a intermediate object file that's been compiled (/tmp/ccJI1LRo.o
), as opposed to a supported emulation, which leads to the error message you've encountered.
The linker's -m
option requires an argument for specifying an emulation. The output in your question lists supported emulations.