问题描述
我需要使用gcc来生成一个简单的Hello World的ELF32可执行文件。
我似乎不具备GCC精灵命令虽然。
是否有可能再没有编译GCC创建ELF可执行文件,而不是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)
推荐答案
a.out的是很老了,我们正在谈论的内核版本的Linux 1.2。假设你在任何远程最近的Linux平台上运行,你生成默认的ELF可执行文件。使用在输出可执行文件
命令来验证。例如:
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
这篇关于创建ELF,而不是a.out的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!