summaryrefslogtreecommitdiff
path: root/nuttx/binfmt
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-09-14 12:40:09 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-09-14 12:40:09 -0600
commit60b7d076c27f4e3450d9beb7131adf787411f529 (patch)
treeecb43b408dde5607cd3609742d9dc5b699d469c0 /nuttx/binfmt
parent353f0c65ac5f95d88b7f372c3732471ffa063dfa (diff)
downloadnuttx-60b7d076c27f4e3450d9beb7131adf787411f529.tar.gz
nuttx-60b7d076c27f4e3450d9beb7131adf787411f529.tar.bz2
nuttx-60b7d076c27f4e3450d9beb7131adf787411f529.zip
Fix an ordering problem in integration of kernel stack logic
Diffstat (limited to 'nuttx/binfmt')
-rw-r--r--nuttx/binfmt/binfmt_execmodule.c28
1 files changed, 13 insertions, 15 deletions
diff --git a/nuttx/binfmt/binfmt_execmodule.c b/nuttx/binfmt/binfmt_execmodule.c
index 3756fbaf6..dae892571 100644
--- a/nuttx/binfmt/binfmt_execmodule.c
+++ b/nuttx/binfmt/binfmt_execmodule.c
@@ -165,8 +165,7 @@ int exec_module(FAR const struct binary_s *binp)
goto errout;
}
-#ifdef CONFIG_ARCH_ADDRENV
-#ifdef CONFIG_BUILD_KERNEL
+#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
/* Instantiate the address environment containing the user heap */
ret = up_addrenv_select(&binp->addrenv, &oldenv);
@@ -183,19 +182,6 @@ int exec_module(FAR const struct binary_s *binp)
up_addrenv_heapsize(&binp->addrenv));
#endif
-#ifdef CONFIG_ARCH_KERNEL_STACK
- /* Allocate the kernel stack */
-
- ret = up_addrenv_kstackalloc(&tcb->cmn);
- if (ret < 0)
- {
- bdbg("ERROR: up_addrenv_select() failed: %d\n", ret);
- err = -ret;
- goto errout_with_addrenv;
- }
-#endif
-#endif
-
/* Allocate the stack for the new task.
*
* REVISIT: This allocation is currently always from the user heap. That
@@ -223,6 +209,18 @@ int exec_module(FAR const struct binary_s *binp)
/* Note that tcb->flags are not modified. 0=normal task */
/* tcb->flags |= TCB_FLAG_TTYPE_TASK; */
+#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
+ /* Allocate the kernel stack */
+
+ ret = up_addrenv_kstackalloc(&tcb->cmn);
+ if (ret < 0)
+ {
+ bdbg("ERROR: up_addrenv_select() failed: %d\n", ret);
+ err = -ret;
+ goto errout_with_addrenv;
+ }
+#endif
+
#ifdef CONFIG_PIC
/* Add the D-Space address as the PIC base address. By convention, this
* must be the first allocated address space.