a.out(4)
NAME
a.out − common assembler and link editor output
DESCRIPTION
The file name a.out is the output file from the assembler as(1)and the link editor ld(1). Both programs will make a.out executable if there were no errors in assembling or linking and no unresolved external references.
A common object file consists of a file header, a CX/UX system header, a table of section headers, relocation information, (optional) line numbers, and a symbol table. The order is given below.
File header.
CX/UX 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 four sections (relocation, line numbers, symbol table and string table) may be missing if the program was linked with the −s option of ld(1) or if the symbol table and relocation bits were removed by strip(1). Also note that if there were no unresolved external references after linking, the relocation information will be absent. The string table exists only if necessary.
The sizes of each segment (contained in the header, discussed below) are in bytes and are even.
When an a.out file is loaded into memory for execution, three logical segments are set up: the text segment, the data segment (initialized data followed by uninitialized, the latter actually being initialized to all 0’s), and a stack. The text segment begins at location 0 in the core image. The header is never loaded. If the magic number (the first field in the CX/UX system header) is 407 (octal), it indicates that the text segment is not to be write-protected or shared, so the data segment will be contiguous with the text segment. If the magic number is 410 (octal), the data segment and the text segment are not writable by the program; if other processes are executing the same a.out file, the processes will share a single text segment. If the magic number is 413 (octal), it’s a demand paging load file. The text segment will begin on a page boundary after the header, and the data segment on the next page boundary follows the text.
The stack begins at the end of memory (address 0xeffffff8 on Series 4000 systems) and grows towards lower addresses. The stack is automatically extended as required. The data segment is extended only as requested by the brk(2) system call.
The value of a word in the text or data portions that is not a reference to an undefined external symbol is exactly the value that will appear in memory when the file is executed. If a word in the text involves a reference to an undefined external symbol, the storage class of the symbol-table entry for that word will be marked as an ”external symbol”, and the section number will be set to 0. 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 word in the file.
File Header
The format of the filehdr header is
struct filehdr
{
unsigned shortf_magic;/∗ magic number ∗/
unsigned shortf_nscns;/∗ number of sections ∗/
longf_timdat;/∗ time and date stamp ∗/
longf_symptr;/∗ file ptr to symtab ∗/
longf_nsyms;/∗ # symtab entries ∗/
unsigned shortf_opthdr;/∗ sizeof(opt hdr) ∗/
unsigned shortf_flags;/∗ flags ∗/
};
CX/UX System Header
The format of the CX/UX system header is
typedef struct aouthdr
{
shortmagic;/∗ magic number ∗/
shortvstamp;/∗ version stamp ∗/
longtsize;/∗ text size in bytes, padded ∗/
longdsize;/∗ initialized data (.data) ∗/
longbsize;/∗ uninitialized data (.bss) ∗/
longentry;/∗ entry point ∗/
longtext_start;/∗ base of text used for this file ∗/
longdata_start;/∗ base of data used for this file ∗/
} AOUTHDR;
Section Header
The format of the section header is
struct scnhdr
{
chars_name/∗ section name ∗/
[SYMNMLEN];
longs_paddr;/∗ physical address ∗/
longs_vaddr;/∗ virtual address ∗/
longs_size;/∗ section size ∗/
longs_scnptr;/∗ file ptr to raw data ∗/
longs_relptr;/∗ file ptr to relocation ∗/
longs_lnnoptr;/∗ file ptr to line numbers ∗/
#if gcx || hcx
unsigned shorts_nreloc; /∗ # reloc entries ∗/
unsigned shorts_nlnno; /∗ # line number entries ∗/
#endif
#ifdef _M88K
unsigned longs_nreloc; /∗ # reloc entries ∗/
unsigned longs_nlnno; /∗ # line number entries ∗/
#endif
longs_flags;/∗ flags ∗/
};
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
{
longr_vaddr;/∗ (virtual) address of reference ∗/
longr_symndx;/∗ index into symbol table ∗/
shortr_type;/∗ relocation type ∗/
#ifdef _M88K
shortr_offset;/∗ high 16 bits of constant in hi16 ∗/
/∗ or lo16 expression ∗/
#endif
};
#defineR_IND1603
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 the symbol table header is
#define SYMNMLEN8
#define FILNMLEN14
#if gcx || hcx
#define SYMESZ18/∗ the size of a SYMENT ∗/
#endif
#if gcx || hcx
#define SYMESZ20/∗ the size of a SYMENT ∗/
#endif
struct syment
{
union/∗ all ways to get a symbol name ∗/
{
char_n_name[SYMNMLEN]; /∗ name of symbol ∗/
struct
{
long_n_zeroes;/∗ == 0L if in string table ∗/
long_n_offset;/∗ location in string table ∗/
} _n_n;
char∗_n_nptr[2];/∗ allows overlaying ∗/
} _n;
unsigned longn_value;/∗ value of symbol ∗/
shortn_scnum;/∗ section number ∗/
unsigned shortn_type;/∗ type and derived type ∗/
charn_sclass;/∗ storage class ∗/
charn_numaux;/∗ number of aux entries ∗/#ifdef _M88K
shortn_pad;/∗ unused - must be zero ∗/
#endif
};
#define n_name_n._n_name
#define n_zeroes_n._n_n._n_zeroes
#define n_offset_n._n_n._n_offset
#define n_nptr_n._n_nptr[1]
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
{
longx_tagndx;/∗ str, un, or enum tag indx ∗/
union
{
struct
{
#if hcx || gcx
unsigned shortx_lnno; /∗ declaration line number ∗/
unsigned shortx_size; /∗ str, union, array size ∗/
#endif
#if _M88K
unsigned longx_lnno; /∗ declaration line number ∗/
unsigned longx_size; /∗ str, union, array size ∗/
#endif
} x_lnsz;
longx_fsize;/∗ size of function ∗/
#if hcx || gcx
unsigned long x_alnno; /∗ line for expanded arrays ∗/
#endif
} x_misc;
union
{
struct/∗ if ISFCN, tag, or .bb ∗/
{
longx_lnnoptr; /∗ ptr to fcn line # ∗/
longx_endndx; /∗ entry ndx past block end ∗/
} x_fcn;
struct /∗ up to 4 short dimensions ∗/
{
unsigned shortx_dimen[DIMNUM];
} x_ary;
struct /∗ hcx & gcx - first dimension ∗/
{
#if hcx || gcx
unsigned long x_asize; /∗ size for arrays ∗/
#endif
unsigned long x_dimen1[DIM1NUM];
} x_ary1;
} x_fcnary;
#if hcx || gcx
unsigned short x_tvndx;/∗ tv index ∗/
#endif
} x_sym;
struct /∗ successive dimensions ∗/
{
unsigned longx_dimen2[DIM2NUM];
} x_ary2;
union
{
charx_fname[FILNMLEN]; /∗ old COFF versio ∗/
struct
{
long _x_zeroes; /∗ 0 if name is in string table ∗/
long _x_offset; /∗ offset into string table ∗/
} _x_x;
} x_file;
struct
{
long x_scnlen; /∗ section length ∗/
#if hcx || gcx
unsigned short x_nreloc; /∗ number of relocation entries ∗/
unsigned short x_nlinno; /∗ number of line numbers ∗/
#endif
#if _M88K
unsigned long x_nreloc; /∗ number of relocation entries ∗/
unsigned long x_nlinno; /∗ number of line numbers ∗/
#endif
} x_scn;
struct
{
longx_tvfill;/∗ tv fill value ∗/
unsigned shortx_tvlen;/∗ length of .tv ∗/
unsigned shortx_tvran[2];/∗ tv range ∗/
}x_tv;/∗ info about .tv section (in auxent of symbol .tv)) ∗/
};
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
brk(2), filehdr(4), ldfcn(4), linenum(4), reloc(4), scnhdr(4), syms(4).
as(1), cc(1), ld(1) in the CX/UX User’s Reference Manual.
CX/UX Programmer’s Reference Manual