4 #include <sys/exec_elf.h>
8 typedef int (*libexec_loadfunc_t
)(struct exec_info
*execi
,
9 off_t offset
, vir_bytes vaddr
, size_t len
);
11 typedef int (*libexec_clearfunc_t
)(struct exec_info
*execi
,
12 vir_bytes vaddr
, size_t len
);
14 typedef int (*libexec_allocfunc_t
)(struct exec_info
*execi
,
15 vir_bytes vaddr
, size_t len
);
17 typedef int (*libexec_procclearfunc_t
)(struct exec_info
*execi
);
19 typedef int (*libexec_mmap_t
)(struct exec_info
*execi
,
20 vir_bytes vaddr
, vir_bytes len
, vir_bytes foffset
, u16_t clearend
,
24 /* Filled in by libexec caller */
25 endpoint_t proc_e
; /* Process endpoint */
26 char *hdr
; /* Header or full image */
27 size_t hdr_len
; /* Size of hdr */
28 vir_bytes frame_len
; /* Stack size */
29 char progname
[PROC_NAME_LEN
]; /* Program name */
30 uid_t new_uid
; /* Process UID after exec */
31 gid_t new_gid
; /* Process GID after exec */
32 int allow_setuid
; /* Allow set{u,g}id execution? */
33 vir_bytes stack_size
; /* Desired stack size */
34 vir_bytes load_offset
; /* Desired load offset */
35 vir_bytes text_size
; /* Text segment size */
36 vir_bytes data_size
; /* Data segment size */
37 off_t filesize
; /* How big is the file */
39 /* Callback pointers for use by libexec */
40 libexec_loadfunc_t copymem
; /* Copy callback */
41 libexec_clearfunc_t clearmem
; /* Clear callback */
42 libexec_allocfunc_t allocmem_prealloc_cleared
; /* Alloc callback */
43 libexec_allocfunc_t allocmem_prealloc_junk
; /* Alloc callback */
44 libexec_allocfunc_t allocmem_ondemand
; /* Alloc callback */
45 libexec_procclearfunc_t clearproc
; /* Clear process callback */
46 libexec_mmap_t memmap
; /* mmap callback */
47 void *opaque
; /* Callback data */
49 /* Filled in by libexec load function */
50 vir_bytes load_base
; /* Where executable is loaded */
51 vir_bytes pc
; /* Entry point of exec file */
52 vir_bytes stack_high
; /* High stack addr */
55 int elf_has_interpreter(char *exec_hdr
, int hdr_len
, char *interp
, int maxsz
);
56 int elf_phdr(char *exec_hdr
, int hdr_len
, vir_bytes
*phdr
);
58 int libexec_pm_newexec(endpoint_t proc_e
, struct exec_info
*execi
);
60 typedef int (*libexec_exec_loadfunc_t
)(struct exec_info
*execi
);
61 int libexec_load_elf(struct exec_info
*execi
);
63 /* Default callbacks for kernel. */
64 int libexec_copy_memcpy(struct exec_info
*execi
, off_t offset
, vir_bytes vaddr
, size_t len
);
65 int libexec_clear_memset(struct exec_info
*execi
, vir_bytes vaddr
, size_t len
);
67 /* Default callbacks. */
68 int libexec_alloc_mmap_prealloc_cleared(struct exec_info
*execi
, vir_bytes vaddr
, size_t len
);
69 int libexec_alloc_mmap_prealloc_junk(struct exec_info
*execi
, vir_bytes vaddr
, size_t len
);
70 int libexec_alloc_mmap_ondemand(struct exec_info
*execi
, vir_bytes vaddr
, size_t len
);
71 int libexec_clearproc_vm_procctl(struct exec_info
*execi
);
72 int libexec_clear_sys_memset(struct exec_info
*execi
, vir_bytes vaddr
, size_t len
);
74 #endif /* !_LIBEXEC_H_ */