From 56a650461894d8ab541277010e93fd5ca75f9f0d Mon Sep 17 00:00:00 2001 From: patacongo Date: Wed, 19 Dec 2012 17:54:26 +0000 Subject: Incorporate address environment interfaces in binfmt/ logic git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5443 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/binfmt/nxflat.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'nuttx/binfmt/nxflat.c') diff --git a/nuttx/binfmt/nxflat.c b/nuttx/binfmt/nxflat.c index 5973a96a9..db29941ca 100644 --- a/nuttx/binfmt/nxflat.c +++ b/nuttx/binfmt/nxflat.c @@ -187,10 +187,31 @@ static int nxflat_loadbinary(struct binary_s *binp) binp->entrypt = (main_t)(loadinfo.ispace + loadinfo.entryoffs); binp->mapped = (void*)loadinfo.ispace; - binp->alloc[0] = (void*)loadinfo.dspace; binp->mapsize = loadinfo.isize; binp->stacksize = loadinfo.stacksize; + /* Add the ELF allocation to the alloc[] only if there is no address + * enironment. If there is an address environment, it will automatically + * be freed when the function exits + * + * REVISIT: If the module is loaded then unloaded, wouldn't this cause + * a memory leak? + */ + +#ifdef CONFIG_ADDRENV +# warning "REVISIT" +#else + binp->alloc[0] = (void*)loadinfo.dspace; +#endif + +#ifdef CONFIG_ADDRENV + /* Save the address environment. This will be needed when the module is + * executed for the up_addrenv_assign() call. + */ + + binp->addrenv = loadinfo.addrenv; +#endif + nxflat_dumpbuffer("Entry code", (FAR const uint8_t*)binp->entrypt, MIN(loadinfo.isize - loadinfo.entryoffs, 512)); -- cgit v1.2.3