Reputation: 7380
How do I generate the a.out file format with GCC on x86 architectures?
With NASM I can do this easily with the -f flag, for example:
nasm -f aout start.asm
objdump -a start.o
start.o: file format a.out-i386-linux
start.o
On Linux, compiling .c files produces an ELF object file. How can I produce a.out files with GCC?
Upvotes: 9
Views: 24340
Reputation: 34587
According to the post Re: How can I control the gcc's output format?, you need to build gcc
for a different target (i386-aout).
It sounds plausible as a.out has been deprecated for years (10+).
Upvotes: 1
Reputation: 1026
There are two answers to this question. One is that you'll need to compile a fresh GCC with aout as its target; it's not as simple as flipping a command-line switch. The other answer is a question: why do you actually need this? I can't immediately think of a valid reason.
Upvotes: 0
Reputation: 1099
To generate the a.out format with gcc, your linker needs to be told to do so. You can do it by passing it flags from gcc thanks to the -Wl
flag.
Here is what you would do for the a.out format:
gcc -Wl,--oformat=a.out-i386-linux file.c -o file.out
You can also display all formats supported by typing:
objdump -i
Upvotes: 16