An executable or shared object file's program header table
is an array of structures, each describing a segment or
other information the system needs to prepare the program
for execution. An object file segment contains one or more
sections.
Program headers are meaningful only for executable and
shared object files. A file specifies its own program
header size with the ELF header's
e_phentsize and e_phnum members.
See
``ELF header''
for more information.
This member tells what kind of segment this array element
describes or how to interpret the array element's information.
Type values and their meanings appear in
Table 8-4, ``Section types, sh_type''.
p_offset
This member gives the offset from the beginning of the
file at which the first byte of the segment resides.
p_vaddr
This member gives the virtual address at which
the first byte of the segment resides in memory.
p_paddr
On systems for which physical addressing is relevant,
this member is reserved for the segment's physical address.
Because UNIX System V ignores physical addressing
for application programs, this member has unspecified
contents for executable files and shared objects.
p_filesz
This member gives the number of bytes in the file image of
the segment; it may be zero.
p_memsz
This member gives the number of bytes in the memory image of
the segment; it may be zero.
Loadable process segments must have congruent values for
p_vaddr and p_offset, modulo the page size.
See
``Program values''
for more information. This
member gives the value to which the segments are aligned in
memory and in the file. Values 0 and 1 mean no alignment
is required. Otherwise, p_align should be a
positive, integral power of 2, and p_vaddr should
equal p_offset, modulo p_align.
Some entries describe process segments; others give
supplementary information and do not contribute to the
process image. Segment entries may appear in any order,
except as explicitly noted in
Table 8-13, ``Segment types, p_type''.
Defined type values follow; other values are reserved for
future use.
The array element is unused; other members' values are undefined.
This type lets the program header table have ignored entries.
PT_LOAD
The array element specifies a loadable segment,
described by p_filesz and p_memsz.
The bytes from the file are mapped to the
beginning of the memory segment.
If the segment's memory size (p_memsz)
is larger than the file size (p_filesz),
the ``extra'' bytes are defined to hold the value 0
and to follow the segment's initialized area.
The file size may not be larger than the memory size.
Loadable segment entries in the program header table
appear in ascending order, sorted on the p_vaddr member.
PT_DYNAMIC
The array element specifies dynamic linking information.
See
``Dynamic section''
for more information.
PT_INTERP
The array element specifies the location and size of
a null-terminated path name to invoke as an interpreter.
This segment type is meaningful only for executable files
(though it may occur for shared objects);
it may not occur more than once in a file.
If it is present, it must precede any loadable segment entry.
See
``Program interpreter''
for more information.
PT_NOTE
The array element specifies the location and size of
auxiliary information.
See
``Note section''
for more information.
PT_SHLIB
This segment type is reserved but has unspecified semantics.
PT_PHDR
The array element, if present, specifies the location and size of
the program header table itself, both in the file and
in the memory image of the program.
This segment type may not occur more than once in a file.
Moreover, it may occur only if the program header table is
part of the memory image of the program.
If it is present, it must precede any loadable segment entry.
See
``Program interpreter''
for more information.
PT_LOPROC through PT_HIPROC
Values in this inclusive range
are reserved for processor-specific semantics.
NOTE:
Unless specifically required elsewhere,
all program header segment types are optional.
A file's program header table may contain
only those elements relevant to its contents.