Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ a.out(5) — Ultrix-11 3.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

as(1)

ld(1)

nm(1)

a.out(5)

NAME

a.out − assembler and link editor output

SYNTAX

#include <a.out.h>

DESCRIPTION

The a.out file 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 PDP11 is:

#ifndef __NLIST__
#include <nlist.h>
#endif  __NLIST__
 struct  exec { /* a.out header */
        int          a_magic;  /* magic number */
        unsigned     a_text;   /* size of text segment */
        unsigned     a_data;   /* size of initialized data */
        unsigned     a_bss;    /* size of unitialized data */
        unsigned     a_syms;   /* size of symbol table */
        unsigned     a_entry;  /* entry point */
        unsigned     a_unused; /* S/A program flags (SEE BELOW) */
        unsigned     a_flag;   /* relocation info stripped */
};
 #define  NOVL     7
 struct  ovlhdr {
        int          max_ovl;      /* maximum ovl size */
        unsigned     ov_siz[NOVL]; /* size of i’th overlay */
};
 /*                  0401  /* ULTRIX-11 S/A programs (SEE BELOW) */
#define A_MAGIC1    0407  /* normal (I space only) */
#define A_MAGIC2    0410  /* read-only/shared text */
#define A_MAGIC3    0411  /* separated I&D */
#define A_MAGIC4    0405  /* overlay (NOT USED) */
#define A_MAGIC5    0430  /* overlay text kernel */
#define A_MAGIC6    0430  /* user overlay (shared text) */
#define A_MAGIC7    0431  /* user overlay (separated I&D) */
#define A_MAGIC8    0450  /* overlay kernel */
#define A_MAGIC9    0451  /* overlay kernel (separated I&D) */
 /*
 * New magic number and some flags, used by
 * ULTRIX-11 boot and stand alone programs.
 * Flags are set in the a_unused element of the
 * a.out header after the program is stripped.
 */
 #defineSA_MAGIC     0401  /* ULTRIX-11 stand alone program */
#defineSA_SCSEG     0001  /* program needs syscall segment */
#defineSA_BOOT      0002  /* identifies BOOT program */
#defineSA_SDLOAD    0004  /* identifies SDLOAD program */
#defineSA_RABADS    0010  /* identifies RABADS program */
#defineSA_SYSCALL   0020  /* identifies SYSCALL segment */
 /*
 * Macros which take exec structures as arguments and tell
 * whether file has reasonable magic number or offset to text.
 */
#defineN_BADMAG(x) \
   (((x).a_magic)!=A_MAGIC1 && ((x).a_magic)!=A_MAGIC2 && \
     ((x).a_magic)!=A_MAGIC3 && ((x).a_magic)!=A_MAGIC4 && \
     ((x).a_magic)!=A_MAGIC5 && ((x).a_magic)!=A_MAGIC6 && \
     ((x).a_magic)!=A_MAGIC7 && ((x).a_magic)!=A_MAGIC8 && \
     ((x).a_magic)!=A_MAGIC9 && ((x).a_magic)!=SA_MAGIC)
 /* BADMAG is SYSTEM V name for ULTRIX-11 N_BADMAG */
#defineBADMAG(x) N_BADMAG(x)
 #define N_OVMAG(x)
   (((x).a_magic)==A_MAGIC5 || ((x).a_magic)==A_MAGIC6 ||
     ((x).a_magic)==A_MAGIC7)
 #define N_KOVMAG(x)
   (((x).a_magic)==A_MAGIC8 || ((x).a_magic)==A_MAGIC9)
 #defineN_TXTOFF(x)
  (N_OVMAG(x)  ? sizeof (struct ovlhdr) + sizeof (struct exec) :
  N_KOVMAG(x) ? sizeof (struct ovlhdr)*2 + sizeof (struct exec) :
                 sizeof (struct exec))

The file has four sections: a header, the program and data text, 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 the 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, but are even.  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 data), 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 8K 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.  If the magic number is 411, the text segment is again pure, write-protected, and shared, and moreover instruction and data space are separated; the text and data segment both begin at location 0.  If the magic number is 0405, the text segment is overlaid on an existing (0411 or 0405) text segment and the existing data segment is preserved. 

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

The start of the text segment in the file is 020(8); the start of the data segment is 020+St (the size of the text) the start of the relocation information is 020+St+Sd; the start of the symbol table is 020+2(St+Sd) if the relocation information is present, 020+St+Sd if not. 

The layout of a symbol table entry and the principal flag values that distinguish symbol types are given in the include file.  Other flag values may occur if an assembly language program defines machine instructions. 

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

The value of a word in the text or data portions which is not a reference to an undefined external symbol is exactly that value which will appear in core 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 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 into the word in the file. 

If relocation information is present, it amounts to one word per word of program text or initialized data.  There is no relocation information if the ’relocation info stripped’ flag in the header is on. 

Bits 3-1 of a relocation word indicate the segment referred to by the text or data word associated with the relocation word:

000 Absolute number

002 Reference to text segment

004 Reference to initialized data

006 Reference to uninitialized data (bss)

010 Reference to undefined external symbol

Bit 0 of the relocation word indicates, if 1, that the reference is relative to the pc (for example, ’clr x’); if 0, that the reference is to the actual symbol (for example, ’clr *$x’). 

The remainder of the relocation word (bits 15-4) contains a symbol number in the case of external references, and is unused otherwise.  The first symbol is numbered 0, the second 1, and so on. 

SEE ALSO

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

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