When your compiler compiles your C code, it generates an object file, which is consequently linked into a program. These "object" files and "executable" files have a specific format.
当你的编译器编译C代码时,会生成一个object文件,这个文件接下来会被链接到程序中,object文件和可执行文件都有固定的格式
Under Windows, Visual C++ (and every Windows compiler) generates PE COFF files. Under Linux, GCC generates ELF files (or others depending on your configurations).
在Windows下Visual C++(所有的windows编译器都一样)会生成呢个PE COFF格式的文件,在Linux下GCC生成ELF格式的文件(格式可以根据你的配置进行变化)
ELF stands for Executable and Linking Format. COFF for Common Object File Format.
ELF是Executable and Linking Format的缩写,而COFF是Common Object File Format的缩写
Microsoft took the COFF file and created their own Windows specific version called PE COFF or Microsoft Portable Executable COFF. They call it portable because the executable itself has the same format no matter what type of code it contains (it can contain code for 64 bit chips, or 32 bit chips, etc., the format is still the same). This doesn't imply that you can run the executable files anywhere; it just means it has a defined format even for code types you never use. (i.e.: executables files for Pocket PC are PE COFF, but you can't run them on your computer and vice versa).
微软在COF文件的格式基础上发展了专属于Windows的PE COFF文件格式,PE中的portable(可移植)是指无论里面包含什么代码(64位代码,32位代码等等,文件格式都会相同),并不是说代码可以在任何系统上运行.所谓可移植只是说这个文件格式为各种代码类型提供支持.(比如:在Pocket PC上的可执行文件格式也为PE COFF,但是他并不能在你的PC机器上运行,反之亦然)
ELF and COFF formats are very similar, and allow for mostly the same functionality. They both can specify object code (files which are generated by the compiler), and executables (files produced by the linker).
ELF 和 COFF 格式非常近似,所以他们所支持的功能也也几乎相同,他们都能指定被生成为object代码(由编译器生成)以及可执行文件(由linker生成)
There is also an a.out format, which was used a while ago, and is supposedly now replaced by ELF. (a.out was a fairly primitive format, lacking some key features to enable easy shared libraries, etc.)
Linux的可执行文件还有一种的格式,a.out,这是一个遗留格式,一般认为会被ELF取代(a.out 是一种很原始的格式,缺乏支持共享库的基本功能)
The link between these formats is that they contain sections. The usual sections you'd find in object and executable files are: .text, which contains actual binary executable code, .data which contains initialized data (if you say "int a = 7;" that's where that integer is stored as initialized to 7), and .bss (blow stack segment) section, which stores un-initialized data (when you declare "int arr[100000];" the executable file will not be increased by that size; this section just has the sizes, etc., and is allocated at load time).
这几种文件格式的联系在于他们都包含section[段],在object文件中和可执行文件中比较常见的段有下面几种:.text,这个段包含实际的可执行代码,.data,这个段包含已经被初始化的数据(比如"int a=7;"这个整型变量的将会被存放在这个段).bss段:存放没有初始化的数据,(比如当你定义"int arr[100000];" ,可执行文件不会真的增大到如此大小,这些空间将会在加载时被分配)
Part of writing an operating is deciding on what object/executable format it will support or whether it defines it's own. It's also important to understand and know these formats to be able to build your operating system.
编写操作系统时会判断是否支持已有的文件格式,或者定义自己的文件格式,所以了解这些文件系统对建立操作系统是十分重要的
ELF格式说明书http://www.muppetlabs.com/~breadbox/software/ELF.txt
PE文件格式详解http://bbs.pediy.com/showthread.php?t=21932
分享到:
相关推荐
elf,omf,coff多种文件转换工具,附带源码
ELF 文件格式分析 中文版 ELF格式
Ada-BFD库允许: 列出并扫描可执行文件或目标文件的ELF部分, 获取ELF部分的内容, 可以访问符号表, 使用BFD反汇编程序Ada BFD库在GNU通用公共许可证版本2下分发(请参阅COPYING)。 Ada BFD使用的单元测试使用...
〜强大的PE / PE64 / NE / LE / COFF / LIB / ELF格式分析,调试,编辑工具〜 ExStudPE Visual Tools是一个扩展的StudPE,LordPE等软件的PE(32位),PE +(64位),NE,Elf(32位),Coff,Lib格式二进制二进制...
文件格式是一种二进制执行文件格式有许多,如elf、coff、aout和flat等,flat格式主要应用在嵌入式uClinux系统中,该文章描述了flat文件格式的具体细节。
ExStudPE Visual Tools 是一个扩展StudPE、LordPE等软件的用于PE(32位)、PE+(64位)、NE、Elf(32位)、Coff、Lib格式 二进制可执行目标文件(.exe、.dll、.ocx、.so、.lib、.obj、*.exp等)的分析、调试、十六进制...
LibObjectFile LibObjectFile是一个.NET库,用于读取,操纵和写入链接器和可执行对象文件(例如ELF,ar,DWARF,COFF ...) 注意:当前LibObjectFile仅支持以下文件格式: ELF目标文件格式DWARF调试格式(版本4) ...
它支持相当多的目标文件格式,包括Linux和NetBSD/FreeBSD,a.out,ELF,COFF,微软16位的OBJ和Win32。它还可以输出纯二进制文件。它的语法设计得相当的简洁易懂,和Intel语法相似但更简单。它支持Pentium,P6,MMX,3DNow!,...
ExStudPE Visual Tools 是一个扩展StudPE、LordPE等软件的用于PE(32位)、PE+(64位)、NE、Elf(32位)、Coff、Lib格式二进制可执行目标文件(*.exe、*.dll、*.ocx、*.so、*.lib、*.obj、*.exp等)的分析、调试、...
新的可执行文件格式COFF在UNIX System VR3中出现,COFF格式相对a.out格式最大变化是多了一个节头表,能够在包含基础的文本段、数据段、BSS段之外包含更多的段,但是COFF对动态连接和C++程序的支持仍然比较困难。...
ExStudPE Visual Tools 是一个扩展StudPE、LordPE等软件的用于PE(32位)、PE+(64位)、NE、Elf(32位)、Coff、Lib格式二进制可执行目标文件(*.exe、*.dll、*.ocx、*.so、*.lib、*.obj、*.exp等)的分析、调试、...
ExStudPE Visual Tools 是一个扩展StudPE、LordPE等软件的用于PE(32位)、PE+(64位)、NE、Elf(32位)、Coff、Lib格式二进制可执行目标文件(*.exe、*.dll、*.ocx、*.so、*.lib、*.obj、*.exp等)的分析、调试、...
从1969年最初的PDP-7 Unix开始,早期的Unix采用的可执行、对象代码和共享库文件格式为a.out(assembler output,汇编程序输出),后来被1983年随Unix System V推出的COFF(Common Object File Format,公共对象文件...
NASM支持大量的文件格式,包括Linux,*BSD,a.out,ELF,COFF,Mach−O,Microsoft 16−bit OBJ,Win32以及Win64,同时也支持简单的二进制文件生成。它的语法被设计的简单易懂,相较Intel的语法更为简单,支持目前...
NASM支持大量的文件格式,包括Linux,*BSD,a.out,ELF,COFF,Mach−O,Microsoft 16−bit OBJ,Win32以及Win64,同时也支持简单的二进制文件生成。它的语法被设计的简单易懂,相较Intel的语法更为简单,支持目前...
NASM支持大量的文件格式,包括Linux,*BSD,a.out,ELF,COFF,Mach−O,Microsoft 16−bit OBJ,Win32以及Win64,同时也支持简单的二进制文件生成。它的语法被设计的简单易懂,相较Intel的语法更为简单,支持目前...