4 #include <sys/exec_elf.h>
8 typedef int (*libexec_loadfunc_t
)(struct exec_info
*execi
,
9 off_t offset
, off_t vaddr
, size_t len
);
11 typedef int (*libexec_clearfunc_t
)(struct exec_info
*execi
,
12 off_t vaddr
, size_t len
);
14 typedef int (*libexec_allocfunc_t
)(struct exec_info
*execi
,
15 off_t vaddr
, size_t len
);
17 typedef int (*libexec_procclearfunc_t
)(struct exec_info
*execi
);
20 /* Filled in by libexec caller */
21 endpoint_t proc_e
; /* Process endpoint */
22 char *hdr
; /* Header or full image */
23 size_t hdr_len
; /* Size of hdr */
24 vir_bytes frame_len
; /* Stack size */
25 char progname
[PROC_NAME_LEN
]; /* Program name */
26 uid_t new_uid
; /* Process UID after exec */
27 gid_t new_gid
; /* Process GID after exec */
28 int allow_setuid
; /* Allow set{u,g}id execution? */
29 vir_bytes stack_size
; /* Desired stack size */
30 vir_bytes load_offset
; /* Desired load offset */
31 off_t filesize
; /* How big is the file */
33 /* Callback pointers for use by libexec */
34 libexec_loadfunc_t copymem
; /* Copy callback */
35 libexec_clearfunc_t clearmem
; /* Clear callback */
36 libexec_allocfunc_t allocmem_prealloc
; /* Alloc callback */
37 libexec_allocfunc_t allocmem_ondemand
; /* Alloc callback */
38 libexec_procclearfunc_t clearproc
; /* Clear process callback */
39 void *opaque
; /* Callback data */
41 /* Filled in by libexec load function */
42 vir_bytes load_base
; /* Where executable is loaded */
43 vir_bytes pc
; /* Entry point of exec file */
44 vir_bytes stack_high
; /* High stack addr */
47 int elf_has_interpreter(char *exec_hdr
, int hdr_len
, char *interp
, int maxsz
);
48 int elf_phdr(char *exec_hdr
, int hdr_len
, vir_bytes
*phdr
);
50 void libexec_patch_ptr(char stack
[ARG_MAX
], vir_bytes base
);
51 int libexec_pm_newexec(endpoint_t proc_e
, struct exec_info
*execi
);
53 typedef int (*libexec_exec_loadfunc_t
)(struct exec_info
*execi
);
54 int libexec_load_elf(struct exec_info
*execi
);
56 int libexec_copy_memcpy(struct exec_info
*execi
, off_t offset
, off_t vaddr
, size_t len
);
57 int libexec_clear_memset(struct exec_info
*execi
, off_t vaddr
, size_t len
);
58 int libexec_alloc_mmap_prealloc(struct exec_info
*execi
, off_t vaddr
, size_t len
);
59 int libexec_alloc_mmap_ondemand(struct exec_info
*execi
, off_t vaddr
, size_t len
);
60 int libexec_clearproc_vm_procctl(struct exec_info
*execi
);
61 int libexec_clear_sys_memset(struct exec_info
*execi
, off_t vaddr
, size_t len
);
63 #endif /* !_LIBEXEC_H_ */