apps/examples/nsh: Add logic to automatically register an application symbol table as part of NSH initialization.
This commit is contained in:
parent
6b938816d1
commit
0ea260e1c3
@ -13,6 +13,23 @@ config EXAMPLES_NSH
|
|||||||
|
|
||||||
if EXAMPLES_NSH
|
if EXAMPLES_NSH
|
||||||
|
|
||||||
|
config EXAMPLES_NSH_SYMTAB
|
||||||
|
bool "Register symbol table"
|
||||||
|
default n
|
||||||
|
depends on LIBC_EXECFUNCS && LIB_BOARDCTL && !EXECFUNCS_HAVE_SYMTAB
|
||||||
|
select BOARDCTL_APP_SYMTAB
|
||||||
|
---help---
|
||||||
|
Enable logic to automatically register an application symbol table
|
||||||
|
as part of NSH initialization. If enabled, then application logic
|
||||||
|
must provide the following:
|
||||||
|
|
||||||
|
const struct symtab_s g_exports[];
|
||||||
|
const int g_nexports;
|
||||||
|
|
||||||
|
Where g_exports is the name of the exported application symbol table
|
||||||
|
and g_nexports holds the number of entries in the application symbol
|
||||||
|
table.
|
||||||
|
|
||||||
config EXAMPLES_NSH_PROGNAME
|
config EXAMPLES_NSH_PROGNAME
|
||||||
string "Program name"
|
string "Program name"
|
||||||
default "nsh"
|
default "nsh"
|
||||||
|
@ -79,8 +79,17 @@
|
|||||||
# undef HAVE_DUMMY_SYMTAB
|
# undef HAVE_DUMMY_SYMTAB
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_FS_BINFS) && !defined(HAVE_DUMMY_SYMTAB)
|
/* If we are going to use the application symbol table, then suppress
|
||||||
# warning "Prequisites not met for BINFS dummy symbol table"
|
* the dummy symbol table.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_EXAMPLES_NSH_SYMTAB
|
||||||
|
# undef HAVE_DUMMY_SYMTAB
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_FS_BINFS) && !defined(HAVE_DUMMY_SYMTAB) && \
|
||||||
|
!defined(CONFIG_EXAMPLES_NSH_SYMTAB)
|
||||||
|
# warning "Prequisites not met for BINFS symbol table"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* C++ initialization requires CXX initializer support */
|
/* C++ initialization requires CXX initializer support */
|
||||||
@ -109,7 +118,7 @@
|
|||||||
* Private Data
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef HAVE_DUMMY_SYMTAB
|
#if defined(HAVE_DUMMY_SYMTAB)
|
||||||
/* If posix_spawn() is enabled as required for CONFIG_NSH_FILE_APPS, then
|
/* If posix_spawn() is enabled as required for CONFIG_NSH_FILE_APPS, then
|
||||||
* a symbol table is needed by the internals of posix_spawn(). The symbol
|
* a symbol table is needed by the internals of posix_spawn(). The symbol
|
||||||
* table is needed to support ELF and NXFLAT binaries to dynamically link to
|
* table is needed to support ELF and NXFLAT binaries to dynamically link to
|
||||||
@ -120,7 +129,13 @@
|
|||||||
* you want to support ELF or NXFLAT binaries!
|
* you want to support ELF or NXFLAT binaries!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static const struct symtab_s CONFIG_EXECFUNCS_SYMTAB[1]; /* Wasted memory! */
|
static const struct symtab_s g_dummy_symtab[1]; /* Wasted memory! */
|
||||||
|
|
||||||
|
#elif defined(CONFIG_EXAMPLES_NSH_SYMTAB)
|
||||||
|
|
||||||
|
extern const struct symtab_s g_exports[];
|
||||||
|
extern const int g_nexports;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -137,7 +152,7 @@ int main(int argc, FAR char *argv[])
|
|||||||
int nsh_main(int argc, char *argv[])
|
int nsh_main(int argc, char *argv[])
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#ifdef HAVE_DUMMY_SYMTAB
|
#if defined(HAVE_DUMMY_SYMTAB) || defined (CONFIG_EXAMPLES_NSH_SYMTAB)
|
||||||
struct boardioc_symtab_s symdesc;
|
struct boardioc_symtab_s symdesc;
|
||||||
#endif
|
#endif
|
||||||
int exitval = 0;
|
int exitval = 0;
|
||||||
@ -149,11 +164,18 @@ int nsh_main(int argc, char *argv[])
|
|||||||
up_cxxinitialize();
|
up_cxxinitialize();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_DUMMY_SYMTAB
|
#if defined(HAVE_DUMMY_SYMTAB) || defined (CONFIG_EXAMPLES_NSH_SYMTAB)
|
||||||
|
#if defined(HAVE_DUMMY_SYMTAB)
|
||||||
/* Make sure that we are using our symbol table */
|
/* Make sure that we are using our symbol table */
|
||||||
|
|
||||||
symdesc.symtab = (FAR struct symtab_s *)g_dummy_symtab; /* Discard 'const' */
|
symdesc.symtab = (FAR struct symtab_s *)g_dummy_symtab; /* Discard 'const' */
|
||||||
symdesc.nsymbols = 0;
|
symdesc.nsymbols = 0;
|
||||||
|
|
||||||
|
#else /* if defined(CONFIG_EXAMPLES_NSH_SYMTAB) */
|
||||||
|
symdesc.symtab = (FAR struct symtab_s *)g_exports; /* Discard 'const' */
|
||||||
|
symdesc.nsymbols = g_nexports;
|
||||||
|
#endif
|
||||||
|
|
||||||
(void)boardctl(BOARDIOC_APP_SYMTAB, (uintptr_t)&symdesc);
|
(void)boardctl(BOARDIOC_APP_SYMTAB, (uintptr_t)&symdesc);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user