问题
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)
回答1:
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
回答2:
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.
来源:https://stackoverflow.com/questions/5565594/creating-elf-instead-of-a-out