Barrelfish
|
ELF file format definitions. More...
Data Structures | |
struct | Elf64_Ehdr |
ELF64 file header. More... | |
struct | Elf64_Phdr |
ELF64 program header. More... | |
struct | Elf64_Shdr |
ELF64 section header. More... | |
struct | Elf64_Rela |
ELF64 relocation entry. More... | |
struct | Elf64_Sym |
ELF64 symbol table entry. More... | |
struct | Elf64_Dyn |
ELF64 Dynamic section entry. More... | |
struct | Elf32_Ehdr |
ELF32 file header. More... | |
struct | Elf32_Phdr |
ELF32 program header. More... | |
struct | Elf32_Shdr |
ELF32 section header. More... | |
struct | Elf32_Rel |
ELF32 relocation entry. More... | |
struct | Elf32_Rela |
ELF32 relocation entry with addend. More... | |
struct | Elf32_Sym |
ELF32 symbol table entry. More... | |
struct | Elf32_Nhdr |
ELF32 note entry. More... | |
Functions | |
struct Elf64_Shdr * | elf64_find_section_header_type (struct Elf64_Shdr *shdr, uint32_t entries, uint32_t type) |
Return pointer to relocation section ELF header. More... | |
struct Elf32_Shdr * | elf32_find_section_header_type (struct Elf32_Shdr *shdr, uint32_t entries, uint32_t type) |
Return pointer to relocation section ELF header. More... | |
struct Elf64_Shdr * | elf64_find_section_header_name (genvaddr_t elf_base, size_t elf_bytes, const char *section_name) |
Return pointer to section header with given name. More... | |
struct Elf32_Shdr * | elf32_find_section_header_name (genvaddr_t elf_base, size_t elf_bytes, const char *section_name) |
Return pointer to section header with given name. More... | |
struct Elf64_Sym * | elf64_find_symbol_by_name (genvaddr_t elf_base, size_t elf_bytes, const char *name, uint8_t contains, uint8_t type, uintptr_t *index) |
finds the symbol by name More... | |
struct Elf32_Sym * | elf32_find_symbol_by_name (genvaddr_t elf_base, size_t elf_bytes, const char *name, uint8_t contains, uint8_t type, uintptr_t *index) |
finds the symbol by name More... | |
struct Elf64_Sym * | elf64_find_symbol_by_addr (genvaddr_t elf_base, size_t elf_bytes, lvaddr_t addr, uintptr_t *index) |
finds the symbol by its address More... | |
struct Elf32_Sym * | elf32_find_symbol_by_addr (genvaddr_t elf_base, size_t elf_bytes, lvaddr_t addr, uintptr_t *index) |
finds the symbol by its address More... | |
void | elf64_relocate (genvaddr_t dst, genvaddr_t src, struct Elf64_Rela *rela, size_t size, struct Elf64_Sym *symtab, size_t symsize, genvaddr_t start, void *vbase) |
Relocates the ELF image from src to dst. More... | |
void | elf32_relocate (genvaddr_t dst, genvaddr_t src, struct Elf32_Rel *rela, size_t size, struct Elf32_Sym *symtab, size_t symsize, genvaddr_t start, void *vbase) |
Relocates the ELF image from src to dst. More... | |
errval_t | elf64_load (uint16_t em_machine, elf_allocator_fn allocate_func, void *state, lvaddr_t base, size_t size, genvaddr_t *retentry, genvaddr_t *ret_tlsbase, size_t *ret_tlsinitlen, size_t *ret_tlstotallen) |
Load ELF64 binary image into memory. More... | |
errval_t | elf32_load (uint16_t em_machine, elf_allocator_fn allocate_func, void *state, lvaddr_t base, size_t size, genvaddr_t *retentry, genvaddr_t *ret_tlsbase, size_t *ret_tlsinitlen, size_t *ret_tlstotallen) |
Load ELF32 binary image into memory. More... | |
errval_t | elf_load_tls (uint16_t em_machine, elf_allocator_fn allocate_func, void *state, lvaddr_t base, size_t size, genvaddr_t *retentry, genvaddr_t *ret_tlsbase, size_t *ret_tlsinitlen, size_t *ret_tlstotallen) |
Load ELF binary image into memory. More... | |
size_t | elf_virtual_size (lvaddr_t base) |
Calculates the size of the loadable portion of the elf image in virtual memory. This is the amount of virtual memory required to load an image. | |
errval_t | elf_get_eh_info (lvaddr_t elfbase, size_t elfsize, lvaddr_t *eh_frame, size_t *eh_frame_size, lvaddr_t *eh_frame_hdr, size_t *eh_frame_hdr_size) |
obtains the error handling frame information form the elf image More... | |
genvaddr_t | elf_virtual_base32 (struct Elf32_Ehdr *ehead) |
Calculates the base of the loadable portion of the elf image in virtual memory. | |
genvaddr_t | elf_virtual_base64 (struct Elf64_Ehdr *ehead) |
Calculates the base of the loadable portion of the elf image in virtual memory. | |
genvaddr_t | elf_virtual_base (lvaddr_t base) |
Calculates the base of the loadable portion of the elf image in virtual memory. | |
ELF file format definitions.
struct Elf32_Shdr* elf32_find_section_header_name | ( | genvaddr_t | elf_base, |
size_t | elf_bytes, | ||
const char * | section_name | ||
) |
Return pointer to section header with given name.
elf_base | Address of ELF header |
elf_bytes | Size of ELF file. |
section_name | Named section to look for. |
struct Elf32_Shdr* elf32_find_section_header_type | ( | struct Elf32_Shdr * | shdr, |
uint32_t | entries, | ||
uint32_t | type | ||
) |
Return pointer to relocation section ELF header.
This function finds and returns a pointer to the first ELF section header of type 'type'.
shdr | Pointer to head of ELF section header table. |
entries | Number of entries in the ELF section header table. |
type | ELF section header type to look for. |
struct Elf32_Sym* elf32_find_symbol_by_addr | ( | genvaddr_t | elf_base, |
size_t | elf_bytes, | ||
lvaddr_t | addr, | ||
uintptr_t * | sindex | ||
) |
finds the symbol by its address
elf_base | virtual address where the elf image is mapped |
elf_bytes | size of the mapped elf image |
addr | virtual address of the symbol |
index | returns the index of the symbol |
struct Elf32_Sym* elf32_find_symbol_by_name | ( | genvaddr_t | elf_base, |
size_t | elf_bytes, | ||
const char * | name, | ||
uint8_t | contains, | ||
uint8_t | type, | ||
uintptr_t * | sindex | ||
) |
finds the symbol by name
elf_base | virtual address where the elf image is mapped |
elf_bytes | size of the mapped elf image |
name | name of the symbol to look for |
contains | if non zero, search for containing rather than exact match |
type | type of the symbol STT_* |
sindex | index where to start and returns the index of the symbol |
errval_t elf32_load | ( | uint16_t | em_machine, |
elf_allocator_fn | allocate_func, | ||
void * | state, | ||
lvaddr_t | base, | ||
size_t | size, | ||
genvaddr_t * | retentry, | ||
genvaddr_t * | ret_tlsbase, | ||
size_t * | ret_tlsinitlen, | ||
size_t * | ret_tlstotallen | ||
) |
Load ELF32 binary image into memory.
This function loads an ELF32 binary image, based at 'base' and of size 'size' into the memory provided by 'allocate'
em_machine | ELF machine type. |
allocate | Memory allocation function. |
state | Pointer to state for allocation function. |
base | Base address of ELF32 binary image in memory. |
size | Size of ELF32 binary image in bytes. |
retentry | Used to return entry point address |
ret_tlsbase | Used to return TLS block base address |
ret_tlsinitlen | Used to return length of initialised TLS data block |
ret_tlstotallen | Used to return total length of TLS data |
void elf32_relocate | ( | genvaddr_t | dst, |
genvaddr_t | src, | ||
struct Elf32_Rel * | rel, | ||
size_t | size, | ||
struct Elf32_Sym * | symtab, | ||
size_t | symsize, | ||
genvaddr_t | start, | ||
void * | vbase | ||
) |
Relocates the ELF image from src to dst.
This function processes the ELF relocation section 'rela' of size 'size' of the ELF image, formerly located at 'src', to the new location 'dst'. Relocation is necessary for certain variables that cannot be coded as position-independent code.
dst | Address to relocate to. |
src | Former base address of the ELF image. |
rela | Pointer to relocation section of the ELF image. |
size | Size in bytes of the ELF relocation section. |
symtab | Pointer to ELF symbol table. |
symsize | Size in bytes of the ELF symbol table. |
start | Original base address of the ELF image. |
vbase | Pointer to ELF image in virtual memory. |
struct Elf64_Shdr* elf64_find_section_header_name | ( | genvaddr_t | elf_base, |
size_t | elf_bytes, | ||
const char * | section_name | ||
) |
Return pointer to section header with given name.
elf_base | Address of ELF header |
elf_bytes | Size of ELF file. |
section_name | Named section to look for. |
struct Elf64_Shdr* elf64_find_section_header_type | ( | struct Elf64_Shdr * | shdr, |
uint32_t | entries, | ||
uint32_t | type | ||
) |
Return pointer to relocation section ELF header.
This function finds and returns a pointer to the first ELF section header of type 'type'.
shdr | Pointer to head of ELF section header table. |
entries | Number of entries in the ELF section header table. |
type | ELF section header type to look for. |
struct Elf64_Sym* elf64_find_symbol_by_addr | ( | genvaddr_t | elf_base, |
size_t | elf_bytes, | ||
lvaddr_t | addr, | ||
uintptr_t * | sindex | ||
) |
finds the symbol by its address
elf_base | virtual address where the elf image is mapped |
elf_bytes | size of the mapped elf image |
addr | virtual address of the symbol |
sindex | returns the index of the symbol |
struct Elf64_Sym* elf64_find_symbol_by_name | ( | genvaddr_t | elf_base, |
size_t | elf_bytes, | ||
const char * | name, | ||
uint8_t | contains, | ||
uint8_t | type, | ||
uintptr_t * | sindex | ||
) |
finds the symbol by name
elf_base | virtual address where the elf image is mapped |
elf_bytes | size of the mapped elf image |
name | name of the symbol to look for |
contains | if non zero, search for containing rather than exact match |
type | type of the symbol STT_* |
sindex | index where to start and returns the index of the symbol |
errval_t elf64_load | ( | uint16_t | em_machine, |
elf_allocator_fn | allocate_func, | ||
void * | state, | ||
lvaddr_t | base, | ||
size_t | size, | ||
genvaddr_t * | retentry, | ||
genvaddr_t * | ret_tlsbase, | ||
size_t * | ret_tlsinitlen, | ||
size_t * | ret_tlstotallen | ||
) |
Load ELF64 binary image into memory.
This function loads an ELF64 binary image, based at 'base' and of size 'size' into the memory provided by 'allocate'
em_machine | ELF machine type. |
allocate | Memory allocation function. |
state | Pointer to state for allocation function. |
base | Base address of ELF64 binary image in memory. |
size | Size of ELF64 binary image in bytes. |
retentry | Used to return entry point address |
ret_tlsbase | Used to return TLS block base address |
ret_tlsinitlen | Used to return length of initialised TLS data block |
ret_tlstotallen | Used to return total length of TLS data |
void elf64_relocate | ( | genvaddr_t | dst, |
genvaddr_t | src, | ||
struct Elf64_Rela * | rela, | ||
size_t | size, | ||
struct Elf64_Sym * | symtab, | ||
size_t | symsize, | ||
genvaddr_t | start, | ||
void * | vbase | ||
) |
Relocates the ELF image from src to dst.
This function processes the ELF relocation section 'rela' of size 'size' of the ELF image, formerly located at 'src', to the new location 'dst'. Relocation is necessary for certain variables that cannot be coded as position-independent code.
dst | Address to relocate to. |
src | Former base address of the ELF image. |
rela | Pointer to relocation section of the ELF image. |
size | Size in bytes of the ELF relocation section. |
symtab | Pointer to ELF symbol table. |
symsize | Size in bytes of the ELF symbol table. |
start | Original base address of the ELF image (needed for symbol-table-based relocations – we don't touch the symbol table). |
vbase | Pointer to ELF image in virtual memory. |
errval_t elf_get_eh_info | ( | lvaddr_t | elfbase, |
size_t | elfsize, | ||
lvaddr_t * | eh_frame, | ||
size_t * | eh_frame_size, | ||
lvaddr_t * | eh_frame_hdr, | ||
size_t * | eh_frame_hdr_size | ||
) |
obtains the error handling frame information form the elf image
elfbase | virtual base address of the mapped elf |
elfsize | size of the elf in bytes |
eh_frame | returns the virtual address of the eh_frame |
eh_frame_size | returns the size of the eh_frame |
eh_frame_hdr | returns the virtual address of the eh_frame_hdr |
eh_frame_hdr_size | returns the size of the eh_frame_hdr |
errval_t elf_load_tls | ( | uint16_t | em_machine, |
elf_allocator_fn | allocate_func, | ||
void * | state, | ||
lvaddr_t | base, | ||
size_t | size, | ||
genvaddr_t * | retentry, | ||
genvaddr_t * | ret_tlsbase, | ||
size_t * | ret_tlsinitlen, | ||
size_t * | ret_tlstotallen | ||
) |
Load ELF binary image into memory.
This function loads an ELF binary image, based at 'base' and of size 'size' into the memory provided by 'allocate'
em_machine | ELF machine type. |
allocate | Memory allocation function. |
state | Pointer to state for allocation function. |
base | Base address of ELF binary image in memory. |
size | Size of ELF binary image in bytes. |
retentry | Used to return entry point address |
ret_tlsbase | Used to return TLS block base address |
ret_tlssize | Used to return TLS block size |