ld 无法识别的仿真模式 /tmp/ccK2pwtc.o ubuntu

ld unrecognized emulation mode /tmp/ccK2pwtc.o on ubuntu

我正在使用以下机器:

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

节目

int main() {
  return 0;
}

编译时

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

我不知道从哪里开始知道为什么。

此外,gcc 和 ld 版本:

> 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.

-Wl,-m 参数指定 gcc 应将 -m 参数传递给链接器。

调用链接器时,会使用 -m 选项,其后跟一个已编译的中间目标文件 (/tmp/ccJI1LRo.o),与受支持的仿真相反,这会导致您遇到的错误消息。

链接器的 -m 选项需要一个用于指定仿真的参数。您问题中的输出列出了支持的仿真。