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?
Without specifying an executable name (which can be done using the -o option), GCC defaults to storing the successfully compiled executable in a file called a. out .
An OUT file is a compiled executable file created by various source code compilers in Unix-like operating systems, such as Linux and AIX. It may store executable code, shared libraries, or object code. OUT files have been largely replaced by the newer COFF (Common Object File Format) format.
a. out is the default executable name generated by the gcc . Once you invoke gcc a.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With