dlfcn, modlib: Appease nxstyle complaints
This commit is contained in:
parent
63395b295f
commit
b39ce514ea
@ -198,8 +198,8 @@ struct mod_loadinfo_s
|
||||
/* elfalloc is the base address of the memory that is allocated to hold the
|
||||
* module image.
|
||||
*
|
||||
* The alloc[] array in struct module_s will hold memory that persists after
|
||||
* the module has been loaded.
|
||||
* The alloc[] array in struct module_s will hold memory that persists
|
||||
* after the module has been 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
|
||||
*
|
||||
* Description:
|
||||
* Releases any resources committed by modlib_initialize(). This essentially
|
||||
* undoes the actions of modlib_initialize.
|
||||
* Releases any resources committed by modlib_initialize(). This
|
||||
* essentially undoes the actions of modlib_initialize.
|
||||
*
|
||||
* Returned Value:
|
||||
* 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:
|
||||
* 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:
|
||||
* None
|
||||
@ -310,7 +311,8 @@ int modlib_load(FAR struct mod_loadinfo_s *loadinfo);
|
||||
*
|
||||
* Description:
|
||||
* 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:
|
||||
* 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
|
||||
@ -358,7 +361,8 @@ int modlib_unload(struct mod_loadinfo_s *loadinfo);
|
||||
****************************************************************************/
|
||||
|
||||
#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
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -147,7 +147,8 @@ static inline int dlremove(FAR void *handle)
|
||||
ret = modlib_registry_del(modp);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -231,7 +231,8 @@ static inline FAR void *dlinsert(FAR const char *filename)
|
||||
|
||||
/* 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)
|
||||
modp->initializer = initializer;
|
||||
#endif
|
||||
|
@ -162,7 +162,6 @@ static inline int modlib_readrelas(FAR struct mod_loadinfo_s *loadinfo,
|
||||
|
||||
static int modlib_relocate(FAR struct module_s *modp,
|
||||
FAR struct mod_loadinfo_s *loadinfo, int relidx)
|
||||
|
||||
{
|
||||
FAR Elf_Shdr *relsec = &loadinfo->shdr[relidx];
|
||||
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))
|
||||
{
|
||||
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)
|
||||
{
|
||||
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);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 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;
|
||||
break;
|
||||
}
|
||||
|
||||
j++;
|
||||
}
|
||||
else
|
||||
@ -261,7 +263,8 @@ static int modlib_relocate(FAR struct module_s *modp,
|
||||
ret = modlib_readsym(loadinfo, symidx, sym);
|
||||
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);
|
||||
lib_free(cache);
|
||||
break;
|
||||
@ -272,8 +275,8 @@ static int modlib_relocate(FAR struct module_s *modp,
|
||||
ret = modlib_symvalue(modp, loadinfo, sym);
|
||||
if (ret < 0)
|
||||
{
|
||||
/* The special error -ESRCH is returned only in one condition: The
|
||||
* symbol has no name.
|
||||
/* The special error -ESRCH is returned only in one condition:
|
||||
* The symbol has no name.
|
||||
*
|
||||
* 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
|
||||
@ -284,13 +287,15 @@ static int modlib_relocate(FAR struct module_s *modp,
|
||||
|
||||
if (ret == -ESRCH)
|
||||
{
|
||||
berr("ERROR: Section %d reloc %d: Undefined symbol[%d] has no name: %d\n",
|
||||
relidx, i, symidx, ret);
|
||||
berr("ERROR: Section %d reloc %d: "
|
||||
"Undefined symbol[%d] has no name: %d\n",
|
||||
relidx, i, symidx, ret);
|
||||
}
|
||||
else
|
||||
{
|
||||
berr("ERROR: Section %d reloc %d: Failed to get value of symbol[%d]: %d\n",
|
||||
relidx, i, symidx, ret);
|
||||
berr("ERROR: Section %d reloc %d: "
|
||||
"Failed to get value of symbol[%d]: %d\n",
|
||||
relidx, i, symidx, ret);
|
||||
lib_free(cache);
|
||||
break;
|
||||
}
|
||||
@ -307,9 +312,11 @@ static int modlib_relocate(FAR struct module_s *modp,
|
||||
|
||||
/* 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);
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
@ -322,7 +329,8 @@ static int modlib_relocate(FAR struct module_s *modp,
|
||||
ret = up_relocate(rel, sym, addr);
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -354,7 +362,8 @@ static int modlib_relocateadd(FAR struct module_s *modp,
|
||||
int i;
|
||||
int j;
|
||||
|
||||
relas = lib_malloc(CONFIG_MODLIB_RELOCATION_BUFFERCOUNT * sizeof(Elf_Rela));
|
||||
relas = lib_malloc(CONFIG_MODLIB_RELOCATION_BUFFERCOUNT *
|
||||
sizeof(Elf_Rela));
|
||||
if (!relas)
|
||||
{
|
||||
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))
|
||||
{
|
||||
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)
|
||||
{
|
||||
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);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 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;
|
||||
break;
|
||||
}
|
||||
|
||||
j++;
|
||||
}
|
||||
else
|
||||
@ -437,7 +449,8 @@ static int modlib_relocateadd(FAR struct module_s *modp,
|
||||
ret = modlib_readsym(loadinfo, symidx, sym);
|
||||
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);
|
||||
lib_free(cache);
|
||||
break;
|
||||
@ -448,8 +461,8 @@ static int modlib_relocateadd(FAR struct module_s *modp,
|
||||
ret = modlib_symvalue(modp, loadinfo, sym);
|
||||
if (ret < 0)
|
||||
{
|
||||
/* The special error -ESRCH is returned only in one condition: The
|
||||
* symbol has no name.
|
||||
/* The special error -ESRCH is returned only in one condition:
|
||||
* The symbol has no name.
|
||||
*
|
||||
* 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
|
||||
@ -460,13 +473,15 @@ static int modlib_relocateadd(FAR struct module_s *modp,
|
||||
|
||||
if (ret == -ESRCH)
|
||||
{
|
||||
berr("ERROR: Section %d reloc %d: Undefined symbol[%d] has no name: %d\n",
|
||||
relidx, i, symidx, ret);
|
||||
berr("ERROR: Section %d reloc %d: "
|
||||
"Undefined symbol[%d] has no name: %d\n",
|
||||
relidx, i, symidx, ret);
|
||||
}
|
||||
else
|
||||
{
|
||||
berr("ERROR: Section %d reloc %d: Failed to get value of symbol[%d]: %d\n",
|
||||
relidx, i, symidx, ret);
|
||||
berr("ERROR: Section %d reloc %d: "
|
||||
"Failed to get value of symbol[%d]: %d\n",
|
||||
relidx, i, symidx, ret);
|
||||
lib_free(cache);
|
||||
break;
|
||||
}
|
||||
@ -483,9 +498,11 @@ static int modlib_relocateadd(FAR struct module_s *modp,
|
||||
|
||||
/* 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);
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
@ -498,7 +515,8 @@ static int modlib_relocateadd(FAR struct module_s *modp,
|
||||
ret = up_relocateadd(rela, sym, addr);
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -522,7 +540,8 @@ static int modlib_relocateadd(FAR struct module_s *modp,
|
||||
*
|
||||
* Description:
|
||||
* 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:
|
||||
* 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 i;
|
||||
|
@ -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
|
||||
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.
|
||||
*/
|
||||
|
||||
DEBUGASSERT(importer->dependencies[freendx] == NULL);
|
||||
importer->dependencies[freendx] = exporter;
|
||||
return OK;
|
||||
DEBUGASSERT(importer->dependencies[freendx] == NULL);
|
||||
importer->dependencies[freendx] = exporter;
|
||||
return OK;
|
||||
}
|
||||
|
||||
/* If we get there then the list of dependencies is full. */
|
||||
|
@ -185,11 +185,11 @@ int modlib_initialize(FAR const char *filename,
|
||||
ret = modlib_verifyheader(&loadinfo->ehdr);
|
||||
if (ret < 0)
|
||||
{
|
||||
/* This may not be an error because we will be called to attempt loading
|
||||
* EVERY binary. If modlib_verifyheader() does not recognize the ELF header,
|
||||
* it will -ENOEXEC which simply informs the system that the file is not an
|
||||
* ELF file. modlib_verifyheader() will return other errors if the ELF header
|
||||
* is not correctly formed.
|
||||
/* This may not be an error because we will be called to attempt
|
||||
* loading EVERY binary. If modlib_verifyheader() does not recognize
|
||||
* the ELF header, it will -ENOEXEC which simply informs the system
|
||||
* that the file is not an ELF file. modlib_verifyheader() will return
|
||||
* other errors if the ELF header is not correctly formed.
|
||||
*/
|
||||
|
||||
berr("ERROR: Bad ELF header: %d\n", ret);
|
||||
|
@ -72,7 +72,8 @@ int modlib_allocbuffer(FAR struct mod_loadinfo_s *loadinfo)
|
||||
{
|
||||
/* 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)
|
||||
{
|
||||
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;
|
||||
size_t newsize;
|
||||
@ -108,8 +110,8 @@ int modlib_reallocbuffer(FAR struct mod_loadinfo_s *loadinfo, size_t increment)
|
||||
|
||||
/* And perform the reallocation */
|
||||
|
||||
buffer = lib_realloc((FAR void *)loadinfo->iobuffer, newsize);
|
||||
if (!buffer)
|
||||
buffer = lib_realloc((FAR void *)loadinfo->iobuffer, newsize);
|
||||
if (!buffer)
|
||||
{
|
||||
berr("ERROR: Failed to reallocate the I/O buffer\n");
|
||||
return -ENOMEM;
|
||||
|
@ -160,7 +160,8 @@ static inline int modlib_loadfile(FAR struct mod_loadinfo_s *loadinfo)
|
||||
FAR Elf_Shdr *shdr = &loadinfo->shdr[i];
|
||||
|
||||
/* SHF_ALLOC indicates that the section requires memory during
|
||||
* execution */
|
||||
* execution
|
||||
*/
|
||||
|
||||
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 */
|
||||
|
||||
loadinfo->textalloc = (uintptr_t)lib_malloc(loadinfo->textsize + loadinfo->datasize);
|
||||
loadinfo->textalloc = (uintptr_t)lib_malloc(loadinfo->textsize +
|
||||
loadinfo->datasize);
|
||||
if (!loadinfo->textalloc)
|
||||
{
|
||||
berr("ERROR: Failed to allocate memory for the module\n");
|
||||
|
@ -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 */
|
||||
|
||||
nbytes = _NX_READ(loadinfo->filfd, buffer, readsize);
|
||||
if (nbytes < 0)
|
||||
{
|
||||
int errval = _NX_GETERRNO(nbytes);
|
||||
nbytes = _NX_READ(loadinfo->filfd, buffer, readsize);
|
||||
if (nbytes < 0)
|
||||
{
|
||||
int errval = _NX_GETERRNO(nbytes);
|
||||
|
||||
/* EINTR just means that we received a signal */
|
||||
/* EINTR just means that we received a signal */
|
||||
|
||||
if (errval != EINTR)
|
||||
{
|
||||
berr("ERROR: Read from offset %lu failed: %d\n",
|
||||
(unsigned long)offset, errval);
|
||||
return -errval;
|
||||
}
|
||||
}
|
||||
else if (nbytes == 0)
|
||||
{
|
||||
berr("ERROR: Unexpected end of file\n");
|
||||
return -ENODATA;
|
||||
}
|
||||
else
|
||||
{
|
||||
readsize -= nbytes;
|
||||
buffer += nbytes;
|
||||
offset += nbytes;
|
||||
}
|
||||
if (errval != EINTR)
|
||||
{
|
||||
berr("ERROR: Read from offset %lu failed: %d\n",
|
||||
(unsigned long)offset, errval);
|
||||
return -errval;
|
||||
}
|
||||
}
|
||||
else if (nbytes == 0)
|
||||
{
|
||||
berr("ERROR: Unexpected end of file\n");
|
||||
return -ENODATA;
|
||||
}
|
||||
else
|
||||
{
|
||||
readsize -= nbytes;
|
||||
buffer += nbytes;
|
||||
offset += nbytes;
|
||||
}
|
||||
}
|
||||
|
||||
modlib_dumpreaddata(buffer, readsize);
|
||||
|
@ -120,7 +120,8 @@ void modlib_registry_lock(void)
|
||||
* 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);
|
||||
}
|
||||
|
||||
|
@ -194,7 +194,8 @@ int modlib_loadshdrs(FAR struct mod_loadinfo_s *loadinfo)
|
||||
|
||||
/* 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)
|
||||
{
|
||||
berr("ERROR: Insufficent space in file for section header table\n");
|
||||
|
@ -82,8 +82,8 @@ struct mod_exportinfo_s
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
* EINVAL - There is something inconsistent in the symbol table (should only
|
||||
* happen if the file is corrupted).
|
||||
* EINVAL - There is something inconsistent in the symbol table (should
|
||||
* only happen if the file is corrupted).
|
||||
* ESRCH - Symbol has no name
|
||||
*
|
||||
****************************************************************************/
|
||||
@ -169,9 +169,9 @@ static int modlib_symname(FAR struct mod_loadinfo_s *loadinfo,
|
||||
* Name: modlib_symcallback
|
||||
*
|
||||
* Description:
|
||||
* modlib_registry_foreach() callback function. Test if the provided module,
|
||||
* modp, exports the symbol of interest. If so, return that symbol value
|
||||
* and setup the module dependency relationship.
|
||||
* modlib_registry_foreach() callback function. Test if the provided
|
||||
* module, modp, exports the symbol of interest. If so, return that symbol
|
||||
* value and setup the module dependency relationship.
|
||||
*
|
||||
* Returned Value:
|
||||
* 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)
|
||||
{
|
||||
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;
|
||||
|
||||
/* 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);
|
||||
#endif
|
||||
|
||||
if (exportinfo->symbol != NULL)
|
||||
{
|
||||
/* Yes.. save the dependency relationship and return SYM_FOUND to
|
||||
* stop the traversal.
|
||||
*/
|
||||
if (exportinfo->symbol != NULL)
|
||||
{
|
||||
/* Yes.. save the dependency relationship and return SYM_FOUND to
|
||||
* stop the traversal.
|
||||
*/
|
||||
|
||||
ret = modlib_depend(exportinfo->modp, modp);
|
||||
if (ret < 0)
|
||||
{
|
||||
berr("ERROR: modlib_depend failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
ret = modlib_depend(exportinfo->modp, modp);
|
||||
if (ret < 0)
|
||||
{
|
||||
berr("ERROR: modlib_depend failed: %d\n", 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
|
||||
* failure.
|
||||
*
|
||||
* EINVAL - There is something inconsistent in the symbol table (should only
|
||||
* happen if the file is corrupted).
|
||||
* EINVAL - There is something inconsistent in the symbol table (should
|
||||
* only happen if the file is corrupted).
|
||||
* ENOSYS - Symbol lies in common
|
||||
* ESRCH - Symbol has no name
|
||||
* 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.symbol = NULL;
|
||||
|
||||
ret = modlib_registry_foreach(modlib_symcallback, (FAR void *)&exportinfo);
|
||||
ret = modlib_registry_foreach(modlib_symcallback,
|
||||
(FAR void *)&exportinfo);
|
||||
if (ret < 0)
|
||||
{
|
||||
berr("ERROR: modlib_symcallback failed: \n", ret);
|
||||
|
@ -90,7 +90,8 @@ int modlib_verifyheader(FAR const Elf_Ehdr *ehdr)
|
||||
if (memcmp(ehdr->e_ident, g_modmagic, EI_MAGIC_SIZE) != 0)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user