【发布时间】:2011-12-17 03:56:18
【问题描述】:
如何在 64 位 Linux 上使用 Gas ('as') 将源代码组装成 32 位二进制文件?
这是为了学习 32 位教程,而无需将所有指针和大量指令更改为四字。
谢谢,
克里斯。
附:我可以在 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
【问题讨论】:
-
--32或将-m32与 gcc 一起使用
标签: assembly 32bit-64bit