From: Matthias Kruk Date: Sun, 3 May 2020 17:22:24 +0000 (+0900) Subject: kernel: Add execeve syscall for execution of ELF files X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=61c710c4734a4237b15b9abea3b2bc130c6f76f2;p=corax kernel: Add execeve syscall for execution of ELF files --- diff --git a/include/corax/syscall.h b/include/corax/syscall.h index c8bccb8..58c7c54 100644 --- a/include/corax/syscall.h +++ b/include/corax/syscall.h @@ -36,6 +36,7 @@ /* Corax-specific variations of POSIX syscalls */ #define SYS_EXECFVE 128 +#define SYS_EXECEVE 129 #define IPC_SEND 0 #define IPC_RECV 1 diff --git a/kernel/core/posixcall.c b/kernel/core/posixcall.c index faea3aa..1bdec66 100644 --- a/kernel/core/posixcall.c +++ b/kernel/core/posixcall.c @@ -293,6 +293,22 @@ int sys_execfve(stack_frame_t *stk) return(ret_val); } +int sys_execeve(stack_frame_t *stk) +{ +/* + void *elfdata; + size_t elfsize; + char **argv; + char **envp; + + elfdata = stk->ebx; + elfsize = stk->ecx; + argv = (char**)stk->edx; + envp = (char**)stk->esi; +*/ + return(-ENOSYS); +} + int sys_vfork(void) { return(process_fork(1)); @@ -480,6 +496,10 @@ int sys_posixcall(stack_frame_t *stk) ret_val = sys_execfve(stk); break; + case SYS_EXECEVE: + ret_val = sys_execeve(stk); + break; + case SYS_MMAP: ret_val = sys_mmap(stk); break; diff --git a/kernel/klibc/posixcall.S b/kernel/klibc/posixcall.S index 3796215..3180f8b 100644 --- a/kernel/klibc/posixcall.S +++ b/kernel/klibc/posixcall.S @@ -10,6 +10,7 @@ .global _exit .global fork .global execfve + .global execeve .global brk .global sbrk .global mmap @@ -51,6 +52,19 @@ execfve: popl %ebx ret +execeve: + pushl %ebx + + movl $SYS_EXECEVE, %eax + movl 8(%esp), %ebx + movl 12(%esp), %ecx + movl 16(%esp), %edx + movl 20(%esp), %esi + int $SYSCALL_POSIX + + popl %ebx + ret + brk: pushl $0 call sbrk diff --git a/libc/posixcall.S b/libc/posixcall.S index 6aecef1..696d2ee 100644 --- a/libc/posixcall.S +++ b/libc/posixcall.S @@ -36,6 +36,20 @@ exit: popl %ebx ret +.global execeve +execeve: + pushl %ebx + + movl $SYS_EXECEVE, %eax + movl 8(%esp), %ebx + movl 12(%esp), %ecx + movl 16(%esp), %edx + movl 20(%esp), %esi + int $SYSCALL_POSIX + + popl %ebx + ret + .global wait wait: pushl %ebx