3BSD/usr/man/man5/a.out.5

Compare this file to the similar file:
Show the results in this format:

.TH A.OUT 5 VAX/11
.UC
.SH NAME
a.out \- assembler and link editor output
.SH SYNOPSIS
.B #include <a.out.h>
.SH DESCRIPTION
.I A.out
is the output file of the assembler
.IR as (1)
and the link editor
.IR ld (1).
Both programs make
.I 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:
.PP
.nf
.ta 8n +9n +11n
.PP
.so /usr/include/a.out.h
.fi
.PP
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
.I ld
or if the symbols and relocation have been
removed by
.IR strip (1).
.PP
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.
.PP
When an
.I 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
.I 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
.B \-z
option of
.IR ld (1).)
.PP
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
.IR break (2).
.PP
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.
.PP
The layout of a symbol table entry and the principal flag values
that distinguish symbol types are given in the include file.
.PP
If a symbol's type is undefined external,
and the value field is non-zero,
the symbol is interpreted by the loader
.I ld
as
the name of a common region
whose size is indicated by the value of the
symbol.
.PP
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.
.PP
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
.nf
.ta 8n 16n 24n 32n 40n 48n
.PP
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) */
};
.fi
.SH "SEE ALSO"
as(1), ld(1), nm(1)