aboutsummaryrefslogtreecommitdiff
path: root/nuttx/binfmt/elf.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
commit56a650461894d8ab541277010e93fd5ca75f9f0d (patch)
tree1587afb37a0e1b5a87f007f452e147ff3c2dcc04 /nuttx/binfmt/elf.c
parent8ae8d43ae254c55a8eaa9c48d38ca8dfa63987be (diff)
downloadpx4-firmware-56a650461894d8ab541277010e93fd5ca75f9f0d.tar.gz
px4-firmware-56a650461894d8ab541277010e93fd5ca75f9f0d.tar.bz2
px4-firmware-56a650461894d8ab541277010e93fd5ca75f9f0d.zip
Incorporate address environment interfaces in binfmt/ logic
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5443 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/binfmt/elf.c')
-rw-r--r--nuttx/binfmt/elf.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/nuttx/binfmt/elf.c b/nuttx/binfmt/elf.c
index ea1e7b0ca..bcebf13ca 100644
--- a/nuttx/binfmt/elf.c
+++ b/nuttx/binfmt/elf.c
@@ -215,9 +215,22 @@ static int elf_loadbinary(struct binary_s *binp)
/* Return the load information */
binp->entrypt = (main_t)(loadinfo.elfalloc + loadinfo.ehdr.e_entry);
- binp->alloc[0] = (FAR void *)loadinfo.elfalloc;
binp->stacksize = CONFIG_ELF_STACKSIZE;
+ /* Add the ELF allocation to the alloc[] only if there is no address
+ * enironment. If there is an address environment, it will automatically
+ * be freed when the function exits
+ *
+ * REVISIT: If the module is loaded then unloaded, wouldn't this cause
+ * a memory leak?
+ */
+
+#ifdef CONFIG_ADDRENV
+# warning "REVISIT"
+#else
+ binp->alloc[0] = (FAR void *)loadinfo.elfalloc;
+#endif
+
#ifdef CONFIG_BINFMT_CONSTRUCTORS
/* Save information about constructors. NOTE: desctructors are not
* yet supported.
@@ -232,6 +245,14 @@ static int elf_loadbinary(struct binary_s *binp)
binp->ndtors = loadinfo.ndtors;
#endif
+#ifdef CONFIG_ADDRENV
+ /* Save the address environment. This will be needed when the module is
+ * executed for the up_addrenv_assign() call.
+ */
+
+ binp->addrenv = loadinfo.addrenv;
+#endif
+
elf_dumpbuffer("Entry code", (FAR const uint8_t*)binp->entrypt,
MIN(loadinfo.allocsize - loadinfo.ehdr.e_entry, 512));