diff options
author | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2009-06-25 21:59:30 +0000 |
---|---|---|
committer | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2009-06-25 21:59:30 +0000 |
commit | 011bd5ef3114a7e695cc0159754d3a93cb6677b8 (patch) | |
tree | f1c3ddab7c38ffff9f9e1ed662bed53bb6267625 /nuttx/binfmt | |
parent | a890f13bd983044a061419eda06ff2b949deb83c (diff) |
Mostly cosmetic integration changes
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@1953 7fd9a85b-ad96-42d3-883c-3090e2eb8679
Diffstat (limited to 'nuttx/binfmt')
-rw-r--r-- | nuttx/binfmt/libnxflat/libnxflat_bind.c | 14 | ||||
-rw-r--r-- | nuttx/binfmt/libnxflat/libnxflat_init.c | 49 | ||||
-rw-r--r-- | nuttx/binfmt/nxflat.c | 17 |
3 files changed, 43 insertions, 37 deletions
diff --git a/nuttx/binfmt/libnxflat/libnxflat_bind.c b/nuttx/binfmt/libnxflat/libnxflat_bind.c index 84ef3a9a32..4e89a76ecb 100644 --- a/nuttx/binfmt/libnxflat/libnxflat_bind.c +++ b/nuttx/binfmt/libnxflat/libnxflat_bind.c @@ -54,17 +54,15 @@ * Pre-processor Definitions ****************************************************************************/ -#undef NXFLAT_DUMPBUFFER /* Define to enable very verbose buffer dumping */ - /* CONFIG_DEBUG, CONFIG_DEBUG_VERBOSE, and CONFIG_DEBUG_BINFMT have to be - * defined or NXFLAT_DUMPBUFFER does nothing. + * defined or CONFIG_NXFLAT_DUMPBUFFER does nothing. */ #if !defined(CONFIG_DEBUG_VERBOSE) || !defined (CONFIG_DEBUG_BINFMT) -# undef NXFLAT_DUMPBUFFER +# undef CONFIG_NXFLAT_DUMPBUFFER #endif -#ifdef NXFLAT_DUMPBUFFER +#ifdef CONFIG_NXFLAT_DUMPBUFFER # define nxflat_dumpbuffer(m,b,n) bvdbgdumpbuffer(m,b,n) #else # define nxflat_dumpbuffer(m,b,n) @@ -319,7 +317,7 @@ static inline int nxflat_gotrelocs(FAR struct nxflat_loadinfo_s *loadinfo) /* Dump the relocation got */ -#ifdef NXFLAT_DUMPBUFFER +#ifdef CONFIG_NXFLAT_DUMPBUFFER if (ret == OK && nrelocs > 0) { relocs = (FAR struct nxflat_reloc_s*)(offset - loadinfo->isize + loadinfo->dspace->region); @@ -421,14 +419,14 @@ static inline int nxflat_bindimports(FAR struct nxflat_loadinfo_s *loadinfo, imports[i].i_funcaddress = (uint32)symbol->sym_value; - bvdbg("Bound import %d (%08p) to export 's' (%08x)\n", + bvdbg("Bound import %d (%08p) to export '%s' (%08x)\n", i, &imports[i], symname, imports[i].i_funcaddress); } } /* Dump the relocation import table */ -#ifdef NXFLAT_DUMPBUFFER +#ifdef CONFIG_NXFLAT_DUMPBUFFER if (nimports > 0) { nxflat_dumpbuffer("Imports", (FAR const ubyte*)imports, nimports * sizeof(struct nxflat_import_s)); diff --git a/nuttx/binfmt/libnxflat/libnxflat_init.c b/nuttx/binfmt/libnxflat/libnxflat_init.c index 6a7a987482..321c90e51c 100644 --- a/nuttx/binfmt/libnxflat/libnxflat_init.c +++ b/nuttx/binfmt/libnxflat/libnxflat_init.c @@ -54,6 +54,20 @@ * Pre-Processor Definitions ****************************************************************************/ +/* CONFIG_DEBUG, CONFIG_DEBUG_VERBOSE, and CONFIG_DEBUG_BINFMT have to be + * defined or CONFIG_NXFLAT_DUMPBUFFER does nothing. + */ + +#if !defined(CONFIG_DEBUG_VERBOSE) || !defined (CONFIG_DEBUG_BINFMT) +# undef CONFIG_NXFLAT_DUMPBUFFER +#endif + +#ifdef CONFIG_NXFLAT_DUMPBUFFER +# define nxflat_dumpbuffer(m,b,n) bvdbgdumpbuffer(m,b,n) +#else +# define nxflat_dumpbuffer(m,b,n) +#endif + /**************************************************************************** * Private Constant Data ****************************************************************************/ @@ -79,8 +93,7 @@ * ****************************************************************************/ -int nxflat_init(const char *filename, struct nxflat_hdr_s *header, - struct nxflat_loadinfo_s *loadinfo) +int nxflat_init(const char *filename, struct nxflat_loadinfo_s *loadinfo) { uint32 datastart; uint32 dataend; @@ -88,7 +101,7 @@ int nxflat_init(const char *filename, struct nxflat_hdr_s *header, uint32 bssend; int ret; - bvdbg("filename: %s header: %p loadinfo: %p\n", filename, header, loadinfo); + bvdbg("filename: %s loadinfo: %p\n", filename, loadinfo); /* Clear the load info structure */ @@ -105,16 +118,19 @@ int nxflat_init(const char *filename, struct nxflat_hdr_s *header, /* Read the NXFLAT header from offset 0 */ - ret = nxflat_read(loadinfo, (char*)header, sizeof(struct nxflat_hdr_s), 0); + ret = nxflat_read(loadinfo, (char*)&loadinfo->header, + sizeof(struct nxflat_hdr_s), 0); if (ret < 0) { bdbg("Failed to read NXFLAT header: %d\n", ret); return ret; } - + nxflat_dumpbuffer("NXFLAT header", (FAR const ubyte*)&loadinfo->header, + sizeof(struct nxflat_hdr_s)); + /* Verify the NXFLAT header */ - if (nxflat_verifyheader(header) != 0) + if (nxflat_verifyheader(&loadinfo->header) != 0) { /* This is not an error because we will be called to attempt loading * EVERY binary. Returning -ENOEXEC simply informs the system that @@ -127,19 +143,16 @@ int nxflat_init(const char *filename, struct nxflat_hdr_s *header, return -ENOEXEC; } - /* Save all of the input values in the loadinfo structure */ - - loadinfo->header = header; - - /* And extract some additional information from the xflat + /* Save all of the input values in the loadinfo structure + * and extract some additional information from the xflat * header. Note that the information in the xflat header is in * network order. */ - datastart = ntohl(header->h_datastart); - dataend = ntohl(header->h_dataend); + datastart = ntohl(loadinfo->header.h_datastart); + dataend = ntohl(loadinfo->header.h_dataend); bssstart = dataend; - bssend = ntohl(header->h_bssend); + bssend = ntohl(loadinfo->header.h_bssend); /* And put this information into the loadinfo structure as well. * @@ -150,12 +163,12 @@ int nxflat_init(const char *filename, struct nxflat_hdr_s *header, * bsssize = the address range from dataend up to bssend. */ - loadinfo->entryoffs = ntohl(header->h_entry); + loadinfo->entryoffs = ntohl(loadinfo->header.h_entry); loadinfo->isize = datastart; loadinfo->datasize = dataend - datastart; loadinfo->bsssize = bssend - dataend; - loadinfo->stacksize = ntohl(header->h_stacksize); + loadinfo->stacksize = ntohl(loadinfo->header.h_stacksize); /* This is the initial dspace size. We'll re-calculate this later * after the memory has been allocated. @@ -167,8 +180,8 @@ int nxflat_init(const char *filename, struct nxflat_hdr_s *header, * this later). */ - loadinfo->relocstart = ntohl(header->h_relocstart); - loadinfo->reloccount = ntohs(header->h_reloccount); + loadinfo->relocstart = ntohl(loadinfo->header.h_relocstart); + loadinfo->reloccount = ntohs(loadinfo->header.h_reloccount); return 0; } diff --git a/nuttx/binfmt/nxflat.c b/nuttx/binfmt/nxflat.c index 8b3677df5e..f4eac0fcf3 100644 --- a/nuttx/binfmt/nxflat.c +++ b/nuttx/binfmt/nxflat.c @@ -55,17 +55,15 @@ * Pre-processor Definitions ****************************************************************************/ -#undef NXFLAT_DUMPBUFFER /* Define to enable very verbose buffer dumping */ - /* CONFIG_DEBUG, CONFIG_DEBUG_VERBOSE, and CONFIG_DEBUG_BINFMT have to be - * defined or NXFLAT_DUMPBUFFER does nothing. + * defined or CONFIG_NXFLAT_DUMPBUFFER does nothing. */ #if !defined(CONFIG_DEBUG_VERBOSE) || !defined (CONFIG_DEBUG_BINFMT) -# undef NXFLAT_DUMPBUFFER +# undef CONFIG_NXFLAT_DUMPBUFFER #endif -#ifdef NXFLAT_DUMPBUFFER +#ifdef CONFIG_NXFLAT_DUMPBUFFER # define nxflat_dumpbuffer(m,b,n) bvdbgdumpbuffer(m,b,n) #else # define nxflat_dumpbuffer(m,b,n) @@ -132,9 +130,6 @@ static void nxflat_dumploadinfo(struct nxflat_loadinfo_s *loadinfo) bdbg(" HANDLES:\n"); bdbg(" filfd: %d\n", loadinfo->filfd); - - bdbg(" NXFLT HEADER:\n"); - bdbg(" header: %p\n", loadinfo->header); } #else # define nxflat_dumploadinfo(i) @@ -151,7 +146,6 @@ static void nxflat_dumploadinfo(struct nxflat_loadinfo_s *loadinfo) static int nxflat_loadbinary(struct binary_s *binp) { - struct nxflat_hdr_s header; /* Just allocated memory */ struct nxflat_loadinfo_s loadinfo; /* Contains globals for libnxflat */ int ret; @@ -159,7 +153,7 @@ static int nxflat_loadbinary(struct binary_s *binp) /* Initialize the xflat library to load the program binary. */ - ret = nxflat_init(binp->filename, &header, &loadinfo); + ret = nxflat_init(binp->filename, &loadinfo); nxflat_dumploadinfo(&loadinfo); if (ret != 0) { @@ -196,7 +190,8 @@ static int nxflat_loadbinary(struct binary_s *binp) binp->isize = loadinfo.isize; binp->stacksize = loadinfo.stacksize; - nxflat_dumpbuffer("Entry code", (FAR const ubyte*)binp->entrypt, MIN(binp->isize,512)); + nxflat_dumpbuffer("Entry code", (FAR const ubyte*)binp->entrypt, + MIN(binp->isize - loadinfo.entryoffs,512)); nxflat_uninit(&loadinfo); return OK; } |