elf_loader: add generic callback-based loader

Change-Id: I1dd972a585bc7c805e32c9665d13e248663ccc73
This commit is contained in:
Aidan MacDonald 2026-01-10 22:00:59 +00:00
parent a610998ea4
commit 843322f898
2 changed files with 35 additions and 16 deletions

View file

@ -38,6 +38,7 @@
#include <stdint.h>
#include <stddef.h>
#include <sys/types.h>
enum elf_error
{
@ -83,9 +84,17 @@ struct elf_load_context
size_t num_mmap;
};
typedef int (*elf_read_callback_t) (intptr_t arg, off_t pos, void *buf, size_t size);
int elf_load(elf_read_callback_t read_cb,
intptr_t read_arg,
const struct elf_load_context *ctx,
void **entrypoint);
int elf_loadfd(int fd,
const struct elf_load_context *ctx,
void **entrypoint);
int elf_read_fd_callback(intptr_t fd, off_t pos, void *buf, size_t size);
int elf_loadpath(const char *filename,
const struct elf_load_context *ctx,