Seventh Edition Unix on the PDP-11 used a 16-bit form of a.out, described in
its a.out(5) manual page. Numbers below are octal, as in the manual. The
header has eight fields in 020 (16) bytes, so each field is a 16-bit word, and the
symbol entries use the same word size.
Header
| Offset (octal) | Size | Field | Meaning |
|---|---|---|---|
00 | 2 | a_magic | Magic number, below. |
02 | 2 | a_text | Size of the text segment. |
04 | 2 | a_data | Size of the initialised data. |
06 | 2 | a_bss | Size of the uninitialised data. |
010 | 2 | a_syms | Size of the symbol table. |
012 | 2 | a_entry | Entry point. |
014 | 2 | a_unused | Not used. |
016 | 2 | a_flag | Set if the relocation information has been stripped. |
Sizes are in bytes, always even, and do not include the header.
Magic numbers
| Octal | Meaning |
|---|---|
0407 | Normal: the text is not write-protected or shared, and the data follows the text directly. |
0410 | Read-only text shared between processes; the data starts at the next 8K boundary after the text. |
0411 | Separate instruction and data spaces: the text is pure and shared, and text and data both start at address 0. |
0405 | Overlay: the text replaces that of a running 0411 or 0405 program, and the data segment is kept. |
Layout
Header, text, data, relocation, symbol table. The relocation and symbol parts may
be empty after ld -s or strip(1). With St the text
size and Sd the data size:
| Part | File offset (octal) |
|---|---|
| text | 020 |
| data | 020 + St |
| relocation | 020 + St + Sd |
| symbol table | 020 + 2(St + Sd) with relocation, 020 + St + Sd without |
The header is not loaded into memory. The text starts at address 0; uninitialised
data follows initialised data and starts as zeros. The stack starts at the top of the
address space (0177776) and grows down.
Relocation words
There is one 16-bit relocation word for each word of text and initialised data, so the relocation part is as long as text and data together.
| Bits | Meaning |
|---|---|
| 0 | 1: the reference is PC-relative; 0: a reference to the actual symbol. |
| 3–1 | Segment, as the value of the word with bit 0 clear: 00 absolute number, 02 text segment, 04 initialised data, 06 BSS, 010 undefined external. |
| 15–4 | For an external reference, the symbol’s number in the symbol table (from 0); unused otherwise. |
Symbol table
| Offset | Size | Field | Meaning |
|---|---|---|---|
0 | 8 | n_name | Name, 8 characters. |
8 | 2 | n_type | Type, below. |
10 | 2 | n_value | Value. |
| Octal | Name | Meaning |
|---|---|---|
0 | N_UNDF | undefined |
01 | N_ABS | absolute |
02 | N_TEXT | text symbol |
03 | N_DATA | data symbol |
04 | N_BSS | BSS symbol |
024 | N_REG | register name |
037 | N_FN | file name symbol |
037 | N_TYPE | mask for the type bits |
040 | N_EXT | external bit, ORed in |
An undefined external symbol with a non-zero value is taken by ld as a
common area of that size.
Sources
The Seventh Edition a.out(5) manual page, as reproduced at
typewritten.org.
The byte order of the 16-bit words is not stated on the page.