PE、ELF、COFF单词不难,但是说的很清楚

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.

Under Windows, Visual C++ (and every Windows compiler) generates PE COFF files. Under Linux, GCC generates ELF files (or others depending on your configurations).

ELF stands for Executable and Linking Format. COFF for 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).

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).

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.)

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).

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.

An operating mode in the Intel 80x86 family of microprocessors. In real mode, the processor can execute only one program at a time. It can access no more than about 1 MB of memory, but it can freely access system memory and input/output devices. Real mode is the only mode possible in the 8086 processor and is the only operating mode supported by MS-DOS. In contrast, the protected mode offered in the 80286 and higher microprocessors provides the memory management and memory protection needed for multitasking environments such as Windows.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值