HP-UX Reference (11i v2 03/08) - 4 File Formats (vol 8)

a
a.out(4) a.out(4)
In a relocatable file, initialized code and data often contain references to locations elsewhere in the file,
and to unresolved symbols defined in other files. These references are patched at link time using the
relocation information. Each entry in the relocation information (a "fixup") specifies a location within the
initialized data for a subspace, and an expression that defines the actual value that should be placed at
that location, relative to one or two symbols.
The linker summarizes the subspace dictionary in the HP-UX auxiliary header when creating an execut-
able file. HP-UX programs contain only three separate sections: one for the code, one for initialized data,
and one for uninitialized data. By convention, this auxiliary header is placed immediately following the
file header.
When an
a.out file is loaded into memory for execution, three areas of memory are set up: the
a.out
code is loaded into the first quadrant of a new, sharable space; the data (initialized followed by uninitial-
ized) is loaded into the second quadrant of a new, private space; and a stack is created beginning at a
fixed address near the middle of the second quadrant of the data space.
If the
a.out file uses shared libraries, then the dynamic loader
/usr/lib/dld.sl
is loaded into
memory and called to map into memory all shared libraries requested by the program. The shared
library text is loaded into the third quadrant of the shared memory space, and the shared library data is
allocated in the second quadrant of the data space.
The file format described here is a common format for all operating systems designed for HP’s Precision
Architecture. Therefore, there are some fields and structures that are not used on HP-UX or have been
reserved for future use.
File Header
The format of the file header is described by the following structure declaration from
<filehdr.h>.
struct header {
short int system_id; /* system id */
short int a_magic; /* magic number */
unsigned int version_id; /* a.out format version */
struct sys_clock file_time; /* timestamp */
unsigned int entry_space; /* index of space containing entry point */
unsigned int entry_subspace; /* subspace index of entry */
unsigned int entry_offset; /* offset of entry point */
unsigned int aux_header_location; /* file ptr to aux hdrs */
unsigned int aux_header_size; /* sizeof aux hdrs */
unsigned int som_length; /* length of object module */
unsigned int presumed_dp; /* DP value assumed during compilation */
unsigned int space_location; /* file ptr to space dict */
unsigned int space_total; /* # of spaces */
unsigned int subspace_location; /* file ptr to subsp dict */
unsigned int subspace_total; /* # of subspaces */
unsigned int loader_fixup_location; /* space reference array */
unsigned int loader_fixup_total; /* # of space reference recs */
unsigned int space_strings_location; /* file ptr to sp. strings */
unsigned int space_strings_size; /* sizeof sp. strings */
unsigned int init_array_location; /* location of init pointers */
unsigned int init_array_total; /* # of init pointers */
unsigned int compiler_location; /* file ptr to comp recs */
unsigned int compiler_total; /* # of compiler recs */
unsigned int symbol_location; /* file ptr to sym table */
unsigned int symbol_total; /* # of symbols */
unsigned int fixup_request_location; /* file ptr to fixups */
unsigned int fixup_request_total; /* # of fixups */
unsigned int symbol_strings_location; /* file ptr to sym strings */
unsigned int symbol_strings_size; /* sizeof sym strings */
unsigned int unloadable_sp_location; /* file ptr to debug info */
unsigned int unloadable_sp_size; /* size of debug info */
unsigned int checksum; /* header checksum */
};
The timestamp is a two-word structure as shown below. If unused, both fields are zero.
Section 44 Hewlett-Packard Company 3 HP-UX 11i Version 2: August 2003