summaryrefslogtreecommitdiff
path: root/nuttx/binfmt/binfmt_unloadmodule.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-12-19 17:54:26 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-12-19 17:54:26 +0000
commit913f876fac94f21a683809d9f648e4793f61e237 (patch)
tree1587afb37a0e1b5a87f007f452e147ff3c2dcc04 /nuttx/binfmt/binfmt_unloadmodule.c
parentbbef9f93daeb6a3565c4c28572d73130dfb6ac85 (diff)
downloadpx4-nuttx-913f876fac94f21a683809d9f648e4793f61e237.tar.gz
px4-nuttx-913f876fac94f21a683809d9f648e4793f61e237.tar.bz2
px4-nuttx-913f876fac94f21a683809d9f648e4793f61e237.zip
Incorporate address environment interfaces in binfmt/ logic
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5443 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/binfmt/binfmt_unloadmodule.c')
-rw-r--r--nuttx/binfmt/binfmt_unloadmodule.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/nuttx/binfmt/binfmt_unloadmodule.c b/nuttx/binfmt/binfmt_unloadmodule.c
index 52243fcf7..a0050481c 100644
--- a/nuttx/binfmt/binfmt_unloadmodule.c
+++ b/nuttx/binfmt/binfmt_unloadmodule.c
@@ -86,8 +86,23 @@
static inline void exec_dtors(FAR const struct binary_s *binp)
{
binfmt_dtor_t *dtor = binp->dtors;
+#ifdef CONFIG_ADDRENV
+ hw_addrenv_t oldenv;
+ int ret;
+#endif
int i;
+ /* Instantiate the address enviroment containing the destructors */
+
+#ifdef CONFIG_ADDRENV
+ ret = up_addrenv_select(binp->addrenv, &oldenv);
+ if (ret < 0)
+ {
+ bdbg("up_addrenv_select() failed: %d\n", ret);
+ return ret;
+ }
+#endif
+
/* Execute each destructor */
for (i = 0; i < binp->ndtors; i++)
@@ -97,6 +112,14 @@ static inline void exec_dtors(FAR const struct binary_s *binp)
(*dtor)();
dtor++;
}
+
+ /* Restore the address enviroment */
+
+#ifdef CONFIG_ADDRENV
+ return up_addrenv_restore(oldenv);
+#else
+ return OK;
+#endif
}
#endif
@@ -125,15 +148,23 @@ static inline void exec_dtors(FAR const struct binary_s *binp)
int unload_module(FAR const struct binary_s *binp)
{
+#ifdef CONFIG_BINFMT_CONSTRUCTORS
+ int ret;
+#endif
int i;
if (binp)
{
-
/* Execute C++ desctructors */
#ifdef CONFIG_BINFMT_CONSTRUCTORS
- exec_dtors(binp);
+ ret = exec_dtors(binp);
+ if (ret < 0)
+ {
+ bdbg("exec_ctors() failed: %d\n", ret);
+ set_errno(-ret);
+ return ERROR;
+ }
#endif
/* Unmap mapped address spaces */
@@ -155,6 +186,10 @@ int unload_module(FAR const struct binary_s *binp)
free(binp->alloc[i]);
}
}
+
+ /* Notice that the address environment is not destroyed. This should
+ * happen automatically when the task exits.
+ */
}
return OK;