3 #include <minix/type.h>
4 #include <minix/const.h>
12 #include <minix/ipc.h>
13 #include <minix/com.h>
14 #include <minix/callnr.h>
16 #include <minix/ipc.h>
17 #include <minix/syslib.h>
19 #include <machine/elf.h>
21 int libexec_alloc_mmap_prealloc_junk(struct exec_info
*execi
, vir_bytes vaddr
, size_t len
)
23 if(minix_mmap_for(execi
->proc_e
, (void *) vaddr
, len
,
24 PROT_READ
|PROT_WRITE
|PROT_EXEC
,
25 MAP_ANON
|MAP_PREALLOC
|MAP_UNINITIALIZED
|MAP_FIXED
, -1, 0) == MAP_FAILED
) {
32 int libexec_alloc_mmap_prealloc_cleared(struct exec_info
*execi
, vir_bytes vaddr
, size_t len
)
34 if(minix_mmap_for(execi
->proc_e
, (void *) vaddr
, len
,
35 PROT_READ
|PROT_WRITE
|PROT_EXEC
,
36 MAP_ANON
|MAP_PREALLOC
|MAP_FIXED
, -1, 0) == MAP_FAILED
) {
43 int libexec_alloc_mmap_ondemand(struct exec_info
*execi
, vir_bytes vaddr
, size_t len
)
45 if(minix_mmap_for(execi
->proc_e
, (void *) vaddr
, len
,
46 PROT_READ
|PROT_WRITE
|PROT_EXEC
,
47 MAP_ANON
|MAP_FIXED
, -1, 0) == MAP_FAILED
) {
54 int libexec_clearproc_vm_procctl(struct exec_info
*execi
)
56 return vm_procctl_clear(execi
->proc_e
);
59 int libexec_clear_sys_memset(struct exec_info
*execi
, vir_bytes vaddr
, size_t len
)
61 return sys_memset(execi
->proc_e
, 0, vaddr
, len
);
64 int libexec_copy_memcpy(struct exec_info
*execi
,
65 off_t off
, vir_bytes vaddr
, size_t len
)
67 assert(off
+ len
<= execi
->hdr_len
);
68 memcpy((char *) vaddr
, (char *) execi
->hdr
+ off
, len
);
72 int libexec_clear_memset(struct exec_info
*execi
, vir_bytes vaddr
, size_t len
)
74 memset((char *) vaddr
, 0, len
);
78 int libexec_pm_newexec(endpoint_t proc_e
, struct exec_info
*e
)
83 memset(&m
, 0, sizeof(m
));
84 m
.m_type
= PM_EXEC_NEW
;
85 m
.m_lexec_pm_exec_new
.endpt
= proc_e
;
86 m
.m_lexec_pm_exec_new
.ptr
= (vir_bytes
)e
;
87 if ((r
= ipc_sendrec(PM_PROC_NR
, &m
)) != OK
) return(r
);
89 e
->allow_setuid
= !!m
.m_pm_lexec_exec_new
.suid
;