<elf.h>¶
The parts of the ELF32 format the loader reads.
#include <elf.h>
Constants¶
Structures¶
Elf32_Ehdr¶
ELF32 file header.
| Field | Type | Description |
|---|---|---|
e_ident |
uint8_t |
ELF identification. |
e_type |
uint16_t |
Object file type. |
e_machine |
uint16_t |
Machine type. |
e_version |
uint32_t |
Object file version. |
e_entry |
uint32_t |
Entry point address. |
e_phoff |
uint32_t |
Program header offset. |
e_shoff |
uint32_t |
Section header offset. |
e_flags |
uint32_t |
Processor-specific flags. |
e_ehsize |
uint16_t |
ELF header size. |
e_phentsize |
uint16_t |
Size of program header entry. |
e_phnum |
uint16_t |
Number of program header entries. |
e_shentsize |
uint16_t |
Size of section header entry. |
e_shnum |
uint16_t |
Number of section header entries. |
e_shstrndx |
uint16_t |
Section name string table index. |
Elf32_Phdr¶
ELF32 program header.
| Field | Type | Description |
|---|---|---|
p_type |
uint32_t |
Type of segment. |
p_offset |
uint32_t |
Offset in file. |
p_vaddr |
uint32_t |
Virtual address in memory. |
p_paddr |
uint32_t |
Physical address. |
p_filesz |
uint32_t |
Size of segment in file. |
p_memsz |
uint32_t |
Size of segment in memory. |
p_flags |
uint32_t |
Segment attributes. |
p_align |
uint32_t |
Alignment of segment. |
Functions¶
ElfValidate¶
uint32_t ElfValidate(const void *data, size_t size);
Checks that data is a 32-bit little-endian ARM executable whose program headers fit.
| Parameter | Direction | Description |
|---|---|---|
data |
in | Pointer to the ELF file data in memory. |
size |
in | Size of the ELF file data in bytes. |
Returns: The entry point, or 0 if the file is not acceptable.
ElfPhdrCount¶
int ElfPhdrCount(const void *data);
Returns the number of program headers in the ELF file.
| Parameter | Direction | Description |
|---|---|---|
data |
in | A file that passed ElfValidate(). |
Returns: Number of program headers.
ElfPhdrGet¶
const Elf32_Phdr * ElfPhdrGet(const void *data, int index);
Returns a pointer to the program header at the specified index.
| Parameter | Direction | Description |
|---|---|---|
data |
in | A file that passed ElfValidate(). |
index |
in | Index of the program header, below ElfPhdrCount(); not checked. |
Returns: Pointer to the program header, inside data.