summaryrefslogtreecommitdiff
path: root/nuttx/binfmt
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-06-25 17:44:35 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-06-25 17:44:35 +0000
commit018ff6e65dcc563321d27d010e693dd8413e2f45 (patch)
treecd6fc22d2130b328328f2aeef39b8758673ec132 /nuttx/binfmt
parent50d5e799e29f7d1da649d43fee8382cdffe3fc89 (diff)
downloadnuttx-018ff6e65dcc563321d27d010e693dd8413e2f45.tar.gz
nuttx-018ff6e65dcc563321d27d010e693dd8413e2f45.tar.bz2
nuttx-018ff6e65dcc563321d27d010e693dd8413e2f45.zip
Consolidate buffer dumping; fix all occurrences of 'the the'
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1951 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/binfmt')
-rw-r--r--nuttx/binfmt/libnxflat/libnxflat_bind.c47
-rw-r--r--nuttx/binfmt/libnxflat/libnxflat_verify.c2
-rw-r--r--nuttx/binfmt/nxflat.c45
3 files changed, 63 insertions, 31 deletions
diff --git a/nuttx/binfmt/libnxflat/libnxflat_bind.c b/nuttx/binfmt/libnxflat/libnxflat_bind.c
index 4489ebfcd..84ef3a9a3 100644
--- a/nuttx/binfmt/libnxflat/libnxflat_bind.c
+++ b/nuttx/binfmt/libnxflat/libnxflat_bind.c
@@ -51,9 +51,25 @@
#include <nuttx/symtab.h>
/****************************************************************************
- * Definitions
+ * 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.
+ */
+
+#if !defined(CONFIG_DEBUG_VERBOSE) || !defined (CONFIG_DEBUG_BINFMT)
+# undef NXFLAT_DUMPBUFFER
+#endif
+
+#ifdef NXFLAT_DUMPBUFFER
+# define nxflat_dumpbuffer(m,b,n) bvdbgdumpbuffer(m,b,n)
+#else
+# define nxflat_dumpbuffer(m,b,n)
+#endif
+
/****************************************************************************
* Private Types
****************************************************************************/
@@ -72,7 +88,7 @@
* Description:
* Perform the NXFLAT_RELOC_TYPE_REL32I binding:
*
- * Meaning: Object file contains a 32-bit offset into I-Space at the the offset.
+ * Meaning: Object file contains a 32-bit offset into I-Space at the offset.
* Fixup: Add mapped I-Space address to the offset.
*
* Returned Value:
@@ -111,7 +127,7 @@ static inline int nxflat_bindrel32i(FAR struct nxflat_loadinfo_s *loadinfo,
* Description:
* Perform the NXFLAT_RELOC_TYPE_REL32D binding:
*
- * Meaning: Object file contains a 32-bit offset into D-Space at the the offset.
+ * Meaning: Object file contains a 32-bit offset into D-Space at the offset.
* Fixup: Add allocated D-Space address to the offset.
*
* Returned Value:
@@ -246,7 +262,7 @@ static inline int nxflat_gotrelocs(FAR struct nxflat_loadinfo_s *loadinfo)
{
/* NXFLAT_RELOC_TYPE_REL32I Meaning: Object file contains a 32-bit offset
- * into I-Space at the the offset.
+ * into I-Space at the offset.
* Fixup: Add mapped I-Space address to the offset.
*/
@@ -257,7 +273,7 @@ static inline int nxflat_gotrelocs(FAR struct nxflat_loadinfo_s *loadinfo)
break;
/* NXFLAT_RELOC_TYPE_REL32D Meaning: Object file contains a 32-bit offset
- * into D-Space at the the offset.
+ * into D-Space at the offset.
* Fixup: Add allocated D-Space address to the
* offset.
*/
@@ -301,6 +317,15 @@ static inline int nxflat_gotrelocs(FAR struct nxflat_loadinfo_s *loadinfo)
}
}
+ /* Dump the relocation got */
+
+#ifdef NXFLAT_DUMPBUFFER
+ if (ret == OK && nrelocs > 0)
+ {
+ relocs = (FAR struct nxflat_reloc_s*)(offset - loadinfo->isize + loadinfo->dspace->region);
+ nxflat_dumpbuffer("GOT", (FAR const ubyte*)relocs, nrelocs * sizeof(struct nxflat_reloc_s));
+ }
+#endif
return ret;
}
@@ -396,11 +421,19 @@ static inline int nxflat_bindimports(FAR struct nxflat_loadinfo_s *loadinfo,
imports[i].i_funcaddress = (uint32)symbol->sym_value;
- bvdbg("Bound imported function '%s' to address %08x\n",
- symname, imports[i].i_funcaddress);
+ 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
+ if (nimports > 0)
+ {
+ nxflat_dumpbuffer("Imports", (FAR const ubyte*)imports, nimports * sizeof(struct nxflat_import_s));
+ }
+#endif
return OK;
}
diff --git a/nuttx/binfmt/libnxflat/libnxflat_verify.c b/nuttx/binfmt/libnxflat/libnxflat_verify.c
index 96947dbc8..bf5221278 100644
--- a/nuttx/binfmt/libnxflat/libnxflat_verify.c
+++ b/nuttx/binfmt/libnxflat/libnxflat_verify.c
@@ -84,7 +84,7 @@ int nxflat_verifyheader(const struct nxflat_hdr_s *header)
/* Check the FLT header -- magic number and revision.
*
- * If the the magic number does not match. Just return
+ * If the magic number does not match. Just return
* silently. This is not our binary.
*/
diff --git a/nuttx/binfmt/nxflat.c b/nuttx/binfmt/nxflat.c
index 6e9d54c84..8b3677df5 100644
--- a/nuttx/binfmt/nxflat.c
+++ b/nuttx/binfmt/nxflat.c
@@ -55,13 +55,32 @@
* 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.
+ */
+
+#if !defined(CONFIG_DEBUG_VERBOSE) || !defined (CONFIG_DEBUG_BINFMT)
+# undef NXFLAT_DUMPBUFFER
+#endif
+
+#ifdef NXFLAT_DUMPBUFFER
+# define nxflat_dumpbuffer(m,b,n) bvdbgdumpbuffer(m,b,n)
+#else
+# define nxflat_dumpbuffer(m,b,n)
+#endif
+
+#ifndef MIN
+# define MIN(a,b) (a < b ? a : b)
+#endif
+
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
static int nxflat_loadbinary(struct binary_s *binp);
#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_BINFMT)
-static void nxflat_dumpmemory(void *addr, int nbytes);
static void nxflat_dumploadinfo(struct nxflat_loadinfo_s *loadinfo);
#endif
@@ -80,25 +99,6 @@ static struct binfmt_s g_nxflatbinfmt =
****************************************************************************/
/****************************************************************************
- * Name: nnxflat_dumpmemory
- ****************************************************************************/
-
-#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_BINFMT)
-static void nxflat_dumpmemory(void *addr, int nbytes)
-{
- ubyte *ptr;
-
- bdbg(" ADDRESS VALUE\n");
- for (ptr = (ubyte*)addr; nbytes > 0; ptr += 4, nbytes -= 4)
- {
- bdbg(" %p: %02x %02x %02x %02x\n", ptr, ptr[0], ptr[1], ptr[2], ptr[3]);
- }
-}
-#else
-# define nxflat_dumpmemory(a,n)
-#endif
-
-/****************************************************************************
* Name: nxflat_dumploadinfo
****************************************************************************/
@@ -115,7 +115,7 @@ static void nxflat_dumploadinfo(struct nxflat_loadinfo_s *loadinfo)
bdbg(" DSPACE:\n");
bdbg(" dspace: %08lx\n", loadinfo->dspace);
- if (oadinfo->dspace != NULL)
+ if (loadinfo->dspace != NULL)
{
bdbg(" crefs: %d\n", loadinfo->dspace->crefs);
bdbg(" region: %08lx\n", loadinfo->dspace->region);
@@ -196,8 +196,7 @@ static int nxflat_loadbinary(struct binary_s *binp)
binp->isize = loadinfo.isize;
binp->stacksize = loadinfo.stacksize;
- bvdbg("ENTRY CODE:\n");
- nxflat_dumpmemory(binp->entrypt, 16*sizeof(uint32));
+ nxflat_dumpbuffer("Entry code", (FAR const ubyte*)binp->entrypt, MIN(binp->isize,512));
nxflat_uninit(&loadinfo);
return OK;
}