diff --git a/sched/module/mod_insmod.c b/sched/module/mod_insmod.c index 82c3e591dc..f0a96dabdb 100644 --- a/sched/module/mod_insmod.c +++ b/sched/module/mod_insmod.c @@ -249,11 +249,17 @@ int insmod(FAR const char *filename, FAR const char *modulename, /* Return the load information */ modp->alloc = (FAR void *)loadinfo.textalloc; - modp->size = loadinfo.textsize + loadinfo.datasize; +#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MODULE) + modp->textsize = loadinfo.textsize; + modp->datasize = loadinfo.datasize; +#endif /* Get the module initializer entry point */ initializer = (mod_initializer_t)(loadinfo.textalloc + loadinfo.ehdr.e_entry); +#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MODULE) + modp->initializer = initializer; +#endif mod_dumpinitializer(initializer, &loadinfo); /* Call the module initializer */ diff --git a/sched/module/mod_procfs.c b/sched/module/mod_procfs.c index dca2db91b5..b430bc8fe0 100644 --- a/sched/module/mod_procfs.c +++ b/sched/module/mod_procfs.c @@ -152,9 +152,12 @@ static int modprocfs_callback(FAR struct module_s *modp, FAR void *arg) DEBUGASSERT(modp != NULL && arg != NULL); priv = (FAR struct modprocfs_file_s *)arg; - linesize = snprintf(priv->line, MOD_LINELEN, "%s,%p,%p,%p,%lu\n", - modp->modulename, modp->uninitializer, modp->arg, - modp->alloc, (unsigned long)modp->size); + linesize = snprintf(priv->line, MOD_LINELEN, "%s,%p,%p,%p,%p,%lu,%p,%lu\n", + modp->modulename, modp->initializer, + modp->uninitializer, modp->arg, + modp->alloc, (unsigned long)modp->textsize, + (FAR uint8_t *)modp->alloc + modp->textsize, + (unsigned long)modp->datasize); copysize = procfs_memcpy(priv->line, linesize, priv->buffer, priv->remaining, &priv->offset); priv->totalsize += copysize; diff --git a/sched/module/mod_rmmod.c b/sched/module/mod_rmmod.c index c9ac15b0ec..76fff1c7aa 100644 --- a/sched/module/mod_rmmod.c +++ b/sched/module/mod_rmmod.c @@ -111,6 +111,9 @@ int rmmod(FAR const char *modulename) /* Nullify so that the uninitializer cannot be called again */ +#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MODULE) + modp->initializer = NULL; +#endif modp->uninitializer = NULL; modp->arg = NULL; } @@ -126,7 +129,10 @@ int rmmod(FAR const char *modulename) /* Nullify so that the memory cannot be freed again */ modp->alloc = NULL; - modp->size = 0; +#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MODULE) + modp->textsize = 0; + modp->datasize = 0; +#endif } /* Remove the module from the registry */ diff --git a/sched/module/module.h b/sched/module/module.h index db04560959..6c9b6813b0 100644 --- a/sched/module/module.h +++ b/sched/module/module.h @@ -59,10 +59,16 @@ struct module_s { FAR struct module_s *flink; /* Supports a singly linked list */ FAR char modulename[MODULENAME_MAX]; /* Module name */ +#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MODULE) + mod_initializer_t initializer; /* Module initializer function */ +#endif mod_uninitializer_t uninitializer; /* Module uninitializer function */ FAR void *arg; /* Uninitializer argument */ FAR void *alloc; /* Allocated kernel memory */ - size_t size; /* Size of the kernel memory allocation */ +#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MODULE) + size_t textsize; /* Size of the kernel .text memory allocation */ + size_t datasize; /* Size of the kernel .bss/.data memory allocation */ +#endif }; /* This struct provides a description of the currently loaded instantiation