diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-10-29 19:32:05 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-10-29 19:32:05 +0000 |
commit | 5681b615ec10265a27677bc2ca98fa385460afec (patch) | |
tree | 63a4ac04f182a282aac2d649973c99285b12cad5 /nuttx/binfmt/elf.c | |
parent | 71fad980c5dfe057dd380a05f1ca1e0bfad2ef1f (diff) | |
download | px4-firmware-5681b615ec10265a27677bc2ca98fa385460afec.tar.gz px4-firmware-5681b615ec10265a27677bc2ca98fa385460afec.tar.bz2 px4-firmware-5681b615ec10265a27677bc2ca98fa385460afec.zip |
C++ constructors work with ELF load now
git-svn-id: http://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.c | 28 |
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; |