summaryrefslogtreecommitdiff
path: root/nuttx/binfmt/elf.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-10-29 19:32:05 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-10-29 19:32:05 +0000
commit9e45144d3ad1420908cfdf84306c76f637829023 (patch)
tree63a4ac04f182a282aac2d649973c99285b12cad5 /nuttx/binfmt/elf.c
parentade5fb42679b7e890f29487ca850c65f9944fa1e (diff)
downloadnuttx-9e45144d3ad1420908cfdf84306c76f637829023.tar.gz
nuttx-9e45144d3ad1420908cfdf84306c76f637829023.tar.bz2
nuttx-9e45144d3ad1420908cfdf84306c76f637829023.zip
C++ constructors work with ELF load now
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5273 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/binfmt/elf.c')
-rw-r--r--nuttx/binfmt/elf.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/nuttx/binfmt/elf.c b/nuttx/binfmt/elf.c
index 57123ed95..26057ffc1 100644
--- a/nuttx/binfmt/elf.c
+++ b/nuttx/binfmt/elf.c
@@ -114,7 +114,7 @@ static void elf_dumploadinfo(FAR struct elf_loadinfo_s *loadinfo)
bdbg(" alloc: %08lx\n", (long)loadinfo->alloc);
bdbg(" allocsize: %ld\n", (long)loadinfo->allocsize);
bdbg(" filelen: %ld\n", (long)loadinfo->filelen);
-#ifdef CONFIG_ELF_CONSTRUCTORS
+#ifdef CONFIG_BINFMT_CONSTRUCTORS
bdbg(" ctors: %08lx\n", (long)loadinfo->ctors);
bdbg(" nctors: %d\n", loadinfo->nctors);
#endif
@@ -211,13 +211,31 @@ static int elf_loadbinary(struct binary_s *binp)
/* Return the load information */
binp->entrypt = (main_t)(loadinfo.alloc + loadinfo.ehdr.e_entry);
- binp->ispace = (void*)loadinfo.alloc;
- binp->dspace = NULL;
- binp->isize = loadinfo.allocsize;
+ binp->alloc[0] = (FAR void *)loadinfo.alloc;
binp->stacksize = CONFIG_ELF_STACKSIZE;
+#ifdef CONFIG_BINFMT_CONSTRUCTORS
+ /* Save information about constructors. NOTE: desctructors are not
+ * yet supported.
+ */
+
+ binp->ctors = loadinfo.ctors;
+ binp->nctors = loadinfo.nctors;
+
+ /* Was memory allocated for constructors? */
+
+ if (!loadinfo.newabi)
+ {
+ /* Yes.. save the allocation address so that it can be freed by
+ * unload module.
+ */
+
+ binp->alloc[1] = (FAR void *)loadinfo.ctors;
+ }
+#endif
+
elf_dumpbuffer("Entry code", (FAR const uint8_t*)binp->entrypt,
- MIN(binp->isize - loadinfo.ehdr.e_entry, 512));
+ MIN(loadinfo.allocsize - loadinfo.ehdr.e_entry, 512));
elf_uninit(&loadinfo);
return OK;