a.out(4) a.out(4)
NAME
a.out - ELF (Executable and Linking Format) files
SYNOPSIS
#include <elf.h>
DESCRIPTION
The filename a.out is the default output filename from the link edi-
tor, ld(1). The link editor will make an a.out executable if there
were no errors in linking.
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.
Page 1 Reliant UNIX 5.44 Printed 11/98
a.out(4) a.out(4)
Linking Execution
View 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" describ-
ing the file's organization. Sections hold the object file information
for the linking view: instructions, data, symbol table, relocation
information, and so on. Segments hold the object file information for
the program execution view. A segment may contain one or more sec-
tions.
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 sec-
tions. Every section has an entry in the table; each entry gives
information such as the section name, the section size, etc. 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 must appear at the start of the
file.
Page 2 Reliant UNIX 5.44 Printed 11/98
a.out(4) a.out(4)
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 is not writable by the pro-
gram; 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. 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 having to realign the beginning of the data section to a page
boundary. Therefore, the first data address is the sum of the next
maximal page boundary past the end of text plus the remainder of the
last text address divided by the maximal page size. If the last text
address is a multiple of the maximal page size, no duplication is
necessary. The stack is automatically extended as required. The data
segment is extended as requested by the brk(2) system call.
SEE ALSO
cc(1), ld(1), brk(2), elf(3E).
The "Object files" chapter in the Guide to Tools for Programming in C.
Page 3 Reliant UNIX 5.44 Printed 11/98