Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ a.out(5) — UNIX 3BSD

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

as(1)

ld(1)

nm(1)

A.OUT(5)  —  Unix Programmer’s Manual

NAME

a.out − assembler and link editor output

SYNOPSIS

#include <a.out.h>

DESCRIPTION

A.out is the output file of the assembler as(1) and the link editor ld(1). Both programs make a.out executable if there were no errors and no unresolved external references.  Layout information as given in the include file for the VAX-11 is:

The file has four sections: a header, the program text and data, relocation information, and a symbol table (in that order).  The last two may be empty if the program was loaded with the ‘−s’ option of ld or if the symbols and relocation have been removed by strip(1).

In the header the sizes of each section are given in bytes.  The size of the header is not included in any of the other sizes. 

When an a.out file is executed, three logical segments are set up: the text segment, the data segment (with uninitialized data, which starts off as all 0, following initialized), and a stack.  The text segment begins at 0 in the core image; the header is not loaded.  If the magic number in the header is 0407(8), it indicates that the text segment is not to be write-protected and shared, so the data segment is immediately contiguous with the text segment.  If the magic number is 0410 (or 0413), the data segment begins at the first 0 mod 1024 byte boundary following the text segment, and the text segment is not writable by the program; if other processes are executing the same file, they will share the text segment.  For 0413 format, the text segment begins at a 0 mod 1024 byte boundary in the a.out file, the remaining bytes after the header in the first block are reserved and should be zero.  In this case the text and data sizes must both be multiples of 1024 bytes, and the pages of the file will be brought into the running image as needed, and not pre-loaded as with the other formats.  This is especially suitable for very large programs (see the −z option of ld(1).)

The stack will occupy the highest possible locations in the core image: growing downwards from 80000000(16).  The stack is automatically extended as required.  The data segment is only extended as requested by break(2).

Let hsiz be 32(10) for all formats but 0413, and 1024 for 0413 format.  The start of the text segment in the file is hsiz; the start of the data segment is hsiz+a_text; the start of the text relocation is hsiz+a_text+a_data; the start of the data relocation is hsiz+a_text+a_data+a_trsize; the start of the symbol table is hsiz+a_text+a_data+a_trsize+a_drsize. 

The layout of a symbol table entry and the principal flag values that distinguish symbol types are given in the include file. 

If a symbol’s type is undefined external, and the value field is non-zero, the symbol is interpreted by the loader ld as the name of a common region whose size is indicated by the value of the symbol. 

The value of a byte in the text or data which is not a portion of a reference to an undefined external symbol is exactly that value which will appear in memory when the file is executed.  If a byte in the text or data involves a reference to an undefined external symbol, as indicated by the relocation information, then the value stored in the file is an offset from the associated external symbol.  When the file is processed by the link editor and the external symbol becomes defined, the value of the symbol will be added to the bytes in the file. 

If relocation information is present, it amounts to eight bytes per relocatable datum.  There is no relocation information if a_trsize+a_drsize==0.  The relocation information is structured as

struct relocation_info {
  long  r_address;/∗ relative to current segment ∗/
  long  r_pcrel:1, /∗ if so, segment offset has already ∗/
/∗ been subtracted ∗/
  r_length:2,/∗ 0=byte, 1=word, 2=long ∗/
  r_extern:1,/∗ does not include value ∗/
/∗ of symbol referenced ∗/
  r_offset:1,/∗ already includes origin ∗/
/∗ of this segment (?) ∗/
r_pad:3,/∗ nothing, yet ∗/
  r_symbolnum:24;
/∗ if extern then symbol table ∗/
/∗ ordinal (0, 1, 2, ...) else ∗/
/∗ segment number (same as symbol types) ∗/
};

SEE ALSO

as(1), ld(1), nm(1)

3rd Berkeley Distribution  —  VAX/11

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026