mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 23:40:19 +08:00
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:
committed by
Xiang Xiao
parent
60200b6c9b
commit
ed4f651bbd
@@ -263,8 +263,8 @@ static int modlib_relocate(FAR struct module_s *modp,
|
|||||||
|
|
||||||
/* Read the symbol table entry into memory */
|
/* Read the symbol table entry into memory */
|
||||||
|
|
||||||
ret = modlib_symvalue(modp, loadinfo, sym,
|
ret = modlib_readsym(loadinfo, symidx, sym,
|
||||||
loadinfo->shdr[loadinfo->strtabidx].sh_offset);
|
&loadinfo->shdr[loadinfo->symtabidx]);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
berr("ERROR: Section %d reloc %d: "
|
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.
|
* 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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -324,12 +324,10 @@ int modlib_load(FAR struct mod_loadinfo_s *loadinfo)
|
|||||||
loadinfo->textalloc = (uintptr_t)
|
loadinfo->textalloc = (uintptr_t)
|
||||||
up_textheap_memalign(loadinfo->textalign,
|
up_textheap_memalign(loadinfo->textalign,
|
||||||
loadinfo->textsize +
|
loadinfo->textsize +
|
||||||
loadinfo->datasize +
|
|
||||||
loadinfo->segpad);
|
loadinfo->segpad);
|
||||||
#else
|
#else
|
||||||
loadinfo->textalloc = (uintptr_t)lib_memalign(loadinfo->textalign,
|
loadinfo->textalloc = (uintptr_t)lib_memalign(loadinfo->textalign,
|
||||||
loadinfo->textsize +
|
loadinfo->textsize +
|
||||||
loadinfo->datasize +
|
|
||||||
loadinfo->segpad);
|
loadinfo->segpad);
|
||||||
#endif
|
#endif
|
||||||
if (!loadinfo->textalloc)
|
if (!loadinfo->textalloc)
|
||||||
@@ -342,9 +340,14 @@ int modlib_load(FAR struct mod_loadinfo_s *loadinfo)
|
|||||||
|
|
||||||
if (loadinfo->datasize > 0)
|
if (loadinfo->datasize > 0)
|
||||||
{
|
{
|
||||||
loadinfo->datastart = loadinfo->textalloc +
|
loadinfo->datastart = (uintptr_t)lib_memalign(loadinfo->dataalign,
|
||||||
loadinfo->textsize +
|
loadinfo->datasize);
|
||||||
loadinfo->segpad;
|
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 */
|
/* Load ELF section data into memory */
|
||||||
|
|||||||
Reference in New Issue
Block a user