summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nuttx/binfmt/libnxflat/libnxflat_init.c10
-rw-r--r--nuttx/binfmt/libnxflat/libnxflat_load.c28
-rw-r--r--nuttx/binfmt/libnxflat/libnxflat_verify.c2
-rw-r--r--nuttx/include/nxflat.h29
4 files changed, 32 insertions, 37 deletions
diff --git a/nuttx/binfmt/libnxflat/libnxflat_init.c b/nuttx/binfmt/libnxflat/libnxflat_init.c
index f60eac1d7..c14ba1c22 100644
--- a/nuttx/binfmt/libnxflat/libnxflat_init.c
+++ b/nuttx/binfmt/libnxflat/libnxflat_init.c
@@ -73,11 +73,11 @@
int nxflat_init(const char *filename, struct nxflat_hdr_s *header,
struct nxflat_loadinfo_s *loadinfo)
{
- uint32 datastart;
- uint32 dataend;
- uint32 bssstart;
- uint32 bssend;
- int ret;
+ uint32 datastart;
+ uint32 dataend;
+ uint32 bssstart;
+ uint32 bssend;
+ int ret;
bvdbg("filename: %s header: %p loadinfo: %p\n", filename, header, loadinfo);
diff --git a/nuttx/binfmt/libnxflat/libnxflat_load.c b/nuttx/binfmt/libnxflat/libnxflat_load.c
index b27dca935..c3654f772 100644
--- a/nuttx/binfmt/libnxflat/libnxflat_load.c
+++ b/nuttx/binfmt/libnxflat/libnxflat_load.c
@@ -92,7 +92,7 @@ static const char *g_segment[] =
static void nxflat_reloc(struct nxflat_loadinfo_s *loadinfo, uint32 rl)
{
uint32 *ptr;
- uint32 datastart;
+ ubyte *datastart;
/* We only support relocations in the data sections. Verify that the
* relocation address lies in the data section of the file image.
@@ -100,14 +100,14 @@ static void nxflat_reloc(struct nxflat_loadinfo_s *loadinfo, uint32 rl)
if (NXFLAT_RELOC_OFFSET(rl) > loadinfo->datasize)
{
- bdbg("ERROR: Relocation at 0x%08x invalid -- "
- "does not lie in the data segment, size=0x%08x\n",
+ bdbg("ERROR: Relocation at %08x invalid -- "
+ "does not lie in the data segment, size: %08x\n",
NXFLAT_RELOC_OFFSET(rl), loadinfo->datasize);
bdbg(" Relocation not performed!\n");
}
else if ((NXFLAT_RELOC_OFFSET(rl) & 0x00000003) != 0)
{
- bdbg("ERROR: Relocation at 0x%08x invalid -- "
+ bdbg("ERROR: Relocation at %08x invalid -- "
"Improperly aligned\n",
NXFLAT_RELOC_OFFSET(rl));
}
@@ -118,7 +118,7 @@ static void nxflat_reloc(struct nxflat_loadinfo_s *loadinfo, uint32 rl)
* DSpace to hold information needed by ld.so at run time.
*/
- datastart = (uint32)loadinfo->dspace->region;
+ datastart = loadinfo->dspace->region;
/* Get a pointer to the value that needs relocation in
* DSpace.
@@ -126,8 +126,8 @@ static void nxflat_reloc(struct nxflat_loadinfo_s *loadinfo, uint32 rl)
ptr = (uint32*)(datastart + NXFLAT_RELOC_OFFSET(rl));
- bvdbg("Relocation of variable at DATASEG+0x%08x "
- "(address 0x%p, currently 0x%08x) into segment %s\n",
+ bvdbg("Relocation of variable at DATASEG+%08x "
+ "(address %p, currently %08x) into segment %s\n",
NXFLAT_RELOC_OFFSET(rl), ptr, *ptr, SEGNAME(rl));
switch (NXFLAT_RELOC_TYPE(rl))
@@ -153,7 +153,7 @@ static void nxflat_reloc(struct nxflat_loadinfo_s *loadinfo, uint32 rl)
case NXFLAT_RELOC_TYPE_DATA:
case NXFLAT_RELOC_TYPE_BSS:
- *ptr += datastart;
+ *ptr += (uint32)datastart;
break;
/* This case happens normally if the symbol is a weak
@@ -165,11 +165,11 @@ static void nxflat_reloc(struct nxflat_loadinfo_s *loadinfo, uint32 rl)
break;
default:
- bdbg("ERROR: Unknown relocation type=%d\n", NXFLAT_RELOC_TYPE(rl));
+ bdbg("ERROR: Unknown relocation type: %d\n", NXFLAT_RELOC_TYPE(rl));
break;
}
- bvdbg("Relocation became 0x%08x\n", *ptr);
+ bvdbg("Relocation became %08x\n", *ptr);
}
}
@@ -186,7 +186,7 @@ int nxflat_load(struct nxflat_loadinfo_s *loadinfo)
off_t doffset; /* Offset to .data in the NXFLAT file */
uint32 *reloctab; /* Address of the relocation table */
uint32 dreadsize; /* Total number of bytes of .data to be read */
- uint32 ret = OK;
+ int ret = OK;
int i;
/* Calculate the extra space we need to allocate. This extra space will be
@@ -251,7 +251,7 @@ int nxflat_load(struct nxflat_loadinfo_s *loadinfo)
return -errno;
}
- bvdbg("Mapped ISpace (%d bytes) at 0x%08x\n", loadinfo->isize, loadinfo->ispace);
+ bvdbg("Mapped ISpace (%d bytes) at %08x\n", loadinfo->isize, loadinfo->ispace);
/* The following call will give a pointer to the allocated but
* uninitialized ISpace memory.
@@ -279,7 +279,7 @@ int nxflat_load(struct nxflat_loadinfo_s *loadinfo)
goto errout;
}
- bvdbg("TEXT=0x%x Entry point offset=0x%08x, datastart is 0x%08x\n",
+ bvdbg("TEXT: %08x Entry point offset: %08x Data offset: %08x\n",
loadinfo->ispace, loadinfo->entryoffs, doffset);
/* Resolve the address of the relocation table. In the file, the
@@ -290,7 +290,7 @@ int nxflat_load(struct nxflat_loadinfo_s *loadinfo)
reloctab = (uint32*)(loadinfo->relocstart + (uint32)loadinfo->dspace->region - loadinfo->isize);
- bvdbg("Relocation table at 0x%p, reloccount=%d\n",
+ bvdbg("Relocation table at %p, reloccount: %d\n",
reloctab, loadinfo->reloccount);
/* Now run through the relocation entries. */
diff --git a/nuttx/binfmt/libnxflat/libnxflat_verify.c b/nuttx/binfmt/libnxflat/libnxflat_verify.c
index b1ca85330..c153a1128 100644
--- a/nuttx/binfmt/libnxflat/libnxflat_verify.c
+++ b/nuttx/binfmt/libnxflat/libnxflat_verify.c
@@ -79,7 +79,7 @@ int nxflat_verifyheader(const struct nxflat_hdr_s *header)
* silently. This is not our binary.
*/
- if (strncmp(header->h_magic, "NXFLAT", 4) != 0)
+ if (strncmp(header->h_magic, NXFLAT_MAGIC, 4) != 0)
{
bdbg("Unrecognized magic=\"%c%c%c%c\"",
header->h_magic[0], header->h_magic[1],
diff --git a/nuttx/include/nxflat.h b/nuttx/include/nxflat.h
index f643020ae..65b2aff75 100644
--- a/nuttx/include/nxflat.h
+++ b/nuttx/include/nxflat.h
@@ -47,18 +47,13 @@
* Pre-processor Definitions
****************************************************************************/
-#define NXFLAT_MAX_STRING_SIZE 64 /* Largest size of string (w/zterminator) */
+#define NXFLAT_MAX_STRING_SIZE 64 /* Largest size of string (w/zterminator) */
+#define NXFLAT_MAGIC "NxFT" /* NXFLAT magic number"
/****************************************************************************
* Public Types
****************************************************************************/
-#ifdef CONFIG_NXFLAT_SMALL
- typedef uint16 nxoff_t;
-#else
- typedef uint32 nxoff_t;
-#endif
-
/****************************************************************************
* The NXFLAT file header
*
@@ -69,8 +64,8 @@
struct nxflat_hdr_s
{
- /* The "magic number identifying the file type. This field should contain
- * "NxFT". NOTE that there is not other versioning information other than
+ /* The "magic number" identifying the file type. This field should contain
+ * "NxFT". NOTE that there is no other versioning information other than
* this magic number.
*/
@@ -100,10 +95,10 @@ struct nxflat_hdr_s
* The bss segment is data_end through bss_end.
*/
- nxoff_t h_entry;
- nxoff_t h_datastart;
- nxoff_t h_dataend;
- nxoff_t h_bssend;
+ uint32 h_entry;
+ uint32 h_datastart;
+ uint32 h_dataend;
+ uint32 h_bssend;
/* Size of stack, in bytes */
@@ -116,8 +111,8 @@ struct nxflat_hdr_s
* h_reloccount - The number of relocation records in the arry
*/
- nxoff_t h_relocstart; /* Offset of relocation records */
- nxoff_t h_reloccount; /* Number of relocation records */
+ uint32 h_relocstart; /* Offset of relocation records */
+ uint32 h_reloccount; /* Number of relocation records */
/* Imported symbol table (NOTE no symbols are exported)
*
@@ -131,8 +126,8 @@ struct nxflat_hdr_s
* h_importcount - The number of records in the h_exportsymbols array.
*/
- nxoff_t h_importsymbols; /* Offset to list of imported symbols */
- uint16 h_importcount; /* Number of imported symbols */
+ uint32 h_importsymbols; /* Offset to list of imported symbols */
+ uint16 h_importcount; /* Number of imported symbols */
};
/****************************************************************************