diff options
Diffstat (limited to 'api/lib/elf.h')
| -rw-r--r-- | api/lib/elf.h | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/api/lib/elf.h b/api/lib/elf.h index 951fc25..ea0d6cc 100644 --- a/api/lib/elf.h +++ b/api/lib/elf.h @@ -5,13 +5,37 @@ #include <stdbool.h> #include <stddef.h> +#include <posix/sys/types.h> + #ifdef __x86_64__ # define elf_validate elf64_validate # define elf_size elf64_size #endif -bool elf64_validate(Elf64_Ehdr *ehdr, unsigned type, unsigned machine); -size_t elf64_size(Elf64_Ehdr *ehdr, Elf64_Phdr *phdr); -void *elf64_dt_ptr(void *base, Elf64_Dyn *dyntab, unsigned long dt_type); +struct linear_buffer +{ + char *base; + size_t length; +}; + +struct elf64_image +{ + struct linear_buffer buffer; + struct + { + Elf64_Ehdr *file; + Elf64_Phdr *segments; + Elf64_Shdr *sections; + } + headers; +}; + +bool elf64_validate(Elf64_Ehdr const *ehdr, unsigned type, unsigned machine); +bool elf64_validate_fd(int fd, unsigned type, unsigned machine); +size_t elf64_size(Elf64_Ehdr const *ehdr, Elf64_Phdr *phdr); +size_t elf64_size_fd(int fd); +ssize_t elf64_load_segments(int fd, size_t buffer_size, char buffer[buffer_size]); +void *elf64_dt_ptr(char *base, Elf64_Dyn *dyntab, unsigned long dt_type); uintptr_t elf64_dt_val(Elf64_Dyn *dyntab, unsigned long dt_type); +struct elf64_image elf64_open(const char *path); |
