天天看点

ld: i386 architecture of input file `eatsyscall.o' is incompatible with i386:x86-64 output

在Ubuntu下用学习汇编语言编程,在使用ld链接时有碰到标题所示的问题。

很明显,root cause 是我编译好的文件(eatsyscall.o)是遵循i386 architecture, 而我使用的计算机却是i386:x86-64架构,即在64位机器上编译32位代码

我安装的ubuntu version是14.04,此版本下预安装的ld(链接工具)显示:

Supported emulations: elf_x86_64 elf32_x86_64 elf_i386 i386linux elf_l1om elf_k1om i386pep i386pe

我之前写的命令行是:ld -o eatsyscall eatsyscall.o

报错后我改了一下:    ld -m elf_i386 -o eatsyscall eatsyscall.o 

然后就可以了