


      AAAA....OOOOUUUUTTTT((((4444))))                    ((((bbbbssssdddd 4444....2222))))                    AAAA....OOOOUUUUTTTT((((4444))))



      NNNNAAAAMMMMEEEE
           a.out - assembler and link editor output

      SSSSYYYYNNNNTTTTAAAAXXXX
           ####iiiinnnncccclllluuuuddddeeee <<<<aaaa....oooouuuutttt....hhhh>>>>

      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
           _A._o_u_t is the output file of the assembler _a_s(1) and the link
           editor _l_d(1).  Both programs make _a._o_u_t executable if there
           were no errors and no unresolved external references.
           Layout information as given in the include file for the
           Ridge is:

           /*
            * Header prepended to each a.out file.
            */
           struct exec {
                unsigned long   a_magic; /* magic number */
                unsigned short  r_brofsett;   /* offset for previous magic */
                unsigned short a_type;        /* type field  */
                unsigned long  a_version;     /* version field */
                unsigned long   a_text;       /* size of text segment */
                unsigned long   a_data;       /* size of initialized data */
                unsigned long   a_bss;        /* size of uninitialized data */
                unsigned long   a_syms;       /* size of symbol table */
                unsigned long   a_entry; /* entry point */
                unsigned long   a_trsize;     /* size of text relocation */
                unsigned long   a_drsize;     /* size of data relocation */
           };

           #define RMAGIC  0x9b000000              /* Ridge magic */
           #define RMAGIC1 0x9b010000         /* Ridge magic - shared code & data */
           #define NEWHDR  (sizeof (struct exec))  /* header size */

           /*
            * Macros which take exec structures as arguments and tell
           whether
            * the file has a reasonable magic number or offsets to
           text, symbols, or strings.
            * A check has been added to make sure that the header is an
           exec struct.
            */
           #define N_BADMAG(x) .
                ((((x).a_magic & 0xff000000) != RMAGIC) ||
                ((x).r_brofsett != NEWHDR) ||
                ((x).a_type == 0) ||
                ((x).a_version == 0))

           #define N_TXTOFF(x)      (sizeof (struct exec))
           #define N_SYMOFF(x)      (N_TXTOFF(x) + (x).a_text+(x).a_data + (x).a_trsize+(x).a_drsize)
           #define N_STROFF(x)      (N_SYMOFF(x) + (x).a_syms)




      Page 1                                                   (9010-E)






      AAAA....OOOOUUUUTTTT((((4444))))                    ((((bbbbssssdddd 4444....2222))))                    AAAA....OOOOUUUUTTTT((((4444))))



           The file has five sections:  a header, the program text and
           data, relocation information, a symbol table and a string
           table (in that order).  The last three may be omitted if the
           program was loaded with the `-s' option of _l_d or if the
           symbols and relocation have been removed by _s_t_r_i_p(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 executed, two physical segments are
           set up: the code and data segments.

           The code segment begins at location 0, and consists of the
           program header and the text segment from the a.out file.
           This is the executable code of the program.

           The data segment consists of initialized data, unisitialized
           data (bss), and a runtime stack.  Normally, initialized data
           begins at location 0 of the data segment, and is copied from
           the a.out file to the data segment when the program begins
           execution.  The initialized data is immediately followed by
           uninitialized data (bss).  Uninitialized data starts out as
           all zeros. The runtime stack begins at the highest possible
           location and grows downward.

           The stack will occupy the highest possible locations in the
           data segment: growing downwards.  The stack is automatically
           extended as required.  The data/bss area is only extended as
           requested by _b_r_k(2).

           After the header in the file follow the text, data, text
           relocation data relocation, symbol table and string table in
           that order.  The text begins immediately after the header.
           The N_TXTOFF macro returns this absolute file position when
           given the name of an exec structure as argument. Initialized
           data is contiguous with the text and immediately followed by
           the text relocation and then the data relocation
           information.  The symbol table follows all this; its
           position is computed by the N_SYMOFF macro.  Finally, the
           string table immediately follows the symbol table at a
           position which can be gotten easily using N_STROFF.  The
           first 4 bytes of the string table are not used for string
           storage, but rather contain the size of the string table;
           this size INCLUDES the 4 bytes, the minimum string table
           size is thus 4.

           The layout of a symbol table entry and the principal flag
           values that distinguish symbol types are given in the
           include file ////uuuussssrrrr////iiiinnnncccclllluuuuddddeeee////aaaa....oooouuuutttt....hhhh as follows:

           /*



      Page 2                                                   (9010-E)






      AAAA....OOOOUUUUTTTT((((4444))))                    ((((bbbbssssdddd 4444....2222))))                    AAAA....OOOOUUUUTTTT((((4444))))



            * Format of a symbol table entry; this file is included by <a.out.h>
            * and should be used if you aren't interested the a.out header
            * or relocation information.
            */
           struct  nlist {
                union {
                     char *n_name;  /* for use when in-core */
                     long n_strx;        /* index into file string table */
                } n_un;
                unsigned char n_type;         /* type flag, i.e. N_TEXT etc; see below */
                char n_other;       /* unused */
                short     n_desc;             /* see <stab.h> */
           unsigned long   n_value;      /* value of this symbol (or dbx offset) */
           };
           #define        n_hash    n_desc    /* used internally by ld */

           /*
            * Simple values for n_type.
            */
           #define    N_UNDF   0x0  /* undefined */
           #define    N_ABS    0x2  /* absolute */
           #define    N_TEXT   0x4  /* text */
           #define    N_DATA   0x6  /* data */
           #define    N_BSS    0x8  /* bss */
           #define    N_COMM   0x12 /* common (internal to ld) */
           #define    N_FN     0x1f /* file name symbol */

           #define    N_EXT    01   /* external bit, or'ed in */
           #define    N_TYPE   0x1e /* mask for all the type bits */

           /*
            * Dbx entries have some of the N_STAB bits set.
            * These are given in <stab.h>
            */
           #define N_STAB  0xe0     /* if any of these bits set, a Dbx entry */

           /*
            * Format for namelist values.
            */
           #define N_FORMAT    "%08x"

           In the _a._o_u_t file a symbol's n_un.n_strx field gives an
           index into the string table.  A n_strx value of 0 indicates
           that no name is associated with a particular symbol table
           entry.  The field n_un.n_name can be used to refer to the
           symbol name only if the program sets this up using n_strx
           and appropriate data from the string table.

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



      Page 3                                                   (9010-E)






      AAAA....OOOOUUUUTTTT((((4444))))                    ((((bbbbssssdddd 4444....2222))))                    AAAA....OOOOUUUUTTTT((((4444))))



           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 eight
           bytes per relocatable datum as in the following structure:

           /*
            * Format of a relocation datum.
            */
           struct relocation_info {
                int  r_address;     /* address which is relocated */
           unsigned int   r_symbolnum:24,     /* local symbol ordinal */
                     r_pcrel:1,     /* was relocated pc relative already */
                     r_length:2,    /* 0=byte, 1=word, 2=long */
                     r_extern:1,    /* does not include value of sym referenced */
                     r_relocate:4;  /* 1 => ridge specific load or laddr, fixup */
           };


           There is no relocation information if a_trsize+a_drsize==0.
           If r_extern is 0, then r_symbolnum is actually a n_type for
           the relocation (i.e. N_TEXT meaning relative to segment text
           origin.)

      SSSSEEEEEEEE AAAALLLLSSSSOOOO
           as(1), ld(1), nm(1), dbx(1), stab(4), strip(1), map(1)





















      Page 4                                                   (9010-E)



