On Sat, May 28, 2022 at 9:30 AM Paul Winalski <paul.winalski@gmail.com> wrote:
On 5/27/22, Warner Losh <imp@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
 
bsd 2.11 has 6 different magic numbers. The three extra are one flavor of overlays that does the itself, and two flavor that do it automatically (I've not plumbed the depths of the code to know what that means) with separate I&D and one without.
 
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.

HP-UX had a weird form of COFF in the early days. IBM AIX had its own thing that wasn't quite COFF, nor was it quite a.out. Apollo also had a variation on COFF that wasn't quite standard. I wrote a symbol mangler for all of these in the early 90s and each one was its own special snowflake.
 
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.

pecoff is also used for UEFI binaries... Though the subset that's used tends
to be smaller than what windows itself uses. 

Warner