A.OUT (V)                    3/15/72                    A.OUT (V)

NAME            a.out  --   assembler and link editor output


        a.out is the output file of the assembler as and the link

        editor ld.  In both cases, a.out may be executed provided

        there were no errors and no unresolved external refer-


        This file has four sections: a header, the program and

        data text, a symbol table, and relocation bits (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.

        The header always contains 8 words:

           1  A magic number (407(8))

           2  The size of the program text segment

           3  The size of the initialized data segment

           4  The size of the uninitialized (bss) segment

           5  The size of the symbol table

           6  The entry location (always 0 at present)

           7  The stack size required (0 at present)

           8  A flag indicating relocation bits have been sup-


        The sizes of each segment are in bytes but are even.  The

        size of the header is not included in any of the other


        When a file produced by the assembler or loader is loaded

        into core for execution, three segments are set up: the

        text segment, the data segment, and the bss (uninitial-

        ized data) segment, in that order.  The text segment be-

        gins at the lowest location in the core image; the header

        is not loaded.  The data segment begins immediately after

        the text segment, and the bss segment immediately after

        the data segment.  The bss segment is initialized by 0's.

        In the future the text segment will be write-protected

        and shared.

        The start of the text segment in the file is 20(8); the

        start of the data segment is 20+S  (the size of the text)
        the start of the relocation information is 20+S +S ; the
                                                       t  d
        start of the symbol table is 20+2(S +S ) if the reloca-
                                           t  d
        tion information is present, 20+S +S  if not.
                                         t  d

        The symbol table consists of 6-word entries.  The first

        four contain the ASCII name of the symbol, null-padded.

        The next word is a flag indicating the type of symbol.

        The following values are possible:

           00  undefined symbol

           01  absolute symbol

           02  text segment symbol

           03  data segment symbol

           04  bss segment symbol

           40  undefined external (.globl) symbol

           41  absolute external symbol

           42  text segment external symbol

           43  data segment external symbol

           44  bss segment external symbol

        Values other than those given above may occur if the user

        has defined some of his own instructions.

        The last word of a symbol table entry contains the value

        of the symbol.

        If the 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 word in the text or data portions which is

        not a reference to an undefined external symbol is ex-

        actly that value which will appear in core when the file

        is executed.  If a word in the text or data portion in-

        volves a reference to an undefined external symbol, as

        indicated by the relocation bits 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 pro-

        cessed 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 "suppress relocation"

        flag in the header is on.

        Bits 3-1 of a relocation word indicate the segment re-

        ferred 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 the data segment

          06  indicates the reference is to the bss segment

          10  indicates the reference is to an undefined external


        Bit 0 of the relocation word indicates if on that the

        reference is relative to the pc (e.g. "clr x"); if off,

        the reference is to the actual symbol (e.g., "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, etc.

SEE ALSO        as, ld, strip, nm, un(I)