Generating a.out file format with GCC
Solution 1
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
Solution 2
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+).
Nulik
A C developer, obsessed with performance. Contact for development on blockchain platforms: [email protected]
Updated on July 01, 2022Comments
-
Nulik almost 2 years
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?
-
Nulik over 12 yearsI am developing an operating system and I need kernel and applications to be packed together in one image file so it is loaded quickly with one read and one write (the whole image) , a.out looks to be the ideal format for this, being simple and supported by a lot of bootloaders.
-
Nulik over 12 yearsthe problem is, I have many object files (.o) which are in elf format, so when I link them with OUTPUT_FORMAT(a.out-i386-linux) parameter in the linker script i get this error: "can not represent section `.comment' in a.out object file format". This is why I need the "gcc -c file.c" being compiled from the beginning into a.out format, and not ELF.
-
Nulik over 12 yearsI found the solution to the above, with -fno-ident option .comment section wasn't generated, i booted my a.out kernel fine with grub. thanks
-
Quentin Casasnovas over 12 yearsSorry I missed your first comment, and glad that you found the fix yourself :)