mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 05:16:47 +08:00
binfmt/: If there is an address environment (CONFIG_ARCH_ADDRENV), binfmt/elf doesn't need to free ctor/dtor alloc since freeing the address environment releases the heap automatically.
This commit is contained in:
+16
-20
@@ -270,32 +270,28 @@ static int elf_loadbinary(FAR struct binary_s *binp)
|
|||||||
* a memory leak?
|
* a memory leak?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_ADDRENV
|
|
||||||
# warning "REVISIT"
|
|
||||||
#else
|
|
||||||
binp->alloc[0] = (FAR void *)loadinfo.textalloc;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_BINFMT_CONSTRUCTORS
|
|
||||||
/* Save information about constructors. NOTE: destructors are not
|
|
||||||
* yet supported.
|
|
||||||
*/
|
|
||||||
|
|
||||||
binp->alloc[1] = loadinfo.ctoralloc;
|
|
||||||
binp->ctors = loadinfo.ctors;
|
|
||||||
binp->nctors = loadinfo.nctors;
|
|
||||||
|
|
||||||
binp->alloc[2] = loadinfo.dtoralloc;
|
|
||||||
binp->dtors = loadinfo.dtors;
|
|
||||||
binp->ndtors = loadinfo.ndtors;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_ADDRENV
|
#ifdef CONFIG_ARCH_ADDRENV
|
||||||
/* Save the address environment in the binfmt structure. This will be
|
/* Save the address environment in the binfmt structure. This will be
|
||||||
* needed when the module is executed.
|
* needed when the module is executed.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
up_addrenv_clone(&loadinfo.addrenv, &binp->addrenv);
|
up_addrenv_clone(&loadinfo.addrenv, &binp->addrenv);
|
||||||
|
#else
|
||||||
|
binp->alloc[0] = (FAR void *)loadinfo.textalloc;
|
||||||
|
#ifdef CONFIG_BINFMT_CONSTRUCTORS
|
||||||
|
binp->alloc[1] = loadinfo.ctoralloc;
|
||||||
|
binp->alloc[2] = loadinfo.dtoralloc;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_BINFMT_CONSTRUCTORS
|
||||||
|
/* Save information about constructors and destructors. */
|
||||||
|
|
||||||
|
binp->ctors = loadinfo.ctors;
|
||||||
|
binp->nctors = loadinfo.nctors;
|
||||||
|
|
||||||
|
binp->dtors = loadinfo.dtors;
|
||||||
|
binp->ndtors = loadinfo.ndtors;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
elf_dumpentrypt(binp, &loadinfo);
|
elf_dumpentrypt(binp, &loadinfo);
|
||||||
|
|||||||
@@ -90,23 +90,24 @@ int elf_unload(struct elf_loadinfo_s *loadinfo)
|
|||||||
/* Release memory used to hold static constructors and destructors */
|
/* Release memory used to hold static constructors and destructors */
|
||||||
|
|
||||||
#ifdef CONFIG_BINFMT_CONSTRUCTORS
|
#ifdef CONFIG_BINFMT_CONSTRUCTORS
|
||||||
|
#ifndef CONFIG_ARCH_ADDRENV
|
||||||
if (loadinfo->ctoralloc != 0)
|
if (loadinfo->ctoralloc != 0)
|
||||||
{
|
{
|
||||||
kumm_free(loadinfo->ctoralloc);
|
kumm_free(loadinfo->ctoralloc);
|
||||||
loadinfo->ctoralloc = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loadinfo->ctors = NULL;
|
|
||||||
loadinfo->nctors = 0;
|
|
||||||
|
|
||||||
if (loadinfo->dtoralloc != 0)
|
if (loadinfo->dtoralloc != 0)
|
||||||
{
|
{
|
||||||
kumm_free(loadinfo->dtoralloc);
|
kumm_free(loadinfo->dtoralloc);
|
||||||
loadinfo->dtoralloc = NULL;
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
loadinfo->dtors = NULL;
|
loadinfo->ctoralloc = NULL;
|
||||||
loadinfo->ndtors = 0;
|
loadinfo->ctors = NULL;
|
||||||
|
loadinfo->nctors = 0;
|
||||||
|
|
||||||
|
loadinfo->dtoralloc = NULL;
|
||||||
|
loadinfo->dtors = NULL;
|
||||||
|
loadinfo->ndtors = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
|||||||
Reference in New Issue
Block a user