Search code examples
cgccelf

Creating ELF instead of a.out


I need to generate a simple "Hello World" ELF32 executable using gcc.

I don't seem to have the gcc-elf command though.

Is it possible to create ELF binaries instead of a.out without building gcc again?

I'm assuming it should be possible with some options, but am unsure how to proceed.


Solution

  • a.out is very old, we're talking kernel version 1.2 of linux. Assuming you are operating on any remotely recent linux platform, you are generating elf executables by default. Use the file command on the output executable to verify. E.g.:

    $ file server
    server: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not stripped