Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ a.out(5) — UNIX 32V

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:

/*
 * Format of an a.out header
 */
 
structexec {/* a.out header */
inta_magic; /* magic number */
unsigneda_text;/* size of text segment */
unsigneda_data;/* size of initialized data */
unsigneda_bss;/* size of uninitialized data */
unsigneda_syms;/* size of symbol table */
unsigneda_entry;/* entry point */
unsigneda_trsize;/* size of text relocation */
unsigneda_drsize;/* size of data relocation */
};
 #defineA_MAGIC10407 /* normal */
#defineA_MAGIC20410 /* read-only text */
#defineA_MAGIC30411 /* separated I&D */
#defineA_MAGIC40405 /* overlay */
 structnlist { /* symbol table entry */
charn_name[8];/* symbol name */
charn_type;/* type flag */
charn_other;
shortn_desc;
unsigned n_value;/* value */
};
 /* values for type flag */
#defineN_UNDF0/* undefined */
#defineN_ABS02/* absolute */
#defineN_TEXT04/* text */
#defineN_DATA06/* data */
#defineN_BSS08
#defineN_TYPE037
#defineN_FN037/* file name symbol */
 #defineN_GSYM0040 /* global sym: name,,type,0 */
#defineN_FUN0044/* function: name,,linenumber,address */
#defineN_STSYM 0046/* static symbol: name,,type,address */
#defineN_RSYM0100/* register sym: name,,register,offset */
#defineN_SLINE0104/* src line: ,,linenumber,address */
#defineN_SSYM0140/* structure elt: name,,type,struct_offset */
#defineN_SO0144/* source file name: name,,,address */
#defineN_LSYM0200/* local sym: name,,type,offset */
#defineN_SOL0204/* #line source filename: name,,,address */
#defineN_PSYM0240/* parameter: name,,type,offset */
#defineN_LBRAC0300 /* left bracket: ,,nesting level,address */
#defineN_RBRAC0340 /* right bracket: ,,nesting level,address */
#defineN_LENG0376/* second stab entry with length information */
 #defineN_EXT01/* external bit, or’ed in */
 #defineFORMAT"%08x"
 #defineSTABTYPES0340

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 loaded into core for execution, 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, the data segment begins at the first 0 mod 512 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. 

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).

The start of the text segment in the file is 32(10); the start of the data segment is 32+a_text; the start of the text relocation is 32+a_text+a_data; the start of the data relocation is 32+a_text+a_data+a_trsize; the start of the symbol table is 32+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 six bytes per relocatable dataum.  There is no relocation information if a_trsize+a_drsize==0.  The relocation information is structured as

struct relocation_info {
long address; /* relative to current segment */
short pcrel:1, /* if so, segment offset has already */
/* been subtracted */
  length:2, /* 0=byte, 1=word, 2=long */
  extern:1, /* does not include value */
/* of symbol referenced */
  offset:1, /* already includes origin */
/* of this segment (?) */
  symbolnum:11;
/* if extern then symbol table */
/* ordinal (0, 1, 2, ...) else */
/* segment number (same as symbol types) */
};

SEE ALSO

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

7th Edition  —  UNIX/32V

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