mirror of
https://github.com/apache/nuttx.git
synced 2025-12-07 01:44:23 +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:
36
binfmt/elf.c
36
binfmt/elf.c
@@ -270,32 +270,28 @@ static int elf_loadbinary(FAR struct binary_s *binp)
|
||||
* 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
|
||||
/* Save the address environment in the binfmt structure. This will be
|
||||
* needed when the module is executed.
|
||||
*/
|
||||
|
||||
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
|
||||
|
||||
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 */
|
||||
|
||||
#ifdef CONFIG_BINFMT_CONSTRUCTORS
|
||||
#ifndef CONFIG_ARCH_ADDRENV
|
||||
if (loadinfo->ctoralloc != 0)
|
||||
{
|
||||
kumm_free(loadinfo->ctoralloc);
|
||||
loadinfo->ctoralloc = NULL;
|
||||
}
|
||||
|
||||
loadinfo->ctors = NULL;
|
||||
loadinfo->nctors = 0;
|
||||
|
||||
if (loadinfo->dtoralloc != 0)
|
||||
{
|
||||
kumm_free(loadinfo->dtoralloc);
|
||||
loadinfo->dtoralloc = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
loadinfo->dtors = NULL;
|
||||
loadinfo->ndtors = 0;
|
||||
loadinfo->ctoralloc = NULL;
|
||||
loadinfo->ctors = NULL;
|
||||
loadinfo->nctors = 0;
|
||||
|
||||
loadinfo->dtoralloc = NULL;
|
||||
loadinfo->dtors = NULL;
|
||||
loadinfo->ndtors = 0;
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
|
||||
Reference in New Issue
Block a user