summaryrefslogtreecommitdiff
path: root/nuttx/include
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/include
parentade5fb42679b7e890f29487ca850c65f9944fa1e (diff)
downloadpx4-nuttx-9e45144d3ad1420908cfdf84306c76f637829023.tar.gz
px4-nuttx-9e45144d3ad1420908cfdf84306c76f637829023.tar.bz2
px4-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/include')
-rw-r--r--nuttx/include/nuttx/binfmt/binfmt.h25
-rw-r--r--nuttx/include/nuttx/binfmt/elf.h19
2 files changed, 31 insertions, 13 deletions
diff --git a/nuttx/include/nuttx/binfmt/binfmt.h b/nuttx/include/nuttx/binfmt/binfmt.h
index 82e5f3557..0c18bfc49 100644
--- a/nuttx/include/nuttx/binfmt/binfmt.h
+++ b/nuttx/include/nuttx/binfmt/binfmt.h
@@ -49,9 +49,15 @@
* Pre-processor Definitions
****************************************************************************/
+#define BINFMT_NALLOC 2
+
/****************************************************************************
* Public Types
****************************************************************************/
+/* The type of one C++ constructor or destructor */
+
+typedef FAR void (*elf_ctor_t)(void);
+typedef FAR void (*elf_dtor_t)(void);
/* This describes the file to be loaded */
@@ -70,9 +76,15 @@ struct binary_s
*/
main_t entrypt; /* Entry point into a program module */
- FAR void *ispace; /* Memory-mapped, I-space (.text) address */
- FAR struct dspace_s *dspace; /* Address of the allocated .data/.bss space */
- size_t isize; /* Size of the I-space region (needed for munmap) */
+ FAR void *mapped; /* Memory-mapped, address space */
+ FAR void *alloc[BINFMT_NALLOC]; /* Allocated address spaces */
+#ifdef CONFIG_BINFMT_CONSTRUCTORS
+ elf_ctor_t *ctors; /* Pointer to a list of constructors */
+ elf_dtor_t *dtors; /* Pointer to a list of destructors */
+ uint16_t nctors; /* Number of constructors in the list */
+ uint16_t ndtors; /* Number of destructors in the list */
+#endif
+ size_t mapsize; /* Size of the mapped address region (needed for munmap) */
size_t stacksize; /* Size of the stack in bytes (unallocated) */
};
@@ -151,7 +163,12 @@ EXTERN int load_module(FAR struct binary_s *bin);
*
* Description:
* Unload a (non-executing) module from memory. If the module has
- * been started (via exec_module), calling this will be fatal.
+ * been started (via exec_module) and has not exited, calling this will
+ * be fatal.
+ *
+ * However, this function must be called after the module exist. How
+ * this is done is up to your logic. Perhaps you register it to be
+ * called by on_exit()?
*
* Returned Value:
* This is a NuttX internal function so it follows the convention that
diff --git a/nuttx/include/nuttx/binfmt/elf.h b/nuttx/include/nuttx/binfmt/elf.h
index 4770d82a3..2e3cb8623 100644
--- a/nuttx/include/nuttx/binfmt/elf.h
+++ b/nuttx/include/nuttx/binfmt/elf.h
@@ -43,10 +43,13 @@
#include <nuttx/config.h>
#include <sys/types.h>
+
#include <stdint.h>
#include <stdbool.h>
#include <elf32.h>
+#include <nuttx/binfmt/binfmt.h>
+
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@@ -59,9 +62,6 @@
/****************************************************************************
* Public Types
****************************************************************************/
-/* The type of one C++ constructor */
-
-typedef FAR void (*elf_ctor_t)(void);
/* This struct provides a desciption of the currently loaded instantiation
* of an ELF binary.
@@ -72,17 +72,18 @@ struct elf_loadinfo_s
uintptr_t alloc; /* Allocated memory with the ELF file is loaded */
size_t allocsize; /* Size of the memory allocation */
off_t filelen; /* Length of the entire ELF file */
- int filfd; /* Descriptor for the file being loaded */
-#ifdef CONFIG_ELF_CONSTRUCTORS
- elf_ctor_t ctors; /* Pointer to a list of constructors */
+ Elf32_Ehdr ehdr; /* Buffered ELF file header */
+ FAR Elf32_Shdr *shdr; /* Buffered ELF section headers */
+ uint8_t *iobuffer; /* File I/O buffer */
+#ifdef CONFIG_BINFMT_CONSTRUCTORS
+ elf_ctor_t *ctors; /* Pointer to a list of constructors */
+ bool newabi; /* True: ctors in 'alloc' */
uint16_t nctors; /* Number of constructors */
#endif
uint16_t symtabidx; /* Symbol table section index */
uint16_t strtabidx; /* String table section index */
uint16_t buflen; /* size of iobuffer[] */
- Elf32_Ehdr ehdr; /* Buffered ELF file header */
- FAR Elf32_Shdr *shdr; /* Buffered ELF section headers */
- uint8_t *iobuffer; /* File I/O buffer */
+ int filfd; /* Descriptor for the file being loaded */
};
/****************************************************************************