Annotation of 43BSDReno/share/man/man5/a.out.5, revision 1.1

1.1     ! root        1: .\" Copyright (c) 1980 Regents of the University of California.
        !             2: .\" All rights reserved.  The Berkeley software License Agreement
        !             3: .\" specifies the terms and conditions for redistribution.
        !             4: .\"
        !             5: .\"    @(#)a.out.5     6.2 (Berkeley) 5/19/86
        !             6: .\"
        !             7: .TH A.OUT 5 "May 19, 1986"
        !             8: .UC 4
        !             9: .SH NAME
        !            10: a.out \- assembler and link editor output
        !            11: .SH SYNOPSIS
        !            12: .B #include <a.out.h>
        !            13: .SH DESCRIPTION
        !            14: .I A.out
        !            15: is the output file of the assembler
        !            16: .IR as (1)
        !            17: and the link editor
        !            18: .IR ld (1).
        !            19: Both programs make
        !            20: .I a.out
        !            21: executable if there were no
        !            22: errors and no unresolved external references.
        !            23: Layout information as given in the include file for the VAX-11 is:
        !            24: .nf
        !            25: .ta \w'#define  'u +\w'unsigned  'u +\w'a_dirsize  'u +4n
        !            26: .PP
        !            27: /*
        !            28: .ti +\w'/'u
        !            29: * Header prepended to each a.out file.
        !            30: .ti +\w'/'u
        !            31: */
        !            32: struct exec {
        !            33:        long    a_magic;        /* magic number */
        !            34:        unsigned        a_text; /* size of text segment */
        !            35:        unsigned        a_data; /* size of initialized data */
        !            36:        unsigned        a_bss;  /* size of uninitialized data */
        !            37:        unsigned        a_syms; /* size of symbol table */
        !            38:        unsigned        a_entry;        /* entry point */
        !            39:        unsigned        a_trsize;       /* size of text relocation */
        !            40:        unsigned        a_drsize;       /* size of data relocation */
        !            41: };
        !            42: 
        !            43: #define        OMAGIC  0407    /* old impure format */
        !            44: #define        NMAGIC  0410    /* read-only text */
        !            45: #define        ZMAGIC  0413    /* demand load format */
        !            46: 
        !            47: /*
        !            48: .ti +\w'/'u
        !            49: * Macros which take exec structures as arguments and tell whether
        !            50: .ti +\w'/'u
        !            51: * the file has a reasonable magic number or offsets to text\||\|symbols\||\|strings.
        !            52: .ti +\w'/'u
        !            53: */
        !            54: #define        N_BADMAG(x) \e
        !            55:     (((x).a_magic)!=OMAGIC && ((x).a_magic)!=NMAGIC && ((x).a_magic)!=ZMAGIC)
        !            56: 
        !            57: #define        N_TXTOFF(x) \e
        !            58:        ((x).a_magic==ZMAGIC ? 1024 : sizeof (struct exec))
        !            59: #define N_SYMOFF(x) \e
        !            60:        (N_TXTOFF(x) + (x).a_text+(x).a_data + (x).a_trsize+(x).a_drsize)
        !            61: #define        N_STROFF(x) \e
        !            62:        (N_SYMOFF(x) + (x).a_syms)
        !            63: .DT
        !            64: .fi
        !            65: .PP
        !            66: The file has five sections:
        !            67: a header, the program text and data,
        !            68: relocation information, a symbol table and a string table (in that order).
        !            69: The last three may be omitted
        !            70: if the program was loaded
        !            71: with the `\-s' option
        !            72: of
        !            73: .I ld
        !            74: or if the symbols and relocation have been
        !            75: removed by
        !            76: .IR strip (1).
        !            77: .PP
        !            78: In the header the sizes of each section are given in bytes.
        !            79: The size of the header is not included in any of the other sizes.
        !            80: .PP
        !            81: When an
        !            82: .I a.out
        !            83: file is executed, three logical segments are
        !            84: set up: the text segment, the data segment
        !            85: (with uninitialized data, which starts off as all 0, following
        !            86: initialized),
        !            87: and a stack.
        !            88: The text segment begins at 0
        !            89: in the core image; the header is not loaded.
        !            90: If the magic number in the header is OMAGIC (0407),
        !            91: it indicates that the text
        !            92: segment is not to be write-protected and shared,
        !            93: so the data segment is immediately contiguous
        !            94: with the text segment.
        !            95: This is the oldest kind of executable program and is rarely used.
        !            96: If the magic number is NMAGIC (0410) or ZMAGIC (0413),
        !            97: the data segment begins at the first 0 mod 1024 byte
        !            98: boundary following the text segment,
        !            99: and the text segment is not writable by the program;
        !           100: if other processes are executing the same file,
        !           101: they will share the text segment.
        !           102: For ZMAGIC format, the text segment begins at a 0 mod 1024 byte boundary
        !           103: in the
        !           104: .I a.out
        !           105: file, the remaining bytes after the header in the first block are
        !           106: reserved and should be zero.
        !           107: In this case the text and data sizes must both be multiples of 1024 bytes,
        !           108: and the pages of the file will be brought into the running image as needed,
        !           109: and not pre-loaded as with the other formats.  This is especially suitable
        !           110: for very large programs and is the default format produced by
        !           111: .IR ld (1).
        !           112: .PP
        !           113: The stack will occupy the highest possible locations
        !           114: in the core image, growing downwards from USRSTACK (from
        !           115: .IR <machine/vmparam.h> ).
        !           116: The stack is automatically extended as required.
        !           117: The data segment is only extended as requested by
        !           118: .IR brk (2).
        !           119: .PP
        !           120: After the header in the file follow the text, data, text relocation
        !           121: data relocation, symbol table and string table in that order.
        !           122: The text begins at the byte 1024 in the file for ZMAGIC format or just
        !           123: after the header for the other formats.  The N_TXTOFF macro returns
        !           124: this absolute file position when given the name of an exec structure
        !           125: as argument.  The data segment is contiguous with the text and immediately
        !           126: followed by the text relocation and then the data relocation information.
        !           127: The symbol table follows all this; its position is computed by the
        !           128: N_SYMOFF macro.  Finally, the string table immediately follows the
        !           129: symbol table at a position which can be gotten easily using N_STROFF.
        !           130: The first 4 bytes of the string table are not used for string storage,
        !           131: but rather contain the size of the string table; this size INCLUDES
        !           132: the 4 bytes, the minimum string table size is thus 4.
        !           133: .PP
        !           134: The layout of a symbol table entry and the principal flag values
        !           135: that distinguish symbol types are given in the include file as follows:
        !           136: .PP
        !           137: .nf
        !           138: .ta \w'#define  'u +\w'char'u-1u +\w'unsigned  'u+1u +\w'*n_name  'u
        !           139: /*
        !           140: .ti +\w'/'u
        !           141: * Format of a symbol table entry.
        !           142: .ti +\w'/'u
        !           143: */
        !           144: struct nlist {
        !           145:        union {
        !           146:                char    *n_name;        /* for use when in-core */
        !           147:                long    n_strx; /* index into file string table */
        !           148:        } n_un;
        !           149:        unsigned char   n_type; /* type flag, i.e. N_TEXT etc; see below */
        !           150:        char    n_other;
        !           151:        short   n_desc; /* see <stab.h> */
        !           152:        unsigned        n_value;        /* value of this symbol (or offset) */
        !           153: };
        !           154: #define        n_hash  n_desc  /* used internally by ld */
        !           155: 
        !           156: /*
        !           157: .ti +\w'/'u
        !           158: * Simple values for n_type.
        !           159: .ti +\w'/'u
        !           160: */
        !           161: #define        N_UNDF  0x0     /* undefined */
        !           162: #define        N_ABS   0x2     /* absolute */
        !           163: #define        N_TEXT  0x4     /* text */
        !           164: #define        N_DATA  0x6     /* data */
        !           165: #define        N_BSS   0x8     /* bss */
        !           166: #define        N_COMM  0x12    /* common (internal to ld) */
        !           167: #define        N_FN    0x1f    /* file name symbol */
        !           168: 
        !           169: #define        N_EXT   01      /* external bit, or'ed in */
        !           170: #define        N_TYPE  0x1e    /* mask for all the type bits */
        !           171: 
        !           172: /*
        !           173: .ti +\w'/'u
        !           174: * Other permanent symbol table entries have some of the N_STAB bits set.
        !           175: .ti +\w'/'u
        !           176: * These are given in <stab.h>
        !           177: .ti +\w'/'u
        !           178: */
        !           179: #define        N_STAB  0xe0    /* if any of these bits set, don't discard */
        !           180: 
        !           181: /*
        !           182: .ti +\w'/'u
        !           183: * Format for namelist values.
        !           184: .ti +\w'/'u
        !           185: */
        !           186: #define        N_FORMAT        "%08x"
        !           187: .fi
        !           188: .DT
        !           189: .PP
        !           190: In the
        !           191: .I a.out
        !           192: file a symbol's n_un.n_strx field gives an index into the
        !           193: string table.  A n_strx value of 0 indicates that no name is associated
        !           194: with a particular symbol table entry.  The field n_un.n_name can be used
        !           195: to refer to the symbol name only if the program sets this up using
        !           196: n_strx and appropriate data from the string table.
        !           197: .PP
        !           198: If a symbol's type is undefined external,
        !           199: and the value field is non-zero,
        !           200: the symbol is interpreted by the loader
        !           201: .I ld
        !           202: as
        !           203: the name of a common region
        !           204: whose size is indicated by the value of the
        !           205: symbol.
        !           206: .PP
        !           207: The value of a byte in the text or data which is not
        !           208: a portion of a reference to an undefined external symbol
        !           209: is exactly that value which will appear in memory
        !           210: when the file is executed.
        !           211: If a byte in the text or data
        !           212: involves a reference to an undefined external symbol,
        !           213: as indicated by the relocation information,
        !           214: then the value stored in the file
        !           215: is an offset from the associated external symbol.
        !           216: When the file is processed by the
        !           217: link editor and the external symbol becomes
        !           218: defined, the value of the symbol will
        !           219: be added to the bytes in the file.
        !           220: .PP
        !           221: If relocation
        !           222: information is present, it amounts to eight bytes per
        !           223: relocatable datum as in the following structure:
        !           224: .PP
        !           225: .nf
        !           226: .ta \w'#define  'u +\w'unsigned  'u +\w'r_symbolnum:24,  'u +4n
        !           227: /*
        !           228: .ti +\w'/'u
        !           229: * Format of a relocation datum.
        !           230: .ti +\w'/'u
        !           231: */
        !           232: struct relocation_info {
        !           233:        int     r_address;      /* address which is relocated */
        !           234:        unsigned        r_symbolnum:24, /* local symbol ordinal */
        !           235:                r_pcrel:1,      /* was relocated pc relative already */
        !           236:                r_length:2,     /* 0=byte, 1=word, 2=long */
        !           237:                r_extern:1,     /* does not include value of sym referenced */
        !           238:                :4;     /* nothing, yet */
        !           239: };
        !           240: .fi
        !           241: .DT
        !           242: .PP
        !           243: There is no relocation information if a_trsize+a_drsize==0.
        !           244: If r_extern is 0, then r_symbolnum is actually a n_type for the relocation
        !           245: (i.e. N_TEXT meaning relative to segment text origin.)
        !           246: .fi
        !           247: .SH "SEE ALSO"
        !           248: adb(1), as(1), ld(1), nm(1), dbx(1), stab(5), strip(1)
        !           249: .SH BUGS
        !           250: Not having the size of the string table in the header is a loss, but
        !           251: expanding the header size would have meant stripped executable file
        !           252: incompatibility, and we couldn't hack this just now.

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.