Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

as(1)

ld(1)

nm(1)

strip(1)

magic(5)

A.OUT(4)

Series 300 Only

NAME

a.out − assembler and link editor output

Remarks:

This manual page describes the a.out file format for Series 300 computers.  Refer to other a.out(4) manual pages for descriptions of other valid implementations. 

DESCRIPTION

A.out is the output file of the link editor ld. Ld will make a.out executable if there were no linking errors and no unresolved external references.  The assembler as produces non-executable files with the same structure. 

File a.out has seven sections: a header, the program text and data segments, a pascal interface section, a symbol table, information for debugger support, and text and data relocation information (in that order).  The pascal interface text will only be present in those pascal code segments that have not been linked.  The last three sections may be missing if the program was linked with the −s option of ld(1) or if the symbol table, debug information, 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 removed.

The file section containing information for debugger support has three tables−the debug name table (DNTT), the source line table (SLT), and the value table (VT).  These tables contain symbolic information used by the HP-UX debugger cdb(1). HP-UX compilers create this information under control of the −g option. 

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 0x0 in the core image; the header is not loaded.  If the magic number (the first field in the header) is EXEC_MAGIC, 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 SHARE_MAGIC or DEMAND_MAGIC, the data segment begins at the first 0 mod 0x1000 byte boundary following the text segment, and the text segment is not writable by the program; if other processes are executing the same a.out file, they will share a single text segment.  If the magic number is DEMAND_MAGIC, the text and data segments are not read in from the file until they are referenced by the program. 

The stack will occupy the highest possible locations in the core image and grow downward (the stack is automatically extended as required).  The data segment is only extended as requested by the brk(2) system call.

The start of the text segment in the a.out file is given by the macro TEXT_OFFSET(hdr), where hdr is a copy of the file header.  The macro DATA_OFFSET(hdr) provides the starting location of the data segment. 

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 or data portion involves a reference to an undefined external symbol, as indicated by the relocation information (discussed below) 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 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. 

Header

The format of the a.out header for the MC68000 is as follows (segment sizes are in bytes):

struct exec {
MAGICa_magic;/∗ magic number ∗/
shorta_stamp;/∗ version stamp ∗/
shorta_unused;
longa_sparehp;
longa_text;/∗ size of text segment ∗/
longa_data;/∗ size of data segment ∗/
longa_bss;/∗ size of bss segment ∗/
longa_trsize;/∗ size of text relocation info ∗/
longa_drsize;/∗ size of data relocation info ∗/
longa_pasint;/∗ size of interface text ∗/
longa_lesyms;/∗ size of symbol table ∗/
longa_dnttsize;/∗ debug name table size ∗/
longa_entry;/∗ entry point of program ∗/
longa_sltsize;/∗ source-line table size ∗/
longa_vtsize;/∗ value table size ∗/
longa_spare3;
longa_spare4;
};

Pascal Interface Section

The Pascal interface section consists of the ascii representation of the interface text for that Pascal module. 

The start of the Pascal interface section is given by the macro MODCAL_OFFSET(hdr). 

Symbol Table

The symbol table consists of entries of the form:

struct nlist {
longn_value;
unsigned charn_type;
unsigned charn_length;
shortn_almod;
shortn_unused;
};

Following this structure is n_length ascii characters which compose the symbol name. 

The n_type field indicates the type of the symbol; the following values are possible:

00 undefined symbol

01 absolute symbol

02 text segment symbol

03 data segment symbol

04 bss segment symbol

One of these values ORed with 040 indicates an external symbol.  One of these values ORed with 020 indicates an aligned symbol. 

The start of the symbol table is given by the macro LESYM_OFFSET(hdr). 

Relocation

If relocation information is present, it amounts to eight bytes per relocatable datum. 

The format of the relocation data is:

structr_info{
longr_address;
shortr_symbolnum;
charr_segment;
charr_length;
};

The r_address field indicates the position of the relocation within the segment. 

The r_segment field indicates the segment referred to by the text or data word associated with the relocation word:

00 indicates the reference is to the text segment;

01 indicates the reference is to initialized data;

02 indicates the reference is to bss (uninitialized data);

03 indicates the reference is to an undefined external symbol. 

The field r_symbolnum contains a symbol number in the case of external references, and is unused otherwise.  The first symbol is numbered 0, the second 1, etc. 

The field r_length indicates the length of the datum to be relocated. 

00 indicates it is a byte

01 indicates it is a short

02 indicates it is a long

03 indicates it is a special align symbol

The start of the text relocation section is provided by the macro RTEXT_OFFSET(hdr). 

The start of the data relocation section is provided by the macro RDATA_OFFSET(hdr). 

SEE ALSO

as(1), ld(1), nm(1), strip(1), magic(5). 

Hewlett-Packard Company  —  May 11, 2021

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026