An ELF executable 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 defined only for executable files. A file specifies its own program header size with the ELF header's e_phentsize and e_phnum.
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; |
|
p_type The kind of segment this array element describes and how to interpret the array element's information.
p_offset Offset from the beginning of the file at which the first byte of the segment resides.
p_vaddr Address at which the first byte of the segment resides in memory.
p_paddr This field is currently unused and is set to zero by the linker.
p_filesz Number of bytes in the file image of the segment; it may be zero.
p_memsz Number of bytes in the memory image of the segment; it may be zero.
p_flags Flags relevant to the segment.
p_align Loadable process segments must have congruent values for p_vaddr and p_offset, modulo the page size. This structure 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.