Mostly cosmetic integration changes

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1953 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2009-06-25 21:59:30 +00:00
parent 2dd2b05af7
commit adad9dea8d
5 changed files with 52 additions and 39 deletions

View file

@ -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));

View file

@ -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;
}

View file

@ -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;
}

View file

@ -276,10 +276,15 @@ CONFIG_SDCLONE_DISABLE=y
# CONFIG_NXFLAT. Enable support for the NXFLAT binary format.
# This format will support execution of NuttX binaries located
# in a ROMFS filesystem (see examples/nxflat).
# CONFIG_NXFLAT_DUMPBUFFER. Dump a most buffers that NXFFLAT deals
# with. CONFIG_DEBUG, CONFIG_DEBUG_VERBOSE, and
# CONFIG_DEBUG_BINFMT have to be defined or
# CONFIG_NXFLAT_DUMPBUFFER does nothing.
# CONFIG_SYMTAB_ORDEREDBYNAME. Select if the system symbol table
# is ordered by symbol name
#
CONFIG_NXFLAT=y
CONFIG_NXFLAT_DUMPBUFFER=n
CONFIG_SYMTAB_ORDEREDBYNAME=y
#

View file

@ -87,7 +87,9 @@ struct nxflat_loadinfo_s
int filfd; /* Descriptor for the file being loaded */
const struct nxflat_hdr_s *header; /* A reference to the flat file header */
/* This is a copy of the NXFLAT header (still in network order) */
struct nxflat_hdr_s header;
};
/****************************************************************************
@ -134,7 +136,7 @@ EXTERN int nxflat_verifyheader(const struct nxflat_hdr_s *header);
*
***********************************************************************/
EXTERN int nxflat_init(const char *filename, struct nxflat_hdr_s *header,
EXTERN int nxflat_init(const char *filename,
struct nxflat_loadinfo_s *loadinfo);
/***********************************************************************