Fix an ordering problem in integration of kernel stack logic

This commit is contained in:
Gregory Nutt 2014-09-14 12:40:09 -06:00
parent 3649dab9bd
commit 2eb71d5a35

View file

@ -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.