Program header
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.
NOTE:
See
``Segment contents''
for more information.
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.
typedef struct {
Elf32_Word p_type;
Elf32_Off p_offset;
Elf32_Addr p_vaddr;
Elf32_Addr p_paddr;
Elf32_Word p_filesz;
Elf32_Word p_memsz;
Elf32_Word p_flags;
Elf32_Word p_align;
} Elf32_Phdr;
Program header
p_type
-
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
``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.
p_flags
-
This member gives flags relevant to the segment.
Defined flag values appear in
``Section types, sh_type''.
p_align
-
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
``Segment types, p_type''.
Defined type values follow; other values are reserved for
future use.
Segment types, p_type
Name
|
Value
|
|
PT_NULL
|
0
|
|
PT_LOAD
|
1
|
|
PT_DYNAMIC
|
2
|
|
PT_INTERP
|
3
|
|
PT_NOTE
|
4
|
|
PT_SHLIB
|
5
|
|
PT_PHDR
|
6
|
|
PT_LOPROC
|
0x70000000
|
|
PT_HIPROC
|
0x7fffffff
|
|
PT_NULL-
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.
Next topic:
Base address
Previous topic:
Program execution
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003