C++ static destructors work with ELF load too now

git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5274 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2012-10-29 20:43:35 +00:00
parent 5681b615ec
commit b48508c844
13 changed files with 344 additions and 89 deletions
+5 -5
View File
@@ -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
+31 -13
View File
@@ -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 */
};
/****************************************************************************