mirror of
https://github.com/apache/nuttx.git
synced 2026-09-21 13:25:12 +08:00
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
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
Reference in New Issue
Block a user