Creating ELF instead of a.out

后端 未结 2 1214
孤独总比滥情好
孤独总比滥情好 2020-12-21 09:18

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.

相关标签:
2条回答
  • 2020-12-21 09:57

    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
    
    0 讨论(0)
  • 2020-12-21 10:18

    Check the file a.out

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

    I believe the default name is retained as a.out but the format is ELF.

    0 讨论(0)
提交回复
热议问题