From 6509a0c0caafb906c077a64cf424b9196ef56bc0 Mon Sep 17 00:00:00 2001 From: nchao Date: Thu, 8 Nov 2018 07:27:14 -0600 Subject: [PATCH] binfmt/ and libs/libc: Make exepath_*() more common: 1. Move exepath_*() related code to libc/misc 1. Rename exepath_ to envpath_ 2. Rename BINFMT_EXEPATH to LIB_ENVPATH libs/libc/modlib: Add pre module library symbol table support --- Documentation/NuttXBinfmt.html | 54 +++--- Documentation/NuttxUserGuide.html | 12 +- binfmt/Kconfig | 10 +- binfmt/Makefile | 4 - binfmt/binfmt_exec.c | 2 +- binfmt/binfmt_loadmodule.c | 11 +- binfmt/libpcode/README.txt | 2 +- binfmt/pcode.c | 2 +- configs/lc823450-xgevk/elf/defconfig | 2 +- configs/lc823450-xgevk/krndis/defconfig | 2 +- configs/lc823450-xgevk/posix_spawn/defconfig | 2 +- configs/lc823450-xgevk/rndis/defconfig | 2 +- configs/olimex-stm32-p407/kelf/defconfig | 2 +- configs/sim/bas/defconfig | 2 +- configs/sim/bluetooth/defconfig | 2 +- configs/sim/ipforward/defconfig | 2 +- configs/sim/loadable/defconfig | 2 +- configs/sim/minibasic/defconfig | 2 +- configs/sim/nsh/defconfig | 2 +- configs/sim/udgram/defconfig | 2 +- configs/sim/unionfs/defconfig | 2 +- configs/sim/userfs/defconfig | 2 +- configs/sim/ustream/defconfig | 2 +- configs/stm32f4discovery/elf/defconfig | 2 +- .../stm32f4discovery/posix_spawn/defconfig | 2 +- include/nuttx/binfmt/binfmt.h | 95 +---------- include/nuttx/envpath.h | 159 ++++++++++++++++++ include/nuttx/lib/modlib.h | 2 - include/spawn.h | 2 +- include/sys/syscall.h | 2 +- libs/libc/misc/Kconfig | 8 + libs/libc/misc/Make.defs | 6 + .../libc/misc/lib_envpath.c | 100 +++++------ libs/libc/modlib/Kconfig | 20 +++ libs/libc/modlib/modlib_symbols.c | 10 +- libs/libc/modlib/modlib_symtab.c | 44 ++++- libs/libc/unistd/lib_execl.c | 2 +- sched/task/task_execv.c | 2 +- sched/task/task_posixspawn.c | 10 +- sched/task/task_spawn.c | 2 +- syscall/syscall.csv | 4 +- syscall/syscall_lookup.h | 2 +- tools/cfgdefine.c | 2 + 43 files changed, 368 insertions(+), 235 deletions(-) create mode 100644 include/nuttx/envpath.h rename binfmt/binfmt_exepath.c => libs/libc/misc/lib_envpath.c (76%) diff --git a/Documentation/NuttXBinfmt.html b/Documentation/NuttXBinfmt.html index b6c19e9cdc..653d1ea198 100644 --- a/Documentation/NuttXBinfmt.html +++ b/Documentation/NuttXBinfmt.html @@ -186,7 +186,7 @@ struct binary_s -

2.3.8 exepath_init()

+

2.3.8 envpath_init()

Function Prototype:

Description:

@@ -361,31 +361,31 @@ EXEPATH_HANDLE exepath_init(void);

  1. - Call exepath_init() to initialize for the traversal. - exepath_init() will return an opaque handle that can then be provided to exepath_next() and exepath_release(). + Call envpath_init() to initialize for the traversal. + envpath_init() will return an opaque handle that can then be provided to envpath_next() and envpath_release().
  2. - Call exepath_next() repeatedly to examine every file that lies in the directories of the PATH variable. + Call envpath_next() repeatedly to examine every file that lies in the directories of the PATH variable.
  3. - Call exepath_release() to free resources set aside by exepath_init(). + Call envpath_release() to free resources set aside by envpath_init().

Input Parameters: None

Returned Value:

-

2.3.9 exepath_next()

+

2.3.9 envpath_next()

Function Prototype:

Description:

@@ -394,7 +394,7 @@ FAR char *exepath_next(EXEPATH_HANDLE handle, FAR const char *relpath);

Input Parameters:

Returned Value:

@@ -410,27 +410,27 @@ FAR char *exepath_next(EXEPATH_HANDLE handle, FAR const char *relpath);

NULLrelpath from any absolute path in the PATH variable. - In this case, there is no point in calling exepath_next() further; exepath_release() must be called to release resources set aside by expath_init(). + In this case, there is no point in calling envpath_next() further; envpath_release() must be called to release resources set aside by expath_init().

-

2.3.10- exepath_release()

+

2.3.10- envpath_release()

Function Prototype:

Description:

Input Parameters:

Returned Value: None

diff --git a/Documentation/NuttxUserGuide.html b/Documentation/NuttxUserGuide.html index b2328be4fa..fea8cf2840 100644 --- a/Documentation/NuttxUserGuide.html +++ b/Documentation/NuttxUserGuide.html @@ -875,7 +875,7 @@ int exec(FAR const char *filename, FAR char * const *argv,
  • filename: The path to the program to be executed. - If CONFIG_BINFMT_EXEPATH is defined in the configuration, then this may be a relative path from the current working directory. + If CONFIG_LIB_ENVPATH is defined in the configuration, then this may be a relative path from the current working directory. Otherwise, path must be the absolute path to the program.
  • @@ -969,7 +969,7 @@ int execv(FAR const char *path, FAR char *const argv[]);
  • path: The path to the program to be executed. - If CONFIG_BINFMT_EXEPATH is defined in the configuration, then this may be a relative path from the current working directory. + If CONFIG_LIB_ENVPATH is defined in the configuration, then this may be a relative path from the current working directory. Otherwise, path must be the absolute path to the program.
  • @@ -1013,7 +1013,7 @@ int execl(FAR const char *path, ...);
  • path: The path to the program to be executed. - If CONFIG_BINFMT_EXEPATH is defined in the configuration, then this may be a relative path from the current working directory. + If CONFIG_LIB_ENVPATH is defined in the configuration, then this may be a relative path from the current working directory. Otherwise, path must be the absolute path to the program.
  • @@ -1074,7 +1074,7 @@ int posix_spawnp(FAR pid_t *pid, FAR const char *file,

    NOTE: NuttX provides only one implementation: - If CONFIG_BINFMT_EXEPATH is defined, then only posix_spawnp() behavior is supported; otherwise, only posix_spawn behavior is supported. + If CONFIG_LIB_ENVPATH is defined, then only posix_spawnp() behavior is supported; otherwise, only posix_spawn behavior is supported.

  • @@ -1156,8 +1156,8 @@ int posix_spawnp(FAR pid_t *pid, FAR const char *file,