Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ a.out(5) — UNIX System III

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

as(1)

ld(1)

nm(1)

strip(1)

A.OUT(5)  —  UNIX 3.0

NAME

a.out − assembler and link editor output

DESCRIPTION

A.out is the output file of the assembler as and the link editor ld. Both programs will make a.out executable if there were no errors in assembling or linking, and no unresolved external references. 

This file has four sections: a header, the program text and data segments, relocation information, and a symbol table (in that order).  The last two sections may be missing if the program was linked with the −s option of ld(1) or if the symbol table and relocation bits were removed by strip(1). Also note that if there were no unresolved external references after linking, the relocation information will be removed.

The sizes of each segment (contained in the header, discussed below) are in bytes and are even.  The size of the header is not included in any of the other sizes. 

When an a.out file is loaded into memory for execution, three logical segments are set up: the text segment, the data segment (initialized data followed by uninitialized, the latter actually being initialized to all 0’s), and a stack.  The text segment begins at location 0 in the core image; the header is not loaded.  If the magic number (the first field in the header) is 407 (octal), it indicates that the text segment is not to be write-protected or shared, so the data segment will be contiguous with the text segment.  If the magic number is 410 (octal), the data segment begins at the first 0 mod 8K byte boundary on the PDP-11, or the first 0 mod 512 byte boundary on the VAX-11/780 following the text segment, and the text segment is not writable by the program; if other processes are executing the same a.out file, they will share a single text segment.  If the magic number is 411 (octal) ( PDP-11 only), the text segment is again pure (write-protected and shared) and, moreover, the instruction and data spaces are separated; the text and data segment both begin at location 0.  See the PDP-11/70 Processor Handbook for restrictions that apply to this situation. 

The stack will occupy the highest possible locations in the core image: from 177776 (octal) on the PDP-11 or 80000000 (hexidecimal) on the VAX-11/780, and growing downwards.  The stack is automatically extended as required.  The data segment is only extended as requested by the brk(2) system call.

The start of the text segment in the a.out file is hsize; the start of the data segment is hsize+St (the size of the text), where hsize is 20 (octal) on the PDP-11 and 20 (hexidecimal) on the VAX-11/780. 

The value of a word in the text or data portions that is not a reference to an undefined external symbol is exactly the value that will appear in memory when the file is executed.  If a word in the text or data portion involves a reference to an undefined external symbol, as indicated by the relocation information (discussed below) for that word, then the value of the word as 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 word in the file. 

Header−PDP-11

The format of the a.out header for the PDP-11 is as follows:

structexec{
shorta_magic;/∗ magic number ∗/
unsigneda_text;/∗ size of text segment ∗/
unsigneda_data;/∗ size of data segment ∗/
unsigneda_bss;/∗ size of bss segment ∗/
unsigneda_syms;/∗ size of symbol table ∗/
unsigneda_entry;/∗ entry point of program ∗/
unsigneda_stamp;/∗ version stamp ∗/
unsigneda_flag;/∗ set if relocation info stripped ∗/
};

Header−VAX-11/780

The format of the header on the VAX-11/780 is as follows:

structexec{
shorta_magic;/∗ magic number ∗/
shorta_stamp;/∗ version stamp ∗/
unsigneda_text;/∗ size of text segment ∗/
unsigneda_data;/∗ size of data segment ∗/
unsigneda_bss;/∗ size of bss segment ∗/
unsigneda_syms;/∗ size of symbol table ∗/
unsigneda_entry;/∗ entry point of program ∗/
unsigneda_trsize;/∗ size of text relocation info ∗/
unsigneda_drsize;/∗ size of data relocation info ∗/
};

Relocation−PDP-11

If relocation information is present, it amounts to two bytes per relocatable datum.  There is no relocation information if the “suppress relocation” flag (a_flag) in the header is on.

The format of the relocation data is:

structr_info{
intr_symbolnum:11,
r_segment:3,
r_pcrel:1;
};

The r_pcrel field indicates, if on, that the reference is relative to the program counter (pc) register (e.g., clr x); if off, that the reference is to the actual symbol (e.g., clr ∗$x). 

The r_segment field indicates the segment referred to by the text or data word associated with the relocation word:

00 indicates the reference is absolute;

02 indicates the reference is to the text segment;

04 indicates the reference is to initialized data;

06 indicates the reference is to bss (uninitialized data);

10 indicates the reference is to an undefined external symbol. 

The field r_symbolnum contains a symbol number in the case of external references, and is unused otherwise.  The first symbol is numbered 0, the second 1, etc. 

Relocation−VAX-11/780

If relocation information is present, it amounts to eight bytes per relocatable datum.  There are no relocation bits if a_trsize+a_drsize==0. The format of the relocation information is:

structr_info{
longr_address;
intr_symbolnum:24,
r_pcrel:1,
r_length:2,
r_extern:1,
r_offset:1,
r_pad:3;
};

The r_address field gives the location of the relocatable reference relative to the segment in which it is defined.  The r_symbolnum field contains a symbol number in the case of an external; otherwise it contains a segment number (expressed in the same manner as the VAX-11/780 symbol types above).  R_pcrel has the same meaning as on the PDP-11.  R_length indicates the length of the relocatable reference:

0 byte

1 word

2 long

The start of the relocation information (on the PDP-11 and the VAX-11/780) is:

hsize+a_text+a_data

Symbol Table−PDP-11

The symbol table on the PDP-11 consists of entries of the form:

structnlist{
charn_name[8];
intn_type;
unsignedn_value;
};

The n_name field contains the ASCII name of the symbol, null-padded.  The n_type field indicates the type of the symbol; the following values are possible:

00 undefined symbol

01 absolute symbol

02 text segment symbol

03 data segment symbol

04 bss segment symbol

37 file name symbol (produced by ld)

40 undefined external symbol

41 absolute external symbol

42 text segment external symbol

43 data segment external symbol

44 bss segment external symbol

The start of the symbol table on the PDP-11 is:

hsize+2(a_text+a_data)

if relocation information is present, and

hsize+a_text+a_data

if it is not. 

Symbol Table−VAX-11/780

The symbol table on the VAX consists of entries of the form:

structnlist{
charn_name[8];
charn_type;
charn_other;
shortn_desc;
unsignedn_value;
};

The possible values for n_type are:

00 undefined symbol

02 absolute symbol

04 text segment symbol

06 data segment symbol

08 bss segment symbol

37 file name symbol (produced by ld(1))

40 undefined external symbol

42 absolute external symbol

44 text segment external symbol

46 data segment external symbol

48 bss segment external symbol

The start of the symbol table on the VAX is:

hsize+a_text+a_data+ a_trsize+a_drsize

If a symbol’s type (on either the PDP-11 or the VAX-11/780) is undefined external and the value field is non-zero, the symbol is interpreted by the link editor ld(1) as the name of a common region whose size is indicated by the value of the symbol.

SEE ALSO

as(1), ld(1), nm(1), strip(1). 

May 16, 1980

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