summaryrefslogtreecommitdiff
path: root/nuttx
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-06-17 22:13:21 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-06-17 22:13:21 +0000
commitf44c80d64924b5796a547d2d4e787591da58726d (patch)
tree0b9933e8f51cc69a2450847c18a03ee4ce5d63eb /nuttx
parent5a0722f9d657233ed85bdcf75a9a14ea321a1a28 (diff)
downloadpx4-nuttx-f44c80d64924b5796a547d2d4e787591da58726d.tar.gz
px4-nuttx-f44c80d64924b5796a547d2d4e787591da58726d.tar.bz2
px4-nuttx-f44c80d64924b5796a547d2d4e787591da58726d.zip
Remove bitfields from NXFLAT definition
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1897 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx')
-rw-r--r--nuttx/binfmt/libnxflat/libnxflat_load.c32
-rw-r--r--nuttx/include/nxflat.h59
2 files changed, 48 insertions, 43 deletions
diff --git a/nuttx/binfmt/libnxflat/libnxflat_load.c b/nuttx/binfmt/libnxflat/libnxflat_load.c
index 8f9da18cb..77ced1b64 100644
--- a/nuttx/binfmt/libnxflat/libnxflat_load.c
+++ b/nuttx/binfmt/libnxflat/libnxflat_load.c
@@ -87,37 +87,25 @@ static const char *g_segment[] =
static void nxflat_reloc(struct nxflat_loadinfo_s *loadinfo, uint32 rl)
{
- union
- {
- uint32 l;
- struct nxflat_reloc_s s;
- } reloc;
uint32 *ptr;
uint32 datastart;
- /* Force the long value into a union so that we can strip off some
- * bit-encoded values.
- */
-
- reloc.l = rl;
-
- /* We only support relocations in the data sections.
- * Verify that the the relocation address lies in the data
- * section of the file image.
+ /* We only support relocations in the data sections. Verify that the
+ * relocation address lies in the data section of the file image.
*/
- if (reloc.s.r_offset > loadinfo->datasize)
+ 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",
- reloc.s.r_offset, loadinfo->datasize);
+ NXFLAT_RELOC_OFFSET(rl), loadinfo->datasize);
bdbg(" Relocation not performed!\n");
}
- else if ((reloc.s.r_offset & 0x00000003) != 0)
+ else if ((NXFLAT_RELOC_OFFSET(rl) & 0x00000003) != 0)
{
bdbg("ERROR: Relocation at 0x%08x invalid -- "
"Improperly aligned\n",
- reloc.s.r_offset);
+ NXFLAT_RELOC_OFFSET(rl));
}
else
{
@@ -132,13 +120,13 @@ static void nxflat_reloc(struct nxflat_loadinfo_s *loadinfo, uint32 rl)
* DSpace.
*/
- ptr = (uint32*)(datastart + reloc.s.r_offset);
+ 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",
- reloc.s.r_offset, ptr, *ptr, g_segment[reloc.s.r_type]);
+ NXFLAT_RELOC_OFFSET(rl), ptr, *ptr, g_segment[NXFLAT_RELOC_TYPE(rl)]);
- switch (reloc.s.r_type)
+ switch (NXFLAT_RELOC_TYPE(rl))
{
/* TEXT is located at an offset of sizeof(struct nxflat_hdr_s) from
* the allocated/mapped ISpace region.
@@ -173,7 +161,7 @@ static void nxflat_reloc(struct nxflat_loadinfo_s *loadinfo, uint32 rl)
break;
default:
- bdbg("ERROR: Unknown relocation type=%d\n", reloc.s.r_type);
+ bdbg("ERROR: Unknown relocation type=%d\n", NXFLAT_RELOC_TYPE(rl));
break;
}
diff --git a/nuttx/include/nxflat.h b/nuttx/include/nxflat.h
index b670b7976..f643020ae 100644
--- a/nuttx/include/nxflat.h
+++ b/nuttx/include/nxflat.h
@@ -44,12 +44,22 @@
#include <sys/types.h>
/****************************************************************************
- * Maximum Sizes
+ * Pre-processor Definitions
****************************************************************************/
#define NXFLAT_MAX_STRING_SIZE 64 /* Largest size of string (w/zterminator) */
/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+#ifdef CONFIG_NXFLAT_SMALL
+ typedef uint16 nxoff_t;
+#else
+ typedef uint32 nxoff_t;
+#endif
+
+/****************************************************************************
* The NXFLAT file header
*
* The elements within this structure are stored in network order (i.e.,
@@ -90,10 +100,10 @@ struct nxflat_hdr_s
* The bss segment is data_end through bss_end.
*/
- uint32 h_entry;
- uint32 h_datastart;
- uint32 h_dataend;
- uint32 h_bssend;
+ nxoff_t h_entry;
+ nxoff_t h_datastart;
+ nxoff_t h_dataend;
+ nxoff_t h_bssend;
/* Size of stack, in bytes */
@@ -106,8 +116,8 @@ struct nxflat_hdr_s
* h_reloccount - The number of relocation records in the arry
*/
- uint32 h_relocstart; /* Offset of relocation records */
- uint32 h_reloccount; /* Number of relocation records */
+ nxoff_t h_relocstart; /* Offset of relocation records */
+ nxoff_t h_reloccount; /* Number of relocation records */
/* Imported symbol table (NOTE no symbols are exported)
*
@@ -121,34 +131,41 @@ struct nxflat_hdr_s
* h_importcount - The number of records in the h_exportsymbols array.
*/
- uint32 h_importsymbols; /* Offset to list of imported symbols */
+ nxoff_t h_importsymbols; /* Offset to list of imported symbols */
uint16 h_importcount; /* Number of imported symbols */
};
/****************************************************************************
* NXFLAT Relocation types.
*
- * The relocation records are an array of the following type. The fields
- * in each element are stored in native machine order.
+ * The relocation records are an array of the following type.
****************************************************************************/
+struct nxflat_reloc_s
+{
+ uint32 r_info; /* Bit-encoded relocation info */
+};
+
+/* The top three bits of the relocation info is the relocation type (see the
+ * NXFLAT_RELOC_TYPE_* definitions below. This is an unsigned value.
+ */
+
+#define NXFLAT_RELOC_TYPE(r) ((uint32)(r) >> 28)
+
+/* The bottom 28 bits of the relocation info is the (non-negative) offset into
+ * the D-Space that needs the fixup.
+ */
+
+#define NXFLAT_RELOC_OFFSET(r) ((uint32)(r) & 0x1fffffff)
+
+/* These are possible values for the relocation type */
+
#define NXFLAT_RELOC_TYPE_NONE 0 /* Invalid relocation type */
#define NXFLAT_RELOC_TYPE_TEXT 1 /* Symbol lies in .text region */
#define NXFLAT_RELOC_TYPE_DATA 2 /* Symbol lies in .data region */
#define NXFLAT_RELOC_TYPE_BSS 3 /* Symbol lies in .bss region */
#define NXFLAT_RELOC_TYPE_NUM 4
-struct nxflat_reloc_s
-{
-#ifdef CONFIG_ENDIAN_BIG
- uint32 r_type : 2;
- sint32 r_offset : 30;
-#else
- sint32 r_offset : 30;
- uint32 r_type : 2;
-#endif
-};
-
/****************************************************************************
* NXFLAT Imported symbol type
*