How can I use Gas (‘as’) to assemble source to a 32 bit binary on 64 bit Linux?
This is for the purpose of following 32 bit tutorials without the hassle of having to change all the pointers and lots of instructions to quad words.
Thanks,
Chris.
P.S. I can easily do this in 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
Use
aswith the option “–32”, likeas --32 source.s -o objectfileOr you can just use gcc to assemble and link an assemler source file. gcc recognizes it by the ending.
gcc -m32 source.s -o executable