Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ a.out(4) — HP-UX 5.20

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

chatr(1)

ld(1)

nm(1)

strip(1)

magic(5)

A.OUT(4)

Series 500 Implementation

NAME

a.out − executable linker output file

Remarks:

This manual entry describes the a.out file format for the Series 500.  Refer to other a.out manual pages for information valid for other implementations. 

DESCRIPTION

A.out is the output file of the linker ld(1).  Ld makes a.out executable if no errors occured during compilation and linking, and there are no remaining unresolved external references. 

The a.out file has five sections: a file header, a segment table, a segment information section, a symbol table(s) section, and a name pool(s) section, logically arranged as follows:

a.out File Structure
File header
Segment Table
Segment Information:
• segment image (code/data)
• fix-up information (loader)
• relocation information (ld)
Symbol Tables:
• linker symbol table
• information for debugger support
Name Pool (strings)

Note that this pictorial representation depicts the logical structure of the file, but does not necessarily reflect the physical arrangement of data in the file.  The following topics discuss each logical section of the a.out file. 

File Header

The a.out file header is conceptually divided into two parts.  The first part contains "scalar" values, while the second part contains "file map" data pertaining to the rest of the file.  The entire file header contains 128 bytes of information, 32 of which make up the scalar section.  The scalar section can be represented pictorially as follows:

Byte Arrangement: File Header Scalar Section
Bytes Contents
0 thru 3 System ID (2 bytes) File Type (2 bytes)
4 thru 7 Reserved for future use
8 thru 11 Flags
12 thru 15 Program Entry Point
16 thru 19 Version Stamp
20 thru 23 Memory Offset
24 thru 27 Working Set gurarantee
28 thru 31 Reserved for future use

Each group of four bytes forms a word that has a specific function:

Magic Number The first word, called the "magic number", is divided into two half-words containing the system ID and the file type.  The system ID identifies the target machine upon which the object code can run.  The file type specifies whether or not the file is executable (hex 107), shareable (hex 108), or relocatable (hex 106). 

Flags The third word specifies the settings of five flags.  The left-most five bits of this word are significant; the remainder of the word is ignored. 

Bit 1 (the left-most of the flag bits) If set, bit 1 marks the program as using a single data segment.  You can override this with the −T or −A ld options, which force the program to reside in one or two data segments, respectively. 

Bit 2 If set, marks the file as relinkable (meaning that the file contains relocation records and a symbol table). 

Bit 3 If set, the file is debuggable. 

Bit 5 If set, marks the program as allowing null pointer dereferencing.  To set bit 5, use the −Z option of ld.

Program Entry Point This word contains an external program pointer (EPP) that references the starting code for the program.  Ld normally assigns the starting address of the main program to this word.  This can be changed with the −e linker option. 

Version Stamp The Version Stamp is a user-supplied 32-bit integer used to distinguish one version of an application program from another.  The user can specify this integer by using the −V ld(1) option at link time. 

The file map portion of the header is structured as follows:

Byte Arrangement: File Header File Map Section
Bytes Contents Bytes Contents
32 thru 35 Code Segment Table: offset 80 thru 83 VT: offset
36 thru 39 Code Segment Table: size 84 thru 87 VT: size
40 thru 43 Code Segment Images: offset 88 thru 91 SLT: offset
44 thru 47 Code Segment Images: size 92 thru 95 SLT: size
48 thru 51 Data Segment Table: offset 96 thru 99 Name Pool: offset
52 thru 55 Data Segment Table: size 100 thru 103 Name Pool: size
56 thru 59 Data Segment Images: offset 104 thru 107 Interface Information: offset
60 thru 63 Data Segment Images: size 108 thru 111 Interface Information: size
64 thru 67 Link Symbol Table: offset 112 thru 115 Reserved for future use
68 thru 71 Link Symbol Table: size 116 thru 119 Reserved for future use
72 thru 75 DNTT: offset 120 thru 123 Reserved for future use
76 thru 79 DNTT: size 124 thru 127 Reserved for future use

Each offset entry in the file map shows where the given section starts, relative to the beginning of the a.out file.  Each size entry gives the size (in bytes) for that section. 

DNTT is the Debug Symbol Table, VT is the Value Table, and SLT is the Source Line Table.  All are used by the symbolic debugger, cdb.

Segment Table

The segment table collects, in one place, all information about the code and data segments making up the program.  The segment table consists of an array of entries.  Each entry describes one code or data segment of the program. 

Both code and data segment table entries include the following information:

segment name Consists of an offset into the name pool, relative to the beginning of the name pool.  Useful for symbolically referring to code or data segments (not currently implemented). 

segment type Specifies one of three possible types of segments: code; direct data (in GDS), or indirect data (in GDS or EDS). 

list of segment attributes Segments can be paged, virtual, demand loadable, writable, or privileged.  The linker sets the attributes for executable files. 

segment offset References a particular code or data segment within the segment image area.  The reference is given relative to the beginning of the segment image area. 

segment size Size (in bytes) of the particular code or data segment being described in the entry. 

segment fixup size Specifies the size (in bytes) of the loader fixup area in the particular segment being described. 

segment relocation information size
Specifies the number of bytes of relocation records for this segment.

The following entries appear only in data segment table entries:

segment limit Specifies the maximum number of bytes that the indirect data segment can contain.  Attempting to increase the size beyond this stated limit produces an error.  The linker assigns a default value of 1.5 Mbytes to this field, but it can be changed with the −m chatr(1) option. 

segment zero-padding size A byte count of the uninitialized data area.  The linker computes this value from the data relocation records. 

The following entries appear only in code segment table entries:

segment local procedures count
Specifies the number of procedures defined in that segment, that are only known locally within the segment.

segment external procedures count
Specifies the number of procedures defined in that segment, that are externally known.

Several words are left unused in each segment table entry to allow for future growth. 

Segment Information

This section of the file contains the segment images for each segment included in the final, executable file.  This section contains a subsection for each program segment.  Each subsection is in turn made up of three parts − the contents of the segment (code or data), a list of pointers that the loader must "fix up" in that segment, and the relocation records for that segment.  Each subsection looks as follows:

Segment Information Structure
Code/Data Image
Loader Initialization Information
Loader Fixup Information
Relocation Records

The code image contains the compiled machine code for each program segment.  The data image contains an image of initialized data for the program.  Contained in this code are pointers.  The loader fixup information area contains offsets that reference these pointers (the offsets are given relative to the beginning of the code/data image area).  These offsets must be "fixed up" at run time (i.e., the program loader exec must update the segment number fields with the correct values).  The linker generates the loader fixup information. 

Symbol Tables

The linker symbol table contains data on relocatable symbols relevant to the linker (e.g. name and type for each global symbol).  Refer to nm(1) (Series 500 only version) for a complete description of each symbol type and the parameters associated with them.  The contents of the symbol table may be listed in several different ways with nm. 

Name Pool

The name pool contains a list of null-terminated strings, which specify the names of the symbols in the program.  The symbol table entries contain indexes into the name pool instead of the names themselves.  This permits arbitrarily long names to be used instead of fixed-length names.  The first string in the name pool is always a null string.  This enables zero to be used as an index into the name pool for entities which have no names. 

SEE ALSO

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

Hewlett-Packard Company  —  April 12, 1993

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