The number of different executable file types is as many and varied as the number of different image and sound file formats. Every Operating System seems to have several executable file types unique to itself. This part of the FAQ will give a brief rundown on the various types you will come across.

A quick intro to a few terms:

The BSS (Below Stack Segment) needn't to be present in an executable file. At load-time, the loader will still allocate memory for it and wipes this memory with zeroes (this is assumed by C programs, for instance).

If you're looking for comprehensive informations, consider using the Programmer's File Format Collection and the Linkers and Loaders online book... You can also check Pierre's Library

EXE (DOS "MZ")

DOS-MZ was introduced with MS-DOS (not DOS v1 though) as a companion to the simplified DOS COM file format. DOS-MZ was designed to be run in real mode and reflects this, having a relocation table of SEGMENT:OFFSET pairings. A very simple format that can be run at any offset, it does not distinguish between TEXT, DATA and BSS. Since it was designed to run in real mode, its maximum filesize of code + data + bss is 1mb in size.

Operating Systems that use it: DOS, Win*, Linux DOS Emu, Amiga DOS Emu

EXE (Win 3.xx "NE")

The WIN-NE executable formated designed for Windows 3.x was the "NE" New-Executable. Again, a 16bit format, it alleviated the maximum size restrictions that the DOS-MZ had.

Operating Systems that use it: Windows 3.xx

EXE (OS/2 "LE")

The "LE" Linear Executable format was designed for IBM's OS/2 operating system by Microsoft. Supporting both 16 and 32bit segments.

Operating Systems that use it: OS/2, Watcom Compiler/Extender (DOS)

EXE (Win 9x/NT "PE")

Included from PeBinaries

With Windows 95/NT, a new exectuable file type was required. Thus was born the "PE" Portable Executable, which is still in use. Unlike its predecessors, WIN-PE is a true 32bit file format, supporting relocatable code. It does distinguish between TEXT, DATA, and BSS. It is, in fact, a bastardised version of the COFF format.

If you did set up a Cygwin environment on your Windows machine, "PE" is the target format for your Cygwin GCC toolchain, which causes the unaware some headache when trying to link parts build under Cygwin with parts build under Linux or BSD (which use the ELF target by default). (Hint: You have to build a GCC Cross-Compiler...)

Operating Systems that use it: Windows 95/98/NT, the Mobius.


additionnal resources

  • MSDN documentation about PE format

ELF

Included from ElfBinaries

The ELF (Executable Linkable Format) was designed by SUN for use in their Unix clone. A very versatile file format, it was later picked up by many other operating systems for use as both executable files and as shared library files. It does distinguish between TEXT, DATA and BSS.

Documentation on ELF can be obtained e.g. at http://www.linuxbase.org/spec/refspecs/elf/, ftp://tsx.mit.edu/pub/linux/packages/GCC/ELF.doc.tar.gz, or various other sources.

Today, ELF is considered the standard format on Unix-alike systems. While it has some drawbacks (e.g., using up one of the scarce general purpose registers of the IA32 when using position-independent code), it is well supported and documented.

Operating Systems that use it: Solaris, IRIX and IRIX64, Linux, *BSD, many many others...

A.OUT

A.OUT is the "original" binary format for Unix machines. It is considered obsolete today because of several shortcomings. However, as it is extremely simple and supported by many compilers/assemblers, it may be a good choice if you're willing to develop your own format or have more information than 'raw binary' for your bootloader.