syscall/: The non-standard interface exec() is now enshrined as a official NuttX API. I really dislike doing this but I think that this is probably the only want to load programs in the protected mode. It is currently used by some example code under apps/ that generate their own symbol tables for linking. Other file execution APIs relay on a symbol table provided by the OS. In the protected mode, the OS cannot provide any meaning symbol table for execution of code in the user-space blob so that is they exec() is really needed in that build case. And, finally, the interface is completely useless and will not be supported in the KERNEL build mode where the contrary is true: An application process cannot provide any meaning symbolic information for use in linking a different process.

This commit is contained in:
Gregory Nutt 2017-10-03 07:09:35 -06:00
parent 5512813157
commit 8e966546c1
4 changed files with 31 additions and 15 deletions

View File

@ -183,16 +183,23 @@
# define SYS_insmod __SYS_insmod
# define SYS_rmmod (__SYS_insmod+1)
# define SYS_modhandle (__SYS_insmod+2)
# define __SYS_posix_spawn (__SYS_insmod+3)
# define __SYS_exec (__SYS_insmod+3)
#else
# define __SYS_posix_spawn __SYS_insmod
# define __SYS_exec __SYS_insmod
#endif
/* The following can only be defined if we are configured to execute
* programs from a file system.
*/
#if !defined(CONFIG_BINFMT_DISABLE) && defined(CONFIG_LIBC_EXECFUNCS)
#ifndef CONFIG_BINFMT_DISABLE
# ifndef CONFIG_BUILD_KERNEL
# define SYS_exec __SYS_exec
# define __SYS_posix_spawn (__SYS_exec+1)
# else
# define __SYS_posix_spawn __SYS_exec
# endif
# ifdef CONFIG_LIBC_EXECFUNCS
# ifdef CONFIG_BINFMT_EXEPATH
# define SYS_posix_spawnp __SYS_posix_spawn
# else
@ -200,8 +207,11 @@
# endif
# define SYS_execv (__SYS_posix_spawn+1)
# define __SYS_signals (__SYS_posix_spawn+2)
#else
# else
# define __SYS_signals __SYS_posix_spawn
# endif
#else
# define __SYS_signals __SYS_exec
#endif
/* The following are only defined is signals are supported in the NuttX

View File

@ -18,6 +18,7 @@
"connect","sys/socket.h","CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET)","int","int","FAR const struct sockaddr*","socklen_t"
"dup","unistd.h","CONFIG_NFILE_DESCRIPTORS > 0","int","int"
"dup2","unistd.h","CONFIG_NFILE_DESCRIPTORS > 0","int","int","int"
"exec","nuttx/binfmt/binfmt.h","!defined(CONFIG_BINFMT_DISABLE) && !defined(CONFIG_BUILD_KERNEL)","int","FAR const char *","FAR char * const *","FAR const struct symtab_s *","int"
"execv","unistd.h","!defined(CONFIG_BINFMT_DISABLE) && defined(CONFIG_LIBC_EXECFUNCS)","int","FAR const char *","FAR char *const []|FAR char *const *"
"exit","stdlib.h","","void","int"
"fcntl","fcntl.h","CONFIG_NFILE_DESCRIPTORS > 0","int","int","int","..."

Can't render this file because it has a wrong number of fields in line 2.

View File

@ -130,14 +130,19 @@ SYSCALL_LOOKUP(up_assert, 2, STUB_up_assert)
* programs from a file system.
*/
#if !defined(CONFIG_BINFMT_DISABLE) && defined(CONFIG_LIBC_EXECFUNCS)
# ifdef CONFIG_BINFMT_EXEPATH
#ifndef CONFIG_BINFMT_DISABLE
#ifndef CONFIG_BUILD_KERNEL
SYSCALL_LOOKUP(exec, 4, STUB_exec)
#endif
#ifdef CONFIG_LIBC_EXECFUNCS
#ifdef CONFIG_BINFMT_EXEPATH
SYSCALL_LOOKUP(posix_spawnp, 6, STUB_posix_spawnp)
# else
#else
SYSCALL_LOOKUP(posix_spawn, 6, STUB_posix_spawn)
# endif
#endif
SYSCALL_LOOKUP(execv, 2, STUB_execv)
#endif
#endif
/* The following are only defined is signals are supported in the NuttX
* configuration.

View File

@ -119,16 +119,16 @@ uintptr_t STUB_waitid(int nbr, uintptr_t parm1, uintptr_t parm2,
* OS modules from a file system.
*/
#ifdef CONFIG_MODULE
uintptr_t STUB_insmod(int nbr, uintptr_t parm1, uintptr_t parm2);
uintptr_t STUB_rmmod(int nbr, uintptr_t parm1);
uintptr_t STUB_modhandle(int nbr, uintptr_t parm1, uintptr_t parm2);
#endif
/* The following can only be defined if we are configured to execute
* programs from a file system.
*/
uintptr_t STUB_exec(int nbr, uintptr_t parm1, uintptr_t parm2,
uintptr_t parm3, uintptr_t parm4);
uintptr_t STUB_posix_spawn(int nbr, uintptr_t parm1, uintptr_t parm2,
uintptr_t parm3, uintptr_t parm4, uintptr_t parm5,
uintptr_t parm6);