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

a
a.out(4) a.out(4)
NAME
a.out - assembler and link editor output
SYNOPSIS
#include <elf.h> (for ELF files)
#include <a.out.h> (for SOM files)
DESCRIPTION
ELF a.out
The file name a.out is the default output file name from the link editor, ld(1). The link editor will
make an
a.out executable if there were no errors in linking. The output file of the assembler, as(1),
also follows the format of the
a.out file although its default file name is different.
Programs that manipulate ELF files may use the library that elf(3E) describes. An overview of the file
format follows. For more complete information, see the references given below.
Linking View Execution View
_______________________ _______________________
ELF header ELF header
|_____________________| |______________________|
|Program header table | | Program header table|
| optional | | |
|_____________________| | _____________________|
| Section 1 | | |
|_____________________| | |
| . . . | | Segment 1 |
||| |
|_____________________| | _____________________|
| Section n | | |
|_____________________| | |
| . . . | | Segment 2 |
||| |
|_____________________| | _____________________|
| ... | | ... |
|_____________________| | _____________________|
| Section header table| | Section header table|
| | | optional |
|_____________________| | _____________________|
An ELF header resides at the beginning and holds a ‘‘road map’’ describing the file’s organization. Sec-
tions hold the bulk of object file information for the linking view: instructions, data, symbol table, reloca-
tion information, and so on. Segments hold the object file information for the program execution view. As
shown, a segment may contain one or more sections.
A program header table, if present, tells the system how to create a process image. Files used to build a
process image (execute a program) must have a program header table; relocatable files do not need one.
A section header table contains information describing the file’s sections. Every section has an entry in
the table; each entry gives information such as the section name, the section size, and so on. Files used
during linking must have a section header table; other object files may or may not have one.
Although the figure shows the program header table immediately after the ELF header, and the section
header table following the sections, actual files may differ. Moreover, sections and segments have no
specified order. Only the ELF header has a fixed position in the file.
When an a.out file is loaded into memory for execution, three logical segments are set up: the text seg-
ment, the data segment (initialized data followed by uninitialized, the latter actually being initialized to
all 0’s), and a stack. The text segment is not writable by the program; if other processes are executing the
same a.out file, the processes will share a single text segment.
The data segment starts at the next maximal page boundary past the last text address. (If the system
supports more than one page size, the ‘‘maximal page’’ is the largest supported size.) When the process
image is created, the part of the file holding the end of text and the beginning of data may appear twice.
The duplicated chunk of text that appears at the beginning of data is never executed; it is duplicated so
that the operating system may bring in pieces of the file in multiples of the actual page size without hav-
ing to realign the beginning of the data section to a page boundary. Therefore, the first data address is
Section 42 Hewlett-Packard Company 1 HP-UX 11i Version 2: August 2003