main | files
October 2nd, 2024    

CISC 3320 3.0 17279 EW6
Main
Files
Syllabus
Links
Homeworks

Notes
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
Networ Intro
LAN Intro
Topologies
Comp Networks

Big Data
Security
Email

Misc
What is ELF/COFF?

Projects
Project 1
Project 2

Past Tests
Midterm
OldSample Midterm
OldMidterm
OldSample Final
OldMidterm Exam

What are ELF, COFF, and PE 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.

[this description just scratches the surface; if you want to know more, read the PE COFF specification linked from the links page, and search the web for ELF documentation].



































© 2006, Particle