dlfcn, modlib: Appease nxstyle complaints

This commit is contained in:
YAMAMOTO Takashi 2020-03-10 14:52:58 +09:00 committed by Xiang Xiao
parent 63395b295f
commit b39ce514ea
13 changed files with 142 additions and 106 deletions

View File

@ -198,8 +198,8 @@ struct mod_loadinfo_s
/* elfalloc is the base address of the memory that is allocated to hold the /* elfalloc is the base address of the memory that is allocated to hold the
* module image. * module image.
* *
* The alloc[] array in struct module_s will hold memory that persists after * The alloc[] array in struct module_s will hold memory that persists
* the module has been loaded. * after the module has been loaded.
*/ */
uintptr_t textalloc; /* .text memory allocated when module was loaded */ uintptr_t textalloc; /* .text memory allocated when module was loaded */
@ -245,8 +245,8 @@ int modlib_initialize(FAR const char *filename,
* Name: modlib_uninitialize * Name: modlib_uninitialize
* *
* Description: * Description:
* Releases any resources committed by modlib_initialize(). This essentially * Releases any resources committed by modlib_initialize(). This
* undoes the actions of modlib_initialize. * essentially undoes the actions of modlib_initialize.
* *
* Returned Value: * Returned Value:
* 0 (OK) is returned on success and a negated errno is returned on * 0 (OK) is returned on success and a negated errno is returned on
@ -264,7 +264,8 @@ int modlib_uninitialize(FAR struct mod_loadinfo_s *loadinfo);
* *
* Input Parameters: * Input Parameters:
* symtab - The location to store the symbol table. * symtab - The location to store the symbol table.
* nsymbols - The location to store the number of symbols in the symbol table. * nsymbols - The location to store the number of symbols in the symbol
* table.
* *
* Returned Value: * Returned Value:
* None * None
@ -310,7 +311,8 @@ int modlib_load(FAR struct mod_loadinfo_s *loadinfo);
* *
* Description: * Description:
* Bind the imported symbol names in the loaded module described by * Bind the imported symbol names in the loaded module described by
* 'loadinfo' using the exported symbol values provided by modlib_setsymtab(). * 'loadinfo' using the exported symbol values provided by
* modlib_setsymtab().
* *
* Returned Value: * Returned Value:
* 0 (OK) is returned on success and a negated errno is returned on * 0 (OK) is returned on success and a negated errno is returned on
@ -318,7 +320,8 @@ int modlib_load(FAR struct mod_loadinfo_s *loadinfo);
* *
****************************************************************************/ ****************************************************************************/
int modlib_bind(FAR struct module_s *modp, FAR struct mod_loadinfo_s *loadinfo); int modlib_bind(FAR struct module_s *modp,
FAR struct mod_loadinfo_s *loadinfo);
/**************************************************************************** /****************************************************************************
* Name: modlib_unload * Name: modlib_unload
@ -358,7 +361,8 @@ int modlib_unload(struct mod_loadinfo_s *loadinfo);
****************************************************************************/ ****************************************************************************/
#if CONFIG_MODLIB_MAXDEPEND > 0 #if CONFIG_MODLIB_MAXDEPEND > 0
int modlib_depend(FAR struct module_s *importer, FAR struct module_s *exporter); int modlib_depend(FAR struct module_s *importer,
FAR struct module_s *exporter);
#endif #endif
/**************************************************************************** /****************************************************************************

View File

@ -147,7 +147,8 @@ static inline int dlremove(FAR void *handle)
ret = modlib_registry_del(modp); ret = modlib_registry_del(modp);
if (ret < 0) if (ret < 0)
{ {
serr("ERROR: Failed to remove the module from the registry: %d\n", ret); serr("ERROR: Failed to remove the module from the registry: %d\n",
ret);
goto errout_with_lock; goto errout_with_lock;
} }

View File

@ -231,7 +231,8 @@ static inline FAR void *dlinsert(FAR const char *filename)
/* Get the module initializer entry point */ /* Get the module initializer entry point */
initializer = (mod_initializer_t)(loadinfo.textalloc + loadinfo.ehdr.e_entry); initializer = (mod_initializer_t)(loadinfo.textalloc +
loadinfo.ehdr.e_entry);
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MODULE) #if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MODULE)
modp->initializer = initializer; modp->initializer = initializer;
#endif #endif

View File

@ -162,7 +162,6 @@ static inline int modlib_readrelas(FAR struct mod_loadinfo_s *loadinfo,
static int modlib_relocate(FAR struct module_s *modp, static int modlib_relocate(FAR struct module_s *modp,
FAR struct mod_loadinfo_s *loadinfo, int relidx) FAR struct mod_loadinfo_s *loadinfo, int relidx)
{ {
FAR Elf_Shdr *relsec = &loadinfo->shdr[relidx]; FAR Elf_Shdr *relsec = &loadinfo->shdr[relidx];
FAR Elf_Shdr *dstsec = &loadinfo->shdr[relsec->sh_info]; FAR Elf_Shdr *dstsec = &loadinfo->shdr[relsec->sh_info];
@ -202,13 +201,15 @@ static int modlib_relocate(FAR struct module_s *modp,
if (!(i % CONFIG_MODLIB_RELOCATION_BUFFERCOUNT)) if (!(i % CONFIG_MODLIB_RELOCATION_BUFFERCOUNT))
{ {
ret = modlib_readrels(loadinfo, relsec, i, rels, CONFIG_MODLIB_RELOCATION_BUFFERCOUNT); ret = modlib_readrels(loadinfo, relsec, i, rels,
CONFIG_MODLIB_RELOCATION_BUFFERCOUNT);
if (ret < 0) if (ret < 0)
{ {
berr("ERROR: Section %d reloc %d: Failed to read relocation entry: %d\n", berr("ERROR: Section %d reloc %d: "
"Failed to read relocation entry: %d\n",
relidx, i, ret); relidx, i, ret);
break; break;
} }
} }
/* Get the symbol table index for the relocation. This is contained /* Get the symbol table index for the relocation. This is contained
@ -247,6 +248,7 @@ static int modlib_relocate(FAR struct module_s *modp,
ret = -ENOMEM; ret = -ENOMEM;
break; break;
} }
j++; j++;
} }
else else
@ -261,7 +263,8 @@ static int modlib_relocate(FAR struct module_s *modp,
ret = modlib_readsym(loadinfo, symidx, sym); ret = modlib_readsym(loadinfo, symidx, sym);
if (ret < 0) if (ret < 0)
{ {
berr("ERROR: Section %d reloc %d: Failed to read symbol[%d]: %d\n", berr("ERROR: Section %d reloc %d: "
"Failed to read symbol[%d]: %d\n",
relidx, i, symidx, ret); relidx, i, symidx, ret);
lib_free(cache); lib_free(cache);
break; break;
@ -272,8 +275,8 @@ static int modlib_relocate(FAR struct module_s *modp,
ret = modlib_symvalue(modp, loadinfo, sym); ret = modlib_symvalue(modp, loadinfo, sym);
if (ret < 0) if (ret < 0)
{ {
/* The special error -ESRCH is returned only in one condition: The /* The special error -ESRCH is returned only in one condition:
* symbol has no name. * The symbol has no name.
* *
* There are a few relocations for a few architectures that do * There are a few relocations for a few architectures that do
* no depend upon a named symbol. We don't know if that is the * no depend upon a named symbol. We don't know if that is the
@ -284,13 +287,15 @@ static int modlib_relocate(FAR struct module_s *modp,
if (ret == -ESRCH) if (ret == -ESRCH)
{ {
berr("ERROR: Section %d reloc %d: Undefined symbol[%d] has no name: %d\n", berr("ERROR: Section %d reloc %d: "
relidx, i, symidx, ret); "Undefined symbol[%d] has no name: %d\n",
relidx, i, symidx, ret);
} }
else else
{ {
berr("ERROR: Section %d reloc %d: Failed to get value of symbol[%d]: %d\n", berr("ERROR: Section %d reloc %d: "
relidx, i, symidx, ret); "Failed to get value of symbol[%d]: %d\n",
relidx, i, symidx, ret);
lib_free(cache); lib_free(cache);
break; break;
} }
@ -307,9 +312,11 @@ static int modlib_relocate(FAR struct module_s *modp,
/* Calculate the relocation address. */ /* Calculate the relocation address. */
if (rel->r_offset < 0 || rel->r_offset > dstsec->sh_size - sizeof(uint32_t)) if (rel->r_offset < 0 ||
rel->r_offset > dstsec->sh_size - sizeof(uint32_t))
{ {
berr("ERROR: Section %d reloc %d: Relocation address out of range, offset %d size %d\n", berr("ERROR: Section %d reloc %d: "
"Relocation address out of range, offset %d size %d\n",
relidx, i, rel->r_offset, dstsec->sh_size); relidx, i, rel->r_offset, dstsec->sh_size);
ret = -EINVAL; ret = -EINVAL;
break; break;
@ -322,7 +329,8 @@ static int modlib_relocate(FAR struct module_s *modp,
ret = up_relocate(rel, sym, addr); ret = up_relocate(rel, sym, addr);
if (ret < 0) if (ret < 0)
{ {
berr("ERROR: Section %d reloc %d: Relocation failed: %d\n", relidx, i, ret); berr("ERROR: Section %d reloc %d: Relocation failed: %d\n",
relidx, i, ret);
break; break;
} }
} }
@ -354,7 +362,8 @@ static int modlib_relocateadd(FAR struct module_s *modp,
int i; int i;
int j; int j;
relas = lib_malloc(CONFIG_MODLIB_RELOCATION_BUFFERCOUNT * sizeof(Elf_Rela)); relas = lib_malloc(CONFIG_MODLIB_RELOCATION_BUFFERCOUNT *
sizeof(Elf_Rela));
if (!relas) if (!relas)
{ {
berr("Failed to allocate memory for elf relocation relas\n"); berr("Failed to allocate memory for elf relocation relas\n");
@ -378,13 +387,15 @@ static int modlib_relocateadd(FAR struct module_s *modp,
if (!(i % CONFIG_MODLIB_RELOCATION_BUFFERCOUNT)) if (!(i % CONFIG_MODLIB_RELOCATION_BUFFERCOUNT))
{ {
ret = modlib_readrelas(loadinfo, relsec, i, relas, CONFIG_MODLIB_RELOCATION_BUFFERCOUNT); ret = modlib_readrelas(loadinfo, relsec, i, relas,
CONFIG_MODLIB_RELOCATION_BUFFERCOUNT);
if (ret < 0) if (ret < 0)
{ {
berr("ERROR: Section %d reloc %d: Failed to read relocation entry: %d\n", berr("ERROR: Section %d reloc %d: "
"Failed to read relocation entry: %d\n",
relidx, i, ret); relidx, i, ret);
break; break;
} }
} }
/* Get the symbol table index for the relocation. This is contained /* Get the symbol table index for the relocation. This is contained
@ -423,6 +434,7 @@ static int modlib_relocateadd(FAR struct module_s *modp,
ret = -ENOMEM; ret = -ENOMEM;
break; break;
} }
j++; j++;
} }
else else
@ -437,7 +449,8 @@ static int modlib_relocateadd(FAR struct module_s *modp,
ret = modlib_readsym(loadinfo, symidx, sym); ret = modlib_readsym(loadinfo, symidx, sym);
if (ret < 0) if (ret < 0)
{ {
berr("ERROR: Section %d reloc %d: Failed to read symbol[%d]: %d\n", berr("ERROR: Section %d reloc %d: "
"Failed to read symbol[%d]: %d\n",
relidx, i, symidx, ret); relidx, i, symidx, ret);
lib_free(cache); lib_free(cache);
break; break;
@ -448,8 +461,8 @@ static int modlib_relocateadd(FAR struct module_s *modp,
ret = modlib_symvalue(modp, loadinfo, sym); ret = modlib_symvalue(modp, loadinfo, sym);
if (ret < 0) if (ret < 0)
{ {
/* The special error -ESRCH is returned only in one condition: The /* The special error -ESRCH is returned only in one condition:
* symbol has no name. * The symbol has no name.
* *
* There are a few relocations for a few architectures that do * There are a few relocations for a few architectures that do
* no depend upon a named symbol. We don't know if that is the * no depend upon a named symbol. We don't know if that is the
@ -460,13 +473,15 @@ static int modlib_relocateadd(FAR struct module_s *modp,
if (ret == -ESRCH) if (ret == -ESRCH)
{ {
berr("ERROR: Section %d reloc %d: Undefined symbol[%d] has no name: %d\n", berr("ERROR: Section %d reloc %d: "
relidx, i, symidx, ret); "Undefined symbol[%d] has no name: %d\n",
relidx, i, symidx, ret);
} }
else else
{ {
berr("ERROR: Section %d reloc %d: Failed to get value of symbol[%d]: %d\n", berr("ERROR: Section %d reloc %d: "
relidx, i, symidx, ret); "Failed to get value of symbol[%d]: %d\n",
relidx, i, symidx, ret);
lib_free(cache); lib_free(cache);
break; break;
} }
@ -483,9 +498,11 @@ static int modlib_relocateadd(FAR struct module_s *modp,
/* Calculate the relocation address. */ /* Calculate the relocation address. */
if (rela->r_offset < 0 || rela->r_offset > dstsec->sh_size - sizeof(uint32_t)) if (rela->r_offset < 0 ||
rela->r_offset > dstsec->sh_size - sizeof(uint32_t))
{ {
berr("ERROR: Section %d reloc %d: Relocation address out of range, offset %d size %d\n", berr("ERROR: Section %d reloc %d: "
"Relocation address out of range, offset %d size %d\n",
relidx, i, rela->r_offset, dstsec->sh_size); relidx, i, rela->r_offset, dstsec->sh_size);
ret = -EINVAL; ret = -EINVAL;
break; break;
@ -498,7 +515,8 @@ static int modlib_relocateadd(FAR struct module_s *modp,
ret = up_relocateadd(rela, sym, addr); ret = up_relocateadd(rela, sym, addr);
if (ret < 0) if (ret < 0)
{ {
berr("ERROR: Section %d reloc %d: Relocation failed: %d\n", relidx, i, ret); berr("ERROR: Section %d reloc %d: Relocation failed: %d\n",
relidx, i, ret);
break; break;
} }
} }
@ -522,7 +540,8 @@ static int modlib_relocateadd(FAR struct module_s *modp,
* *
* Description: * Description:
* Bind the imported symbol names in the loaded module described by * Bind the imported symbol names in the loaded module described by
* 'loadinfo' using the exported symbol values provided by modlib_setsymtab(). * 'loadinfo' using the exported symbol values provided by
* modlib_setsymtab().
* *
* Input Parameters: * Input Parameters:
* modp - Module state information * modp - Module state information
@ -534,7 +553,8 @@ static int modlib_relocateadd(FAR struct module_s *modp,
* *
****************************************************************************/ ****************************************************************************/
int modlib_bind(FAR struct module_s *modp, FAR struct mod_loadinfo_s *loadinfo) int modlib_bind(FAR struct module_s *modp,
FAR struct mod_loadinfo_s *loadinfo)
{ {
int ret; int ret;
int i; int i;

View File

@ -66,7 +66,8 @@
* *
****************************************************************************/ ****************************************************************************/
int modlib_depend(FAR struct module_s *importer, FAR struct module_s *exporter) int modlib_depend(FAR struct module_s *importer,
FAR struct module_s *exporter)
{ {
#if CONFIG_MODLIB_MAXDEPEND > 0 #if CONFIG_MODLIB_MAXDEPEND > 0
int freendx; int freendx;
@ -131,9 +132,9 @@ int modlib_depend(FAR struct module_s *importer, FAR struct module_s *exporter)
* dependents if the importer is removed. * dependents if the importer is removed.
*/ */
DEBUGASSERT(importer->dependencies[freendx] == NULL); DEBUGASSERT(importer->dependencies[freendx] == NULL);
importer->dependencies[freendx] = exporter; importer->dependencies[freendx] = exporter;
return OK; return OK;
} }
/* If we get there then the list of dependencies is full. */ /* If we get there then the list of dependencies is full. */

View File

@ -185,11 +185,11 @@ int modlib_initialize(FAR const char *filename,
ret = modlib_verifyheader(&loadinfo->ehdr); ret = modlib_verifyheader(&loadinfo->ehdr);
if (ret < 0) if (ret < 0)
{ {
/* This may not be an error because we will be called to attempt loading /* This may not be an error because we will be called to attempt
* EVERY binary. If modlib_verifyheader() does not recognize the ELF header, * loading EVERY binary. If modlib_verifyheader() does not recognize
* it will -ENOEXEC which simply informs the system that the file is not an * the ELF header, it will -ENOEXEC which simply informs the system
* ELF file. modlib_verifyheader() will return other errors if the ELF header * that the file is not an ELF file. modlib_verifyheader() will return
* is not correctly formed. * other errors if the ELF header is not correctly formed.
*/ */
berr("ERROR: Bad ELF header: %d\n", ret); berr("ERROR: Bad ELF header: %d\n", ret);

View File

@ -72,7 +72,8 @@ int modlib_allocbuffer(FAR struct mod_loadinfo_s *loadinfo)
{ {
/* No.. allocate one now */ /* No.. allocate one now */
loadinfo->iobuffer = (FAR uint8_t *)lib_malloc(CONFIG_MODLIB_BUFFERSIZE); loadinfo->iobuffer = (FAR uint8_t *)
lib_malloc(CONFIG_MODLIB_BUFFERSIZE);
if (!loadinfo->iobuffer) if (!loadinfo->iobuffer)
{ {
berr("ERROR: Failed to allocate an I/O buffer\n"); berr("ERROR: Failed to allocate an I/O buffer\n");
@ -97,7 +98,8 @@ int modlib_allocbuffer(FAR struct mod_loadinfo_s *loadinfo)
* *
****************************************************************************/ ****************************************************************************/
int modlib_reallocbuffer(FAR struct mod_loadinfo_s *loadinfo, size_t increment) int modlib_reallocbuffer(FAR struct mod_loadinfo_s *loadinfo,
size_t increment)
{ {
FAR void *buffer; FAR void *buffer;
size_t newsize; size_t newsize;
@ -108,8 +110,8 @@ int modlib_reallocbuffer(FAR struct mod_loadinfo_s *loadinfo, size_t increment)
/* And perform the reallocation */ /* And perform the reallocation */
buffer = lib_realloc((FAR void *)loadinfo->iobuffer, newsize); buffer = lib_realloc((FAR void *)loadinfo->iobuffer, newsize);
if (!buffer) if (!buffer)
{ {
berr("ERROR: Failed to reallocate the I/O buffer\n"); berr("ERROR: Failed to reallocate the I/O buffer\n");
return -ENOMEM; return -ENOMEM;

View File

@ -160,7 +160,8 @@ static inline int modlib_loadfile(FAR struct mod_loadinfo_s *loadinfo)
FAR Elf_Shdr *shdr = &loadinfo->shdr[i]; FAR Elf_Shdr *shdr = &loadinfo->shdr[i];
/* SHF_ALLOC indicates that the section requires memory during /* SHF_ALLOC indicates that the section requires memory during
* execution */ * execution
*/
if ((shdr->sh_flags & SHF_ALLOC) == 0) if ((shdr->sh_flags & SHF_ALLOC) == 0)
{ {
@ -261,7 +262,8 @@ int modlib_load(FAR struct mod_loadinfo_s *loadinfo)
/* Allocate memory to hold the ELF image */ /* Allocate memory to hold the ELF image */
loadinfo->textalloc = (uintptr_t)lib_malloc(loadinfo->textsize + loadinfo->datasize); loadinfo->textalloc = (uintptr_t)lib_malloc(loadinfo->textsize +
loadinfo->datasize);
if (!loadinfo->textalloc) if (!loadinfo->textalloc)
{ {
berr("ERROR: Failed to allocate memory for the module\n"); berr("ERROR: Failed to allocate memory for the module\n");

View File

@ -127,31 +127,31 @@ int modlib_read(FAR struct mod_loadinfo_s *loadinfo, FAR uint8_t *buffer,
/* Read the file data at offset into the user buffer */ /* Read the file data at offset into the user buffer */
nbytes = _NX_READ(loadinfo->filfd, buffer, readsize); nbytes = _NX_READ(loadinfo->filfd, buffer, readsize);
if (nbytes < 0) if (nbytes < 0)
{ {
int errval = _NX_GETERRNO(nbytes); int errval = _NX_GETERRNO(nbytes);
/* EINTR just means that we received a signal */ /* EINTR just means that we received a signal */
if (errval != EINTR) if (errval != EINTR)
{ {
berr("ERROR: Read from offset %lu failed: %d\n", berr("ERROR: Read from offset %lu failed: %d\n",
(unsigned long)offset, errval); (unsigned long)offset, errval);
return -errval; return -errval;
} }
} }
else if (nbytes == 0) else if (nbytes == 0)
{ {
berr("ERROR: Unexpected end of file\n"); berr("ERROR: Unexpected end of file\n");
return -ENODATA; return -ENODATA;
} }
else else
{ {
readsize -= nbytes; readsize -= nbytes;
buffer += nbytes; buffer += nbytes;
offset += nbytes; offset += nbytes;
} }
} }
modlib_dumpreaddata(buffer, readsize); modlib_dumpreaddata(buffer, readsize);

View File

@ -120,7 +120,8 @@ void modlib_registry_lock(void)
* the wait was awakened by a signal. * the wait was awakened by a signal.
*/ */
DEBUGASSERT(_SEM_ERRNO(ret) == EINTR || _SEM_ERRNO(ret) == ECANCELED); DEBUGASSERT(_SEM_ERRNO(ret) == EINTR ||
_SEM_ERRNO(ret) == ECANCELED);
UNUSED(ret); UNUSED(ret);
} }

View File

@ -194,7 +194,8 @@ int modlib_loadshdrs(FAR struct mod_loadinfo_s *loadinfo)
/* Get the total size of the section header table */ /* Get the total size of the section header table */
shdrsize = (size_t)loadinfo->ehdr.e_shentsize * (size_t)loadinfo->ehdr.e_shnum; shdrsize = (size_t)loadinfo->ehdr.e_shentsize *
(size_t)loadinfo->ehdr.e_shnum;
if (loadinfo->ehdr.e_shoff + shdrsize > loadinfo->filelen) if (loadinfo->ehdr.e_shoff + shdrsize > loadinfo->filelen)
{ {
berr("ERROR: Insufficent space in file for section header table\n"); berr("ERROR: Insufficent space in file for section header table\n");

View File

@ -82,8 +82,8 @@ struct mod_exportinfo_s
* 0 (OK) is returned on success and a negated errno is returned on * 0 (OK) is returned on success and a negated errno is returned on
* failure. * failure.
* *
* EINVAL - There is something inconsistent in the symbol table (should only * EINVAL - There is something inconsistent in the symbol table (should
* happen if the file is corrupted). * only happen if the file is corrupted).
* ESRCH - Symbol has no name * ESRCH - Symbol has no name
* *
****************************************************************************/ ****************************************************************************/
@ -169,9 +169,9 @@ static int modlib_symname(FAR struct mod_loadinfo_s *loadinfo,
* Name: modlib_symcallback * Name: modlib_symcallback
* *
* Description: * Description:
* modlib_registry_foreach() callback function. Test if the provided module, * modlib_registry_foreach() callback function. Test if the provided
* modp, exports the symbol of interest. If so, return that symbol value * module, modp, exports the symbol of interest. If so, return that symbol
* and setup the module dependency relationship. * value and setup the module dependency relationship.
* *
* Returned Value: * Returned Value:
* 0 (OK) is returned on success and a negated errno is returned on * 0 (OK) is returned on success and a negated errno is returned on
@ -181,7 +181,8 @@ static int modlib_symname(FAR struct mod_loadinfo_s *loadinfo,
static int modlib_symcallback(FAR struct module_s *modp, FAR void *arg) static int modlib_symcallback(FAR struct module_s *modp, FAR void *arg)
{ {
FAR struct mod_exportinfo_s *exportinfo = (FAR struct mod_exportinfo_s *)arg; FAR struct mod_exportinfo_s *exportinfo = (FAR struct mod_exportinfo_s *)
arg;
int ret; int ret;
/* Check if this module exports a symbol of that name */ /* Check if this module exports a symbol of that name */
@ -196,23 +197,23 @@ static int modlib_symcallback(FAR struct module_s *modp, FAR void *arg)
modp->modinfo.nexports); modp->modinfo.nexports);
#endif #endif
if (exportinfo->symbol != NULL) if (exportinfo->symbol != NULL)
{ {
/* Yes.. save the dependency relationship and return SYM_FOUND to /* Yes.. save the dependency relationship and return SYM_FOUND to
* stop the traversal. * stop the traversal.
*/ */
ret = modlib_depend(exportinfo->modp, modp); ret = modlib_depend(exportinfo->modp, modp);
if (ret < 0) if (ret < 0)
{ {
berr("ERROR: modlib_depend failed: %d\n", ret); berr("ERROR: modlib_depend failed: %d\n", ret);
return ret; return ret;
} }
return SYM_FOUND; return SYM_FOUND;
} }
return SYM_NOT_FOUND; return SYM_NOT_FOUND;
} }
/**************************************************************************** /****************************************************************************
@ -314,8 +315,8 @@ int modlib_readsym(FAR struct mod_loadinfo_s *loadinfo, int index,
* 0 (OK) is returned on success and a negated errno is returned on * 0 (OK) is returned on success and a negated errno is returned on
* failure. * failure.
* *
* EINVAL - There is something inconsistent in the symbol table (should only * EINVAL - There is something inconsistent in the symbol table (should
* happen if the file is corrupted). * only happen if the file is corrupted).
* ENOSYS - Symbol lies in common * ENOSYS - Symbol lies in common
* ESRCH - Symbol has no name * ESRCH - Symbol has no name
* ENOENT - Symbol undefined and not provided via a symbol table * ENOENT - Symbol undefined and not provided via a symbol table
@ -376,7 +377,8 @@ int modlib_symvalue(FAR struct module_s *modp,
exportinfo.modp = modp; exportinfo.modp = modp;
exportinfo.symbol = NULL; exportinfo.symbol = NULL;
ret = modlib_registry_foreach(modlib_symcallback, (FAR void *)&exportinfo); ret = modlib_registry_foreach(modlib_symcallback,
(FAR void *)&exportinfo);
if (ret < 0) if (ret < 0)
{ {
berr("ERROR: modlib_symcallback failed: \n", ret); berr("ERROR: modlib_symcallback failed: \n", ret);

View File

@ -90,7 +90,8 @@ int modlib_verifyheader(FAR const Elf_Ehdr *ehdr)
if (memcmp(ehdr->e_ident, g_modmagic, EI_MAGIC_SIZE) != 0) if (memcmp(ehdr->e_ident, g_modmagic, EI_MAGIC_SIZE) != 0)
{ {
binfo("Not ELF magic {%02x, %02x, %02x, %02x}\n", binfo("Not ELF magic {%02x, %02x, %02x, %02x}\n",
ehdr->e_ident[0], ehdr->e_ident[1], ehdr->e_ident[2], ehdr->e_ident[3]); ehdr->e_ident[0], ehdr->e_ident[1], ehdr->e_ident[2],
ehdr->e_ident[3]);
return -ENOEXEC; return -ENOEXEC;
} }