summaryrefslogtreecommitdiff
path: root/nuttx/include
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-10-29 20:43:35 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-10-29 20:43:35 +0000
commitb7c575a7ec2b15a37e888f94408680303ace71a7 (patch)
treeb7c28580644d845360274723b39b8367ed109bba /nuttx/include
parent9e45144d3ad1420908cfdf84306c76f637829023 (diff)
downloadpx4-nuttx-b7c575a7ec2b15a37e888f94408680303ace71a7.tar.gz
px4-nuttx-b7c575a7ec2b15a37e888f94408680303ace71a7.tar.bz2
px4-nuttx-b7c575a7ec2b15a37e888f94408680303ace71a7.zip
C++ static destructors work with ELF load too now
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5274 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/include')
-rw-r--r--nuttx/include/nuttx/binfmt/binfmt.h10
-rw-r--r--nuttx/include/nuttx/binfmt/elf.h44
2 files changed, 36 insertions, 18 deletions
diff --git a/nuttx/include/nuttx/binfmt/binfmt.h b/nuttx/include/nuttx/binfmt/binfmt.h
index 0c18bfc49..49ab37264 100644
--- a/nuttx/include/nuttx/binfmt/binfmt.h
+++ b/nuttx/include/nuttx/binfmt/binfmt.h
@@ -49,15 +49,15 @@
* Pre-processor Definitions
****************************************************************************/
-#define BINFMT_NALLOC 2
+#define BINFMT_NALLOC 3
/****************************************************************************
* Public Types
****************************************************************************/
/* The type of one C++ constructor or destructor */
-typedef FAR void (*elf_ctor_t)(void);
-typedef FAR void (*elf_dtor_t)(void);
+typedef FAR void (*binfmt_ctor_t)(void);
+typedef FAR void (*binfmt_dtor_t)(void);
/* This describes the file to be loaded */
@@ -79,8 +79,8 @@ struct binary_s
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 */
+ FAR binfmt_ctor_t *ctors; /* Pointer to a list of constructors */
+ FAR binfmt_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
diff --git a/nuttx/include/nuttx/binfmt/elf.h b/nuttx/include/nuttx/binfmt/elf.h
index 2e3cb8623..432e57f0f 100644
--- a/nuttx/include/nuttx/binfmt/elf.h
+++ b/nuttx/include/nuttx/binfmt/elf.h
@@ -59,6 +59,17 @@
# define CONFIG_ELF_ALIGN_LOG2 2
#endif
+/* Allocation array size and indices */
+
+#define LIBELF_ELF_ALLOC 0
+#ifdef CONFIG_BINFMT_CONSTRUCTORS
+# define LIBELF_CTORS_ALLOC 1
+# define LIBELF_CTPRS_ALLOC 2
+# define LIBELF_NALLOC 3
+#else
+# define LIBELF_NALLOC 1
+#endif
+
/****************************************************************************
* Public Types
****************************************************************************/
@@ -69,21 +80,28 @@
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 */
- Elf32_Ehdr ehdr; /* Buffered ELF file header */
- FAR Elf32_Shdr *shdr; /* Buffered ELF section headers */
- uint8_t *iobuffer; /* File I/O buffer */
+ /* The alloc[] array holds memory that persists after the ELF module has
+ * been loaded.
+ */
+
+ uintptr_t elfalloc; /* Memory allocated when ELF file was loaded */
+ size_t elfsize; /* Size of the ELF memory allocation */
+ off_t filelen; /* Length of the entire ELF file */
+ 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 */
+ FAR void *ctoralloc; /* Memory allocated for ctors */
+ FAR void *dtoralloc; /* Memory allocated dtors */
+ FAR binfmt_ctor_t *ctors; /* Pointer to a list of constructors */
+ FAR binfmt_dtor_t *dtors; /* Pointer to a list of destructors */
+ uint16_t nctors; /* Number of constructors */
+ uint16_t ndtors; /* Number of destructors */
#endif
- uint16_t symtabidx; /* Symbol table section index */
- uint16_t strtabidx; /* String table section index */
- uint16_t buflen; /* size of iobuffer[] */
- int filfd; /* Descriptor for the file being loaded */
+ uint16_t symtabidx; /* Symbol table section index */
+ uint16_t strtabidx; /* String table section index */
+ uint16_t buflen; /* size of iobuffer[] */
+ int filfd; /* Descriptor for the file being loaded */
};
/****************************************************************************