A.OUT(5) BSD A.OUT(5)
NAME
a.out - common compiler and link editor output
SYNOPSIS
#include <a.out.h>
DESCRIPTION
The compiler (cc(1)) and the link editor (ld(1)) produce output in common
object file format (COFF). If none other is specified, they give the
name a.out to the output file they create. The link editor will make
a.out executable if there were no errors in linking. Object files are of
the type coff.
A common object file consists of a file header, a BSD system header a
table of section headers, relocation information, (optional) line
numbers, a symbol table, and a string table. The order is given below.
File header.
BSD system header.
Section 1 header.
...
Section n header.
Section 1 data.
...
Section n data.
Section 1 relocation.
...
Section n relocation.
Section 1 line numbers.
...
Section n line numbers.
Symbol table.
String table.
The last three parts of an object file (line numbers, symbol table and
string table) may be missing if the program was linked with the -s option
of ld(1) or if they were removed by strip(1). Also note that the
relocation information may be absent after linking unless the -r option
of ld(1) was used. The string table exists only if the symbol table
contains symbols with names longer than eight characters.
File Header
The format of the filehdr header is
struct filehdr {
unsigned short f_magic; /* magic number */
unsigned short f_nscns; /* number of sections */
long f_timdat; /* time & date stamp */
long f_symptr; /* file pointer to symtab */
long f_nsyms; /* number of symtab entries */
unsigned short f_opthdr; /* sizeof(optional hdr) */
unsigned short f_flags; /* flags */
};
Domain/OS BSD System Header
The format of the Domain/OS BSD system header is
typedef struct aouthdr {
short vformat; /* Object file format version*/
short magic; /* see filehdr.h*/
short vstamp; /* version stamp*/
long tsize; /* text size in bytes, padded to FW
bdry*/
long dsize; /* initialized data " "*/
long bsize; /* uninitialized data " "*/
long entry; /* entry pt.*/
long text_start; /* base of text used for this file*/
long data_start; /* base of data used for this file*/
long o_sri; /* File pointer to the .sri data*/
long o_inlib; /* File pointer to the .inlib data.*/
long vid[2]; /* 64-bit unique version identifier */
} AOUTHDR;
#define APOLLO_COFF_VERSION_NUMBER 1/* The current format version */
vformat is an overloading of the magic field. o_sri points to the .sri
section which contains Static Resource Information records. o_inlib
points to the .inlib section which contains a list of pathnames to
objects to be dynamically installed by the loader before program
execution. If these last two fields are 0, the loader assumes a set of
run-time defaults for the object.
Section Header
The format of the section header is
struct scnhdr {
union section_name {
char _n_name[8]; /* Name lives here if 1-8 chars, */
struct {
long _n_zeroes; /* zero if > 8 chars */
long _n_offset; /* offset into string table. */
} _n_n;
char *_n_nptr[2]; /* allows overlaying */
} _n;
long s_paddr; /* physical address */
long s_vaddr; /* virtual address */
long s_size; /* section size */
long s_scnptr; /* file ptr to raw data for section */
long s_relptr; /* file ptr to relocation */
long s_lnnoptr; /* file ptr to line numbers */
unsigned short s_nreloc; /* number of relocation entries */
unsigned short s_nlnno; /* number of line number entries */
long s_flags; /* flags */
};
#define s_name _n._n_name
#define s_zeroes _n._n_n._n_zeroes
#define s_offset _n._n_n._n_offset
#define s_nptr _n._n_nptr[1]
On Apollo workstations, section names can be longer than 8 characters.
Relocation
Object files have one relocation entry for each relocatable reference in
the text or data. If relocation information is present, it will be in
the following format:
struct reloc {
long r_vaddr; /* (virtual) address of reference */
long r_symndx; /* index into symbol table */
unsigned short r_type;/* relocation type */
};
The start of the relocation information is s_relptr from the section
header. If there is no relocation information, s_relptr is 0.
Symbol Table
The format of each symbol in the symbol table is
struct syment
{
union
{
char _n_name[SYMNMLEN];/* old COFF version */
struct
{
long_n_zeroes;/* new == 0 */
long_n_offset;/* offset into string table */
} _n_n;
char *_n_nptr[2];/* allows for overlaying */
} _n;
long n_value;/* value of symbol */
short n_scnum;/* section number */
unsigned short n_type;/* type and derived type */
char n_sclass;/* storage class */
char n_numaux;/* number of aux. entries */
};
#define n_name _n._n_name
#define n_nptr _n._n_nptr[1]
#define n_zeroes _n._n_n._n_zeroes
#define n_offset _n._n_n._n_offset
Some symbols require more information than a single entry; they are
followed by auxiliary entries that are the same size as a symbol entry.
The format follows.
union auxent
{
struct
{
long x_tagndx; /* str, un, or enum tag indx */
union
{
struct
{
unsigned short x_lnno;/* declaration line number */
unsigned short x_size;/* str, union, array size */
} x_lnsz;
long x_fsize; /* size of function */
} x_misc;
union
{
struct /* if ISFCN, tag, or .bb */
{
long x_lnnoptr;/* ptr to fcn line # */
long x_endndx;/* entry ndx past block end */
} x_fcn;
struct /* if ISARY, up to 4 dimen. */
{
unsigned short x_dimen[DIMNUM];
} x_ary;
} x_fcnary;
unsigned short x_tvndx; /* tv index */
} x_sym;
union
{
char x_fname[FILNMLEN];
struct
{
long _n_zeroes;/* new == 0 */
long _n_offset;/* offset into string table */
} _n_n;
} x_file;
struct
{
long x_scnlen; /* section length */
unsigned short x_nreloc; /* number of relocation entries */
unsigned short x_nlinno; /* number of line numbers */
} x_scn;
struct
{
long x_tvfill; /* tv fill value */
unsigned short x_tvlen; /* length of .tv */
unsigned short x_tvran[2]; /* tv range */
} x_tv; /* info about .tv section (in auxent of symbol .tv)) */
#define x_name x_fname
#define x_zeroes _n_n._n_zeroes
#define x_offset _n_n._n_offset
On Apollo workstations, filenames can be longer than 14 characters.
Indexes of symbol table entries begin at zero. The start of the symbol
table is f_symptr (from the file header) bytes from the beginning of the
file. If the symbol table is stripped, f_symptr is 0. The string table
(if one exists) begins at f_symptr + (f_nsyms * SYMESZ) bytes from the
beginning of the file.
SEE ALSO
cc(1), ld(1), brk(2), filehdr(5), ldfcn(5), linenum(5), reloc(5),
scnhdr(5), syms(5).