Introduction
a.out, short for “assembler output”, is the executable and object file format of early Unix. It takes its name from the file the assembler and the C compiler write when no output name is given. The BSDs and early Linux used it for programs, libraries and object files until the late 1990s or early 2000s, when it gave way to ELF, which can describe shared libraries and many sections far more easily. Modern Linux no longer runs a.out programs.
Compilers still name their output a.out by default, but on today’s
systems that file is an ELF or Mach-O program; only
the name is left.
Structure
An a.out file starts with a short header: on 32-bit systems, eight 32-bit words. The
first is the magic number, which also says how the program is loaded: octal
0407 (OMAGIC) for a program whose code may be written to,
0410 (NMAGIC) for read-only code that can be shared, and
0413 (ZMAGIC) for a program paged in from the file on demand. On the
PDP-11, 0407 was also the instruction to jump over the header. The other
words give the sizes of the text (code), the data, the zero-filled BSS area, the
symbol table and the two relocation tables, and the entry point.
0x00a_magic: 0407, 0410 or 0413 (octal)4 bytes0x04a_text, a_data, a_bss sizes12 bytes0x10a_syms symbol table size, a_entry entry point8 bytes0x18a_trsize, a_drsize: text and data relocation sizes8 bytes0x20text, then datavaries…text relocations, data relocationsvaries…symbol table, then the string tablevaries
Links
Software
- GNU Binutils, whose
objdumpandnmread a.out files when built with support for them (Linux, macOS, Windows) - IDA Pro (Windows, macOS, Linux)
Reference
- a.out(5), the FreeBSD manual page for the format