fad*_*bee 5 assembly 32bit-64bit
如何在64位Linux上使用Gas('as')将源代码组装成32位二进制文件?
这是为了遵循32位教程而无需将所有指针和大量指令更改为四字的麻烦.
谢谢,
克里斯.
PS我可以在C中轻松完成这个...
chris@chris-linux-desktop:~$ cat test.c
#include "stdio.h"
int main() {
printf("hello world");
return 0;
}
chris@chris-linux-desktop:~$ gcc test.c -o test64
chris@chris-linux-desktop:~$ gcc -m32 test.c -o test32
chris@chris-linux-desktop:~$ file test32
test32: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not stripped
chris@chris-linux-desktop:~$ file test64
test64: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not stripped
Run Code Online (Sandbox Code Playgroud)
使用as
选项"--32",如
as --32 source.s -o objectfile
或者您可以使用gcc来汇编和链接汇编源文件.gcc在结尾处认出它.
gcc -m32 source.s -o executable