diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-09-09 17:32:32 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-09-09 17:32:32 -0600 |
commit | ff2590120d50e6d2cb741e4f9b226706a33363a1 (patch) | |
tree | 89915417880151e88dfd56d2a454fb5a013aa188 /nuttx/binfmt | |
parent | 32965a36ee1aa53bc738b37027dcf36fdb712216 (diff) | |
download | px4-nuttx-ff2590120d50e6d2cb741e4f9b226706a33363a1.tar.gz px4-nuttx-ff2590120d50e6d2cb741e4f9b226706a33363a1.tar.bz2 px4-nuttx-ff2590120d50e6d2cb741e4f9b226706a33363a1.zip |
When allocating a stack for a new process using the user-sapce allocator, need to select the address environment first
Diffstat (limited to 'nuttx/binfmt')
-rw-r--r-- | nuttx/binfmt/binfmt_execmodule.c | 28 | ||||
-rw-r--r-- | nuttx/binfmt/binfmt_unloadmodule.c | 10 |
2 files changed, 32 insertions, 6 deletions
diff --git a/nuttx/binfmt/binfmt_execmodule.c b/nuttx/binfmt/binfmt_execmodule.c index dccd225b5..9b8024dde 100644 --- a/nuttx/binfmt/binfmt_execmodule.c +++ b/nuttx/binfmt/binfmt_execmodule.c @@ -135,6 +135,9 @@ static void exec_ctors(FAR void *arg) int exec_module(FAR const struct binary_s *binp) { FAR struct task_tcb_s *tcb; +#ifdef CONFIG_ARCH_ADDRENV + save_addrenv_t oldenv; +#endif FAR uint32_t *stack; pid_t pid; int err; @@ -150,7 +153,7 @@ int exec_module(FAR const struct binary_s *binp) } #endif - bdbg("Executing %s\n", binp->filename); + bvdbg("Executing %s\n", binp->filename); /* Allocate a TCB for the new task. */ @@ -161,6 +164,18 @@ int exec_module(FAR const struct binary_s *binp) goto errout; } + /* Instantiate the address environment containing the destructors */ + +#ifdef CONFIG_ARCH_ADDRENV + ret = up_addrenv_select(&binp->addrenv, &oldenv); + if (ret < 0) + { + bdbg("ERROR: up_addrenv_select() failed: %d\n", ret); + err = -ret; + goto errout_with_tcb; + } +#endif + /* Allocate the stack for the new task (always from the user heap) */ stack = (FAR uint32_t*)kumm_malloc(binp->stacksize); @@ -170,6 +185,17 @@ int exec_module(FAR const struct binary_s *binp) goto errout_with_tcb; } + /* Restore the address environment */ + +#ifdef CONFIG_ARCH_ADDRENV + ret = up_addrenv_restore(&oldenv); + if (ret < 0) + { + bdbg("ERROR: up_addrenv_select() failed: %d\n", ret); + err = -ret; + goto errout_with_stack; + } +#endif /* Initialize the task */ ret = task_init((FAR struct tcb_s *)tcb, binp->filename, binp->priority, diff --git a/nuttx/binfmt/binfmt_unloadmodule.c b/nuttx/binfmt/binfmt_unloadmodule.c index 067e72796..67b957b20 100644 --- a/nuttx/binfmt/binfmt_unloadmodule.c +++ b/nuttx/binfmt/binfmt_unloadmodule.c @@ -93,13 +93,13 @@ static inline int exec_dtors(FAR struct binary_s *binp) #endif int i; - /* Instantiate the address enviroment containing the destructors */ + /* Instantiate the address environment containing the destructors */ #ifdef CONFIG_ARCH_ADDRENV - ret = up_addrenv_select(binp->addrenv, &oldenv); + ret = up_addrenv_select(&binp->addrenv, &oldenv); if (ret < 0) { - bdbg("up_addrenv_select() failed: %d\n", ret); + bdbg("ERROR: up_addrenv_select() failed: %d\n", ret); return ret; } #endif @@ -114,10 +114,10 @@ static inline int exec_dtors(FAR struct binary_s *binp) dtor++; } - /* Restore the address enviroment */ + /* Restore the address environment */ #ifdef CONFIG_ARCH_ADDRENV - return up_addrenv_restore(oldenv); + return up_addrenv_restore(&oldenv); #else return OK; #endif |