Module names are not needed in libc/modlib when the module library is used only for shared library support.

This commit is contained in:
Gregory Nutt 2017-01-29 12:23:24 -06:00
parent 86bdd0a4c7
commit 2c45f482b1
9 changed files with 36 additions and 46 deletions

View file

@ -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

View file

@ -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

View file

@ -7,10 +7,6 @@ config LIBC_MODLIB
bool
default n
config MODLIB_NAMES
bool
default n
menu "Module library configuration"
depends on LIBC_MODLIB

View file

@ -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

View file

@ -46,6 +46,7 @@
#include <nuttx/lib/modlib.h>
#include "libc.h"
#include "modlib/modlib.h"
/****************************************************************************
* Public Functions

View file

@ -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
****************************************************************************/

View file

@ -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

View file

@ -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 */

View file

@ -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,