如何在64位机器上运行32位代码?

时间:2016-10-01 23:39:26

标签: nasm

当我使用gcc(使用-m32和没有它)尝试使用nasm时出现以下错误。有人知道如何解决这个问题吗?感谢。

~$ cat tiny.asm 
BITS 32
GLOBAL main
SECTION .text
main:
mov eax, 42
ret
~$ nasm -f elf tiny.asm
~$ gcc -Wall -s tiny.o
/usr/bin/ld: i386 architecture of input file `tiny.o' is incompatible with i386:x86-64 output
collect2: error: ld returned 1 exit status

$ gcc -m32 -Wall -s tiny.o
/usr/bin/ld: cannot find crt1.o: No such file or directory
/usr/bin/ld: cannot find crti.o: No such file or directory
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find -lc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find crtn.o: No such file or directory
collect2: error: ld returned 1 exit status

0 个答案:

没有答案