Fix modlib to get binary loading working again
This patch fixes the issue reported here: https://github.com/apache/nuttx/issues/9845
This commit is contained in:
parent
60200b6c9b
commit
ed4f651bbd
@ -263,8 +263,8 @@ static int modlib_relocate(FAR struct module_s *modp,
|
||||
|
||||
/* Read the symbol table entry into memory */
|
||||
|
||||
ret = modlib_symvalue(modp, loadinfo, sym,
|
||||
loadinfo->shdr[loadinfo->strtabidx].sh_offset);
|
||||
ret = modlib_readsym(loadinfo, symidx, sym,
|
||||
&loadinfo->shdr[loadinfo->symtabidx]);
|
||||
if (ret < 0)
|
||||
{
|
||||
berr("ERROR: Section %d reloc %d: "
|
||||
@ -862,7 +862,7 @@ int modlib_bind(FAR struct module_s *modp,
|
||||
* sections that were not loaded into memory.
|
||||
*/
|
||||
|
||||
if ((loadinfo->shdr[i].sh_flags & SHF_ALLOC) == 0)
|
||||
if ((loadinfo->shdr[infosec].sh_flags & SHF_ALLOC) == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -324,12 +324,10 @@ int modlib_load(FAR struct mod_loadinfo_s *loadinfo)
|
||||
loadinfo->textalloc = (uintptr_t)
|
||||
up_textheap_memalign(loadinfo->textalign,
|
||||
loadinfo->textsize +
|
||||
loadinfo->datasize +
|
||||
loadinfo->segpad);
|
||||
#else
|
||||
loadinfo->textalloc = (uintptr_t)lib_memalign(loadinfo->textalign,
|
||||
loadinfo->textsize +
|
||||
loadinfo->datasize +
|
||||
loadinfo->segpad);
|
||||
#endif
|
||||
if (!loadinfo->textalloc)
|
||||
@ -342,9 +340,14 @@ int modlib_load(FAR struct mod_loadinfo_s *loadinfo)
|
||||
|
||||
if (loadinfo->datasize > 0)
|
||||
{
|
||||
loadinfo->datastart = loadinfo->textalloc +
|
||||
loadinfo->textsize +
|
||||
loadinfo->segpad;
|
||||
loadinfo->datastart = (uintptr_t)lib_memalign(loadinfo->dataalign,
|
||||
loadinfo->datasize);
|
||||
if (!loadinfo->datastart)
|
||||
{
|
||||
berr("ERROR: Failed to allocate memory for the module data\n");
|
||||
ret = -ENOMEM;
|
||||
goto errout_with_buffers;
|
||||
}
|
||||
}
|
||||
|
||||
/* Load ELF section data into memory */
|
||||
|
Loading…
Reference in New Issue
Block a user