On 5/27/22, Warner Losh <imp(a)bsdimp.com> wrote:
People working on emulators run into these issues all the time as well.
There was a greater diversity of object formats when Unix was younger
as well, most have been displaced by ELF (PECOFF being the only exception
that's still around outside of Windows).
The object formats that I'm aware of on Unix are:
a.out - comes in three flavors:
OMAGIC - executable instructions (text) and static data in the same section
NMAGIC - text separate from data; shared text
ZMAGIC - text separate from data; demand paged
MACH-O - Object and executable format for the MACH microkernel. This
is still the object format used by the Mac OS X operating system,
which IIRC was built by placing FreeBSD Unix on top of the MACH
microkernel. It allows more than the three sections (.text, .data,
.bss) in a.out.
COFF - Common Object File Format. Allows up to 64 object fsections.
ELF - Executable and Linkable Format. Much more uniform (everything
is a section) than its predecessors, and allows essentially an
arbitrary number of sections. In addition to its use on Unix, this is
the object file and executable format used by Linux and OpenVMS (on
Itanium and x86).
Are there others?
PECOFF, Portable Executable and Common Object File Format, is the
object file and executable format used by Microsoft Windows. It is a
derivative of COFF, but, in typical Microsoft embrace-and-extend
fashion, there are significant differences. When Windows NT was
ported to the DEC Alpha processor, I had to add PECOFF support to
DEC's GEM compiler back end. I started by adding conditional code to
the existing COFF support, but I found that PECOFF differed enough
from vanilla COFF that it was easier and more maintainable to fork off
a separate module for it.
-Paul W.