diff --git a/include/nuttx/lib/modlib.h b/include/nuttx/lib/modlib.h index 551305e84b..a0b68893ea 100644 --- a/include/nuttx/lib/modlib.h +++ b/include/nuttx/lib/modlib.h @@ -65,7 +65,19 @@ # define CONFIG_MODLIB_BUFFERINCR 32 #endif -#define MODULENAME_MAX 16 +/* Module names. These are only used by the kernel module and will be + * disabled in all other configurations. + * + * FLAT build: There are only kernel modules and kernel modules + * masquerading as shared libraries. Names are required. + * PROTECTED and KERNEL builds: Names are only needed in the kernel + * portion of the build + */ + +#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__) +# define HAVE_MODLIB_NAMES +# define MODLIB_NAMEMAX 16 +#endif /**************************************************************************** * Public Types @@ -135,7 +147,9 @@ struct symtab_s; struct module_s { FAR struct module_s *flink; /* Supports a singly linked list */ - FAR char modulename[MODULENAME_MAX]; /* Module name */ +#ifdef HAVE_MODLIB_NAMES + FAR char modname[MODLIB_NAMEMAX]; /* Module name */ +#endif #if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MODULE) mod_initializer_t initializer; /* Module initializer function */ #endif @@ -448,7 +462,7 @@ int modlib_registry_del(FAR struct module_s *modp); * Find an entry in the module registry using the name of the module. * * Input Parameters: - * modulename - The name of the module to be found + * modname - The name of the module to be found * * Returned Value: * If the registry entry is found, a pointer to the module entry is @@ -459,7 +473,9 @@ int modlib_registry_del(FAR struct module_s *modp); * ****************************************************************************/ -FAR struct module_s *modlib_registry_find(FAR const char *modulename); +#ifdef HAVE_MODLIB_NAMES +FAR struct module_s *modlib_registry_find(FAR const char *modname); +#endif /**************************************************************************** * Name: modlib_registry_verify diff --git a/include/nuttx/module.h b/include/nuttx/module.h index 615dde6f8b..25964d70d0 100644 --- a/include/nuttx/module.h +++ b/include/nuttx/module.h @@ -71,8 +71,8 @@ extern "C" * * Input Parameters: * - * filename - Full path to the module binary to be loaded - * modulename - The name that can be used to refer to the module after + * filename - Full path to the module binary to be loaded + * modname - The name that can be used to refer to the module after * it has been loaded. * * Returned Value: @@ -83,7 +83,7 @@ extern "C" * ****************************************************************************/ -FAR void *insmod(FAR const char *filename, FAR const char *modulename); +FAR void *insmod(FAR const char *filename, FAR const char *modname); /**************************************************************************** * Name: rmmod diff --git a/libc/modlib/Kconfig b/libc/modlib/Kconfig index 81e8d3178f..eeb5d05dcc 100644 --- a/libc/modlib/Kconfig +++ b/libc/modlib/Kconfig @@ -7,10 +7,6 @@ config LIBC_MODLIB bool default n -config MODLIB_NAMES - bool - default n - menu "Module library configuration" depends on LIBC_MODLIB diff --git a/libc/modlib/modlib_registry.c b/libc/modlib/modlib_registry.c index 5fe8ef02c0..2cab201230 100644 --- a/libc/modlib/modlib_registry.c +++ b/libc/modlib/modlib_registry.c @@ -244,7 +244,7 @@ int modlib_registry_del(FAR struct module_s *modp) * Find an entry in the module registry using the name of the module. * * Input Parameters: - * modulename - The name of the module to be found + * modname - The name of the module to be found * * Returned Value: * If the registry entry is found, a pointer to the module entry is @@ -255,16 +255,18 @@ int modlib_registry_del(FAR struct module_s *modp) * ****************************************************************************/ -FAR struct module_s *modlib_registry_find(FAR const char *modulename) +#ifdef HAVE_MODLIB_NAMES +FAR struct module_s *modlib_registry_find(FAR const char *modname) { FAR struct module_s *modp; for (modp = g_mod_registry; - modp != NULL && strncmp(modp->modulename, modulename, MODULENAME_MAX) != 0; + modp != NULL && strncmp(modp->modname, modname, MODLIB_NAMEMAX) != 0; modp = modp->flink); return modp; } +#endif /**************************************************************************** * Name: modlib_registry_verify diff --git a/libc/modlib/modlib_unload.c b/libc/modlib/modlib_unload.c index 634e92104a..8cb4f98406 100644 --- a/libc/modlib/modlib_unload.c +++ b/libc/modlib/modlib_unload.c @@ -46,6 +46,7 @@ #include #include "libc.h" +#include "modlib/modlib.h" /**************************************************************************** * Public Functions diff --git a/libc/sched/task_startup.c b/libc/sched/task_startup.c index 6012e62675..c0895a16b8 100644 --- a/libc/sched/task_startup.c +++ b/libc/sched/task_startup.c @@ -46,30 +46,6 @@ #if defined(CONFIG_BUILD_PROTECTED) && !defined(__KERNEL__) -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Type Declarations - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/sched/Kconfig b/sched/Kconfig index 199fe439b7..db3e695019 100644 --- a/sched/Kconfig +++ b/sched/Kconfig @@ -1123,7 +1123,6 @@ config MODULE bool "Enable loadable OS modules" default n select LIBC_MODLIB - select LIBC_MODLIB_NAMES select LIBC_ARCH_ELF ---help--- Enable support for loadable OS modules. Default: n diff --git a/sched/module/mod_insmod.c b/sched/module/mod_insmod.c index e6664d57ba..537f0e3b2d 100644 --- a/sched/module/mod_insmod.c +++ b/sched/module/mod_insmod.c @@ -173,8 +173,8 @@ static void mod_dumpinitializer(mod_initializer_t initializer, * * Input Parameters: * - * filename - Full path to the module binary to be loaded - * modulename - The name that can be used to refer to the module after + * filename - Full path to the module binary to be loaded + * modname - The name that can be used to refer to the module after * it has been loaded. * * Returned Value: @@ -185,14 +185,14 @@ static void mod_dumpinitializer(mod_initializer_t initializer, * ****************************************************************************/ -FAR void *insmod(FAR const char *filename, FAR const char *modulename) +FAR void *insmod(FAR const char *filename, FAR const char *modname) { struct mod_loadinfo_s loadinfo; FAR struct module_s *modp; mod_initializer_t initializer; int ret; - DEBUGASSERT(filename != NULL && modulename != NULL); + DEBUGASSERT(filename != NULL && modname != NULL); sinfo("Loading file: %s\n", filename); /* Get exclusive access to the module registry */ @@ -201,7 +201,7 @@ FAR void *insmod(FAR const char *filename, FAR const char *modulename) /* Check if this module is already installed */ - if (modlib_registry_find(modulename) != NULL) + if (modlib_registry_find(modname) != NULL) { modlib_registry_unlock(); ret = -EEXIST; @@ -229,7 +229,7 @@ FAR void *insmod(FAR const char *filename, FAR const char *modulename) /* Save the module name in the registry entry */ - strncpy(modp->modulename, modulename, MODULENAME_MAX); + strncpy(modp->modname, modname, MODLIB_NAMEMAX); /* Load the program binary */ diff --git a/sched/module/mod_procfs.c b/sched/module/mod_procfs.c index 89a65b161a..d900165c99 100644 --- a/sched/module/mod_procfs.c +++ b/sched/module/mod_procfs.c @@ -147,7 +147,7 @@ static int modprocfs_callback(FAR struct module_s *modp, FAR void *arg) priv = (FAR struct modprocfs_file_s *)arg; linesize = snprintf(priv->line, MOD_LINELEN, "%s,%p,%p,%p,%u,%p,%lu,%p,%lu\n", - modp->modulename, modp->initializer, + modp->modname, modp->initializer, modp->modinfo.uninitializer, modp->modinfo.arg, modp->modinfo.nexports, modp->alloc, (unsigned long)modp->textsize,