git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ld-tool portability fix: MacOS build experience
[lunaix-os.git]
/
lunaix-os
/
kernel
/
exe
/
exec.c
diff --git
a/lunaix-os/kernel/exe/exec.c
b/lunaix-os/kernel/exe/exec.c
index 6f2962e8048f947e3b6a056a963ba271fc060a37..0f6e4ecbfad7390ef7816540601d98939bbf4130 100644
(file)
--- a/
lunaix-os/kernel/exe/exec.c
+++ b/
lunaix-os/kernel/exe/exec.c
@@
-120,7
+120,7
@@
exec_load(struct exec_container* container, struct v_file* executable)
if (!argv_extra[1]) {
// If loading a statically linked file, then heap remapping we can do,
// otherwise delayed.
if (!argv_extra[1]) {
// If loading a statically linked file, then heap remapping we can do,
// otherwise delayed.
- create_heap(vmspace(proc),
va_align
(container->exe.end));
+ create_heap(vmspace(proc),
page_aligned
(container->exe.end));
}
if (container->vms_mnt == VMS_SELF) {
}
if (container->vms_mnt == VMS_SELF) {
@@
-137,6
+137,9
@@
exec_load(struct exec_container* container, struct v_file* executable)
memcpy((void*)ustack, (const void*)envp, envp_len);
ustack = copy_to_ustack(ustack, (ptr_t*)ustack);
memcpy((void*)ustack, (const void*)envp, envp_len);
ustack = copy_to_ustack(ustack, (ptr_t*)ustack);
+ } else {
+ ustack -= sizeof(ptr_t);
+ *((ptr_t*)ustack) = 0;
}
if (argv) {
}
if (argv) {
@@
-144,6
+147,9
@@
exec_load(struct exec_container* container, struct v_file* executable)
ustack -= argv_len;
memcpy((void*)ustack, (const void**)argv, argv_len);
ustack -= argv_len;
memcpy((void*)ustack, (const void**)argv, argv_len);
+ } else {
+ ustack -= sizeof(ptr_t);
+ *((ptr_t*)ustack) = 0;
}
for (size_t i = 0; i < 2 && argv_extra[i]; i++) {
}
for (size_t i = 0; i < 2 && argv_extra[i]; i++) {
@@
-195,6
+201,11
@@
exec_load_byname(struct exec_container* container, const char* filename)
goto done;
}
goto done;
}
+ if (!check_itype_any(dnode->inode, F_FILE)) {
+ errno = EISDIR;
+ goto done;
+ }
+
errno = exec_load(container, file);
// It shouldn't matter which pid we passed. As the only reader is
errno = exec_load(container, file);
// It shouldn't matter which pid we passed. As the only reader is
@@
-252,13
+263,13
@@
__DEFINE_LXSYSCALL3(int,
// we will jump to new entry point (_u_start) upon syscall's
// return so execve 'will not return' from the perspective of it's invoker
// we will jump to new entry point (_u_start) upon syscall's
// return so execve 'will not return' from the perspective of it's invoker
- eret_target(current_thread) = container.exe.entry;
-
eret_stack(current_thread) = container.stack_top
;
+ hart_flow_redirect(current_thread->hstate,
+
container.exe.entry, container.stack_top)
;
// these become meaningless once execved!
current_thread->ustack_top = 0;
signal_reset_context(¤t_thread->sigctx);
// these become meaningless once execved!
current_thread->ustack_top = 0;
signal_reset_context(¤t_thread->sigctx);
- signal_reset_regist
er
(__current->sigreg);
+ signal_reset_regist
ry
(__current->sigreg);
done:
// set return value
done:
// set return value