1
0
Fork 0
forked from nuttx/nuttx-update

sched/modules: Be consistent use of binary loader debug instrumentation. Was mixed system and binary loader debug. libs/libc/modlib: Switch from systemb to binary load debug to be consistent with sched/modules.

This commit is contained in:
Gregory Nutt 2018-06-01 10:10:17 -06:00
parent 12de93dd36
commit a6a88198c0
13 changed files with 68 additions and 68 deletions

View file

@ -74,7 +74,7 @@ static inline int modlib_readrel(FAR struct mod_loadinfo_s *loadinfo,
if (index < 0 || index > (relsec->sh_size / sizeof(Elf32_Rel)))
{
serr("ERROR: Bad relocation symbol index: %d\n", index);
berr("ERROR: Bad relocation symbol index: %d\n", index);
return -EINVAL;
}
@ -127,7 +127,7 @@ static int modlib_relocate(FAR struct module_s *modp,
ret = modlib_readrel(loadinfo, relsec, i, &rel);
if (ret < 0)
{
serr("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);
return ret;
}
@ -143,7 +143,7 @@ static int modlib_relocate(FAR struct module_s *modp,
ret = modlib_readsym(loadinfo, symidx, &sym);
if (ret < 0)
{
serr("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);
return ret;
}
@ -165,13 +165,13 @@ static int modlib_relocate(FAR struct module_s *modp,
if (ret == -ESRCH)
{
serr("ERROR: Section %d reloc %d: Undefined symbol[%d] has no name: %d\n",
berr("ERROR: Section %d reloc %d: Undefined symbol[%d] has no name: %d\n",
relidx, i, symidx, ret);
psym = NULL;
}
else
{
serr("ERROR: Section %d reloc %d: Failed to get value of symbol[%d]: %d\n",
berr("ERROR: Section %d reloc %d: Failed to get value of symbol[%d]: %d\n",
relidx, i, symidx, ret);
return ret;
}
@ -181,7 +181,7 @@ static int modlib_relocate(FAR struct module_s *modp,
if (rel.r_offset < 0 || rel.r_offset > dstsec->sh_size - sizeof(uint32_t))
{
serr("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);
return -EINVAL;
}
@ -193,7 +193,7 @@ static int modlib_relocate(FAR struct module_s *modp,
ret = up_relocate(&rel, psym, addr);
if (ret < 0)
{
serr("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);
return ret;
}
}
@ -204,7 +204,7 @@ static int modlib_relocate(FAR struct module_s *modp,
static int modlib_relocateadd(FAR struct module_s *modp,
FAR struct mod_loadinfo_s *loadinfo, int relidx)
{
serr("ERROR: Not implemented\n");
berr("ERROR: Not implemented\n");
return -ENOSYS;
}
@ -249,7 +249,7 @@ int modlib_bind(FAR struct module_s *modp, FAR struct mod_loadinfo_s *loadinfo)
ret = modlib_allocbuffer(loadinfo);
if (ret < 0)
{
serr("ERROR: modlib_allocbuffer failed: %d\n", ret);
berr("ERROR: modlib_allocbuffer failed: %d\n", ret);
return -ENOMEM;
}

View file

@ -66,7 +66,7 @@
#endif
#ifdef CONFIG_MODLIB_DUMPBUFFER
# define modlib_dumpbuffer(m,b,n) sinfodumpbuffer(m,b,n)
# define modlib_dumpbuffer(m,b,n) binfodumpbuffer(m,b,n)
#else
# define modlib_dumpbuffer(m,b,n)
#endif
@ -99,7 +99,7 @@ static inline int modlib_filelen(FAR struct mod_loadinfo_s *loadinfo,
if (ret < 0)
{
int errval = get_errno();
serr("ERROR: Failed to stat file: %d\n", errval);
berr("ERROR: Failed to stat file: %d\n", errval);
return -errval;
}
@ -107,7 +107,7 @@ static inline int modlib_filelen(FAR struct mod_loadinfo_s *loadinfo,
if (!S_ISREG(buf.st_mode))
{
serr("ERROR: Not a regular file. mode: %d\n", buf.st_mode);
berr("ERROR: Not a regular file. mode: %d\n", buf.st_mode);
return -ENOENT;
}
@ -143,7 +143,7 @@ int modlib_initialize(FAR const char *filename,
{
int ret;
sinfo("filename: %s loadinfo: %p\n", filename, loadinfo);
binfo("filename: %s loadinfo: %p\n", filename, loadinfo);
/* Clear the load info structure */
@ -154,7 +154,7 @@ int modlib_initialize(FAR const char *filename,
ret = modlib_filelen(loadinfo, filename);
if (ret < 0)
{
serr("ERROR: modlib_filelen failed: %d\n", ret);
berr("ERROR: modlib_filelen failed: %d\n", ret);
return ret;
}
@ -164,7 +164,7 @@ int modlib_initialize(FAR const char *filename,
if (loadinfo->filfd < 0)
{
int errval = get_errno();
serr("ERROR: Failed to open ELF binary %s: %d\n", filename, errval);
berr("ERROR: Failed to open ELF binary %s: %d\n", filename, errval);
return -errval;
}
@ -174,7 +174,7 @@ int modlib_initialize(FAR const char *filename,
sizeof(Elf32_Ehdr), 0);
if (ret < 0)
{
serr("ERROR: Failed to read ELF header: %d\n", ret);
berr("ERROR: Failed to read ELF header: %d\n", ret);
return ret;
}
@ -193,7 +193,7 @@ int modlib_initialize(FAR const char *filename,
* is not correctly formed.
*/
serr("ERROR: Bad ELF header: %d\n", ret);
berr("ERROR: Bad ELF header: %d\n", ret);
return ret;
}

View file

@ -76,7 +76,7 @@ int modlib_allocbuffer(FAR struct mod_loadinfo_s *loadinfo)
loadinfo->iobuffer = (FAR uint8_t *)lib_malloc(CONFIG_MODLIB_BUFFERSIZE);
if (!loadinfo->iobuffer)
{
serr("ERROR: Failed to allocate an I/O buffer\n");
berr("ERROR: Failed to allocate an I/O buffer\n");
return -ENOMEM;
}
@ -112,7 +112,7 @@ int modlib_reallocbuffer(FAR struct mod_loadinfo_s *loadinfo, size_t increment)
buffer = lib_realloc((FAR void *)loadinfo->iobuffer, newsize);
if (!buffer)
{
serr("ERROR: Failed to reallocate the I/O buffer\n");
berr("ERROR: Failed to reallocate the I/O buffer\n");
return -ENOMEM;
}

View file

@ -153,7 +153,7 @@ static inline int modlib_loadfile(FAR struct mod_loadinfo_s *loadinfo)
/* Read each section into memory that is marked SHF_ALLOC + SHT_NOBITS */
sinfo("Loaded sections:\n");
binfo("Loaded sections:\n");
text = (FAR uint8_t *)loadinfo->textalloc;
data = (FAR uint8_t *)loadinfo->datastart;
@ -193,7 +193,7 @@ static inline int modlib_loadfile(FAR struct mod_loadinfo_s *loadinfo)
ret = modlib_read(loadinfo, *pptr, shdr->sh_size, shdr->sh_offset);
if (ret < 0)
{
serr("ERROR: Failed to read section %d: %d\n", i, ret);
berr("ERROR: Failed to read section %d: %d\n", i, ret);
return ret;
}
}
@ -209,7 +209,7 @@ static inline int modlib_loadfile(FAR struct mod_loadinfo_s *loadinfo)
/* Update sh_addr to point to copy in memory */
sinfo("%d. %08lx->%08lx\n", i,
binfo("%d. %08lx->%08lx\n", i,
(unsigned long)shdr->sh_addr, (unsigned long)*pptr);
shdr->sh_addr = (uintptr_t)*pptr;
@ -243,7 +243,7 @@ int modlib_load(FAR struct mod_loadinfo_s *loadinfo)
{
int ret;
sinfo("loadinfo: %p\n", loadinfo);
binfo("loadinfo: %p\n", loadinfo);
DEBUGASSERT(loadinfo && loadinfo->filfd >= 0);
/* Load section headers into memory */
@ -251,7 +251,7 @@ int modlib_load(FAR struct mod_loadinfo_s *loadinfo)
ret = modlib_loadshdrs(loadinfo);
if (ret < 0)
{
serr("ERROR: modlib_loadshdrs failed: %d\n", ret);
berr("ERROR: modlib_loadshdrs failed: %d\n", ret);
goto errout_with_buffers;
}
@ -266,7 +266,7 @@ int modlib_load(FAR struct mod_loadinfo_s *loadinfo)
loadinfo->textalloc = (uintptr_t)lib_zalloc(loadinfo->textsize + loadinfo->datasize);
if (!loadinfo->textalloc)
{
serr("ERROR: Failed to allocate memory for the module\n");
berr("ERROR: Failed to allocate memory for the module\n");
ret = -ENOMEM;
goto errout_with_buffers;
}
@ -278,7 +278,7 @@ int modlib_load(FAR struct mod_loadinfo_s *loadinfo)
ret = modlib_loadfile(loadinfo);
if (ret < 0)
{
serr("ERROR: modlib_loadfile failed: %d\n", ret);
berr("ERROR: modlib_loadfile failed: %d\n", ret);
goto errout_with_buffers;
}

View file

@ -110,7 +110,7 @@ int modlib_read(FAR struct mod_loadinfo_s *loadinfo, FAR uint8_t *buffer,
ssize_t nbytes; /* Number of bytes read */
off_t rpos; /* Position returned by lseek */
sinfo("Read %ld bytes from offset %ld\n", (long)readsize, (long)offset);
binfo("Read %ld bytes from offset %ld\n", (long)readsize, (long)offset);
/* Loop until all of the requested data has been read. */
@ -122,7 +122,7 @@ int modlib_read(FAR struct mod_loadinfo_s *loadinfo, FAR uint8_t *buffer,
if (rpos != offset)
{
int errval = get_errno();
serr("ERROR: Failed to seek to position %lu: %d\n",
berr("ERROR: Failed to seek to position %lu: %d\n",
(unsigned long)offset, errval);
return -errval;
}
@ -138,14 +138,14 @@ int modlib_read(FAR struct mod_loadinfo_s *loadinfo, FAR uint8_t *buffer,
if (errval != EINTR)
{
serr("ERROR: Read from offset %lu failed: %d\n",
berr("ERROR: Read from offset %lu failed: %d\n",
(unsigned long)offset, errval);
return -errval;
}
}
else if (nbytes == 0)
{
serr("ERROR: Unexpected end of file\n");
berr("ERROR: Unexpected end of file\n");
return -ENODATA;
}
else

View file

@ -223,7 +223,7 @@ int modlib_registry_del(FAR struct module_s *modp)
if (curr == NULL)
{
serr("ERROR: Could not find module entry\n");
berr("ERROR: Could not find module entry\n");
return -ENOENT;
}

View file

@ -86,7 +86,7 @@ static inline int modlib_sectname(FAR struct mod_loadinfo_s *loadinfo,
shstrndx = loadinfo->ehdr.e_shstrndx;
if (shstrndx == SHN_UNDEF)
{
serr("ERROR: No section header string table\n");
berr("ERROR: No section header string table\n");
return -EINVAL;
}
@ -119,7 +119,7 @@ static inline int modlib_sectname(FAR struct mod_loadinfo_s *loadinfo,
{
if (loadinfo->filelen <= offset)
{
serr("ERROR: At end of file\n");
berr("ERROR: At end of file\n");
return -EINVAL;
}
@ -132,7 +132,7 @@ static inline int modlib_sectname(FAR struct mod_loadinfo_s *loadinfo,
ret = modlib_read(loadinfo, buffer, readlen, offset);
if (ret < 0)
{
serr("ERROR: Failed to read section name: %d\n", ret);
berr("ERROR: Failed to read section name: %d\n", ret);
return ret;
}
@ -152,7 +152,7 @@ static inline int modlib_sectname(FAR struct mod_loadinfo_s *loadinfo,
ret = modlib_reallocbuffer(loadinfo, CONFIG_MODLIB_BUFFERINCR);
if (ret < 0)
{
serr("ERROR: mod_reallocbuffer failed: %d\n", ret);
berr("ERROR: mod_reallocbuffer failed: %d\n", ret);
return ret;
}
}
@ -189,7 +189,7 @@ int modlib_loadshdrs(FAR struct mod_loadinfo_s *loadinfo)
if (loadinfo->ehdr.e_shnum < 1)
{
serr("ERROR: No sections(?)\n");
berr("ERROR: No sections(?)\n");
return -EINVAL;
}
@ -198,7 +198,7 @@ int modlib_loadshdrs(FAR struct mod_loadinfo_s *loadinfo)
shdrsize = (size_t)loadinfo->ehdr.e_shentsize * (size_t)loadinfo->ehdr.e_shnum;
if (loadinfo->ehdr.e_shoff + shdrsize > loadinfo->filelen)
{
serr("ERROR: Insufficent space in file for section header table\n");
berr("ERROR: Insufficent space in file for section header table\n");
return -ESPIPE;
}
@ -207,7 +207,7 @@ int modlib_loadshdrs(FAR struct mod_loadinfo_s *loadinfo)
loadinfo->shdr = (FAR FAR Elf32_Shdr *)lib_malloc(shdrsize);
if (!loadinfo->shdr)
{
serr("ERROR: Failed to allocate the section header table. Size: %ld\n",
berr("ERROR: Failed to allocate the section header table. Size: %ld\n",
(long)shdrsize);
return -ENOMEM;
}
@ -218,7 +218,7 @@ int modlib_loadshdrs(FAR struct mod_loadinfo_s *loadinfo)
loadinfo->ehdr.e_shoff);
if (ret < 0)
{
serr("ERROR: Failed to read section header table: %d\n", ret);
berr("ERROR: Failed to read section header table: %d\n", ret);
}
return ret;
@ -258,13 +258,13 @@ int modlib_findsection(FAR struct mod_loadinfo_s *loadinfo,
ret = modlib_sectname(loadinfo, shdr);
if (ret < 0)
{
serr("ERROR: modlib_sectname failed: %d\n", ret);
berr("ERROR: modlib_sectname failed: %d\n", ret);
return ret;
}
/* Check if the name of this section is 'sectname' */
sinfo("%d. Comparing \"%s\" and .\"%s\"\n",
binfo("%d. Comparing \"%s\" and .\"%s\"\n",
i, loadinfo->iobuffer, sectname);
if (strcmp((FAR const char *)loadinfo->iobuffer, sectname) == 0)

View file

@ -112,7 +112,7 @@ static int modlib_symname(FAR struct mod_loadinfo_s *loadinfo,
if (sym->st_name == 0)
{
serr("ERROR: Symbol has no name\n");
berr("ERROR: Symbol has no name\n");
return -ESRCH;
}
@ -131,7 +131,7 @@ static int modlib_symname(FAR struct mod_loadinfo_s *loadinfo,
{
if (loadinfo->filelen <= offset)
{
serr("ERROR: At end of file\n");
berr("ERROR: At end of file\n");
return -EINVAL;
}
@ -144,7 +144,7 @@ static int modlib_symname(FAR struct mod_loadinfo_s *loadinfo,
ret = modlib_read(loadinfo, buffer, readlen, offset);
if (ret < 0)
{
serr("ERROR: modlib_read failed: %d\n", ret);
berr("ERROR: modlib_read failed: %d\n", ret);
return ret;
}
@ -164,7 +164,7 @@ static int modlib_symname(FAR struct mod_loadinfo_s *loadinfo,
ret = modlib_reallocbuffer(loadinfo, CONFIG_MODLIB_BUFFERINCR);
if (ret < 0)
{
serr("ERROR: mod_reallocbuffer failed: %d\n", ret);
berr("ERROR: mod_reallocbuffer failed: %d\n", ret);
return ret;
}
}
@ -214,7 +214,7 @@ static int modlib_symcallback(FAR struct module_s *modp, FAR void *arg)
ret = modlib_depend(exportinfo->modp, modp);
if (ret < 0)
{
serr("ERROR: modlib_depend failed: %d\n", ret);
berr("ERROR: modlib_depend failed: %d\n", ret);
return ret;
}
@ -260,7 +260,7 @@ int modlib_findsymtab(FAR struct mod_loadinfo_s *loadinfo)
if (loadinfo->symtabidx == 0)
{
serr("ERROR: No symbols in ELF file\n");
berr("ERROR: No symbols in ELF file\n");
return -EINVAL;
}
@ -294,7 +294,7 @@ int modlib_readsym(FAR struct mod_loadinfo_s *loadinfo, int index,
if (index < 0 || index > (symtab->sh_size / sizeof(Elf32_Sym)))
{
serr("ERROR: Bad relocation symbol index: %d\n", index);
berr("ERROR: Bad relocation symbol index: %d\n", index);
return -EINVAL;
}
@ -345,7 +345,7 @@ int modlib_symvalue(FAR struct module_s *modp,
{
/* NuttX ELF modules should be compiled with -fno-common. */
serr("ERROR: SHN_COMMON: Re-compile with -fno-common\n");
berr("ERROR: SHN_COMMON: Re-compile with -fno-common\n");
return -ENOSYS;
}
@ -353,7 +353,7 @@ int modlib_symvalue(FAR struct module_s *modp,
{
/* st_value already holds the correct value */
sinfo("SHN_ABS: st_value=%08lx\n", (long)sym->st_value);
binfo("SHN_ABS: st_value=%08lx\n", (long)sym->st_value);
return OK;
}
@ -370,7 +370,7 @@ int modlib_symvalue(FAR struct module_s *modp,
* indicate the nameless symbol.
*/
serr("ERROR: SHN_UNDEF: Failed to get symbol name: %d\n", ret);
berr("ERROR: SHN_UNDEF: Failed to get symbol name: %d\n", ret);
return ret;
}
@ -387,7 +387,7 @@ int modlib_symvalue(FAR struct module_s *modp,
ret = modlib_registry_foreach(modlib_symcallback, (FAR void *)&exportinfo);
if (ret < 0)
{
serr("ERROR: modlib_symcallback failed: \n", ret);
berr("ERROR: modlib_symcallback failed: \n", ret);
return ret;
}
@ -412,14 +412,14 @@ int modlib_symvalue(FAR struct module_s *modp,
if (symbol == NULL)
{
serr("ERROR: SHN_UNDEF: Exported symbol \"%s\" not found\n",
berr("ERROR: SHN_UNDEF: Exported symbol \"%s\" not found\n",
loadinfo->iobuffer);
return -ENOENT;
}
/* Yes... add the exported symbol value to the ELF symbol table entry */
sinfo("SHN_ABS: name=%s %08x+%08x=%08x\n",
binfo("SHN_ABS: name=%s %08x+%08x=%08x\n",
loadinfo->iobuffer, sym->st_value, symbol->sym_value,
sym->st_value + symbol->sym_value);
@ -431,7 +431,7 @@ int modlib_symvalue(FAR struct module_s *modp,
{
secbase = loadinfo->shdr[sym->st_shndx].sh_addr;
sinfo("Other: %08x+%08x=%08x\n",
binfo("Other: %08x+%08x=%08x\n",
sym->st_value, secbase, sym->st_value + secbase);
sym->st_value += secbase;

View file

@ -81,7 +81,7 @@ int modlib_verifyheader(FAR const Elf32_Ehdr *ehdr)
{
if (!ehdr)
{
serr("ERROR: NULL ELF header!");
berr("ERROR: NULL ELF header!");
return -ENOEXEC;
}
@ -89,7 +89,7 @@ int modlib_verifyheader(FAR const Elf32_Ehdr *ehdr)
if (memcmp(ehdr->e_ident, g_modmagic, EI_MAGIC_SIZE) != 0)
{
sinfo("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]);
return -ENOEXEC;
}
@ -98,7 +98,7 @@ int modlib_verifyheader(FAR const Elf32_Ehdr *ehdr)
if (ehdr->e_type != ET_REL)
{
serr("ERROR: Not a relocatable file: e_type=%d\n", ehdr->e_type);
berr("ERROR: Not a relocatable file: e_type=%d\n", ehdr->e_type);
return -EINVAL;
}
@ -106,7 +106,7 @@ int modlib_verifyheader(FAR const Elf32_Ehdr *ehdr)
if (!up_checkarch(ehdr))
{
serr("ERROR: Not a supported architecture\n");
berr("ERROR: Not a supported architecture\n");
return -ENOEXEC;
}

View file

@ -200,7 +200,7 @@ FAR void *insmod(FAR const char *filename, FAR const char *modname)
mod_dumploadinfo(&loadinfo);
if (ret != 0)
{
serr("ERROR: Failed to initialize to load module: %d\n", ret);
berr("ERROR: Failed to initialize to load module: %d\n", ret);
goto errout_with_lock;
}

View file

@ -85,7 +85,7 @@ FAR void *modhandle(FAR const char *name)
modp = modlib_registry_find(name);
if (modp == NULL)
{
serr("ERROR: Failed to find module %s: %d\n", name, modp);
berr("ERROR: Failed to find module %s: %d\n", name, modp);
set_errno(ENOENT);
}

View file

@ -93,7 +93,7 @@ FAR const void *modsym(FAR void *handle, FAR const char *name)
ret = modlib_registry_verify(modp);
if (ret < 0)
{
serr("ERROR: Failed to verify module: %d\n", ret);
berr("ERROR: Failed to verify module: %d\n", ret);
err = -ret;
goto errout_with_lock;
}
@ -102,7 +102,7 @@ FAR const void *modsym(FAR void *handle, FAR const char *name)
if (modp->modinfo.exports == NULL || modp->modinfo.nexports == 0)
{
serr("ERROR: Module has no symbol table\n");
berr("ERROR: Module has no symbol table\n");
err = ENOENT;
goto errout_with_lock;
}
@ -113,7 +113,7 @@ FAR const void *modsym(FAR void *handle, FAR const char *name)
modp->modinfo.nexports);
if (symbol == NULL)
{
serr("ERROR: Failed to find symbol in symbol \"$s\" in table\n", name);
berr("ERROR: Failed to find symbol in symbol \"$s\" in table\n", name);
err = ENOENT;
goto errout_with_lock;
}

View file

@ -84,7 +84,7 @@ int rmmod(FAR void *handle)
ret = modlib_registry_verify(modp);
if (ret < 0)
{
serr("ERROR: Failed to verify module: %d\n", ret);
berr("ERROR: Failed to verify module: %d\n", ret);
goto errout_with_lock;
}
@ -93,7 +93,7 @@ int rmmod(FAR void *handle)
if (modp->dependents > 0)
{
serr("ERROR: Module has dependents: %d\n", modp->dependents);
berr("ERROR: Module has dependents: %d\n", modp->dependents);
ret = -EBUSY;
goto errout_with_lock;
}
@ -111,7 +111,7 @@ int rmmod(FAR void *handle)
if (ret < 0)
{
serr("ERROR: Failed to uninitialize the module: %d\n", ret);
berr("ERROR: Failed to uninitialize the module: %d\n", ret);
goto errout_with_lock;
}
@ -148,7 +148,7 @@ int rmmod(FAR void *handle)
ret = modlib_registry_del(modp);
if (ret < 0)
{
serr("ERROR: Failed to remove the module from the registry: %d\n", ret);
berr("ERROR: Failed to remove the module from the registry: %d\n", ret);
goto errout_with_lock;
}