summaryrefslogtreecommitdiff
path: root/misc/pascal/libpoff/pfread.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-02-06 15:24:18 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-02-06 15:24:18 +0000
commitbb5ede8152f14cc757ff4ee6f44ff3128c3ff144 (patch)
treedb2726eb2b79bde890812a8227dae075f8ca2a3b /misc/pascal/libpoff/pfread.c
parenta26dad80f4d004a4a0f6effedc803b3902389b39 (diff)
downloadnuttx-bb5ede8152f14cc757ff4ee6f44ff3128c3ff144.tar.gz
nuttx-bb5ede8152f14cc757ff4ee6f44ff3128c3ff144.tar.bz2
nuttx-bb5ede8152f14cc757ff4ee6f44ff3128c3ff144.zip
Standardize to big-endian binary
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@637 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'misc/pascal/libpoff/pfread.c')
-rw-r--r--misc/pascal/libpoff/pfread.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/misc/pascal/libpoff/pfread.c b/misc/pascal/libpoff/pfread.c
index 016aebceb..1bcc1618a 100644
--- a/misc/pascal/libpoff/pfread.c
+++ b/misc/pascal/libpoff/pfread.c
@@ -101,6 +101,10 @@ static uint16 poffReadFileHeader(poffHandle_t handle, FILE *poffFile)
return ePOFFREADERROR;
}
+ /* The POFF file is retained in big-endian order. Fixup fields as necessary */
+
+ poffSwapFileHeader(&poffInfo->fileHeader);
+
/* Verify that this is a valid POFF header */
if ((poffInfo->fileHeader.fh_ident[FHI_MAG0] != FHI_POFF_MAG0) ||
@@ -145,6 +149,10 @@ static uint16 poffReadSectionHeaders(poffHandle_t handle, FILE *poffFile)
return ePOFFREADERROR;
}
+ /* The POFF file is retained in big-endian order. Fixup fields as necessary */
+
+ poffSwapSectionHeader(&sectionHeader);
+
/* Copy the section header to the correct location */
switch (sectionHeader.sh_type)
@@ -251,6 +259,12 @@ static uint16 poffReadAllSectionData(poffHandle_t handle, FILE *poffFile)
retval = poffReadSectionData(&poffInfo->symbolTableSection,
(ubyte**)&poffInfo->symbolTable,
poffFile);
+#ifdef CONFIG_POFF_SWAPNEEDED
+ if (retval == eNOERROR)
+ {
+ poffSwapSymbolTableData(poffInfo);
+ }
+#endif
}
if ((retval == eNOERROR) && (HAVE_STRING_TABLE))
@@ -265,6 +279,12 @@ static uint16 poffReadAllSectionData(poffHandle_t handle, FILE *poffFile)
retval = poffReadSectionData(&poffInfo->relocSection,
(ubyte**)&poffInfo->relocTable,
poffFile);
+#ifdef CONFIG_POFF_SWAPNEEDED
+ if (retval == eNOERROR)
+ {
+ poffSwapRelocationData(poffInfo);
+ }
+#endif
}
if ((retval == eNOERROR) && (HAVE_FILE_TABLE))
@@ -272,6 +292,12 @@ static uint16 poffReadAllSectionData(poffHandle_t handle, FILE *poffFile)
retval = poffReadSectionData(&poffInfo->fileNameTableSection,
(ubyte**)&poffInfo->fileNameTable,
poffFile);
+#ifdef CONFIG_POFF_SWAPNEEDED
+ if (retval == eNOERROR)
+ {
+ poffSwapFileTableData(poffInfo);
+ }
+#endif
}
if ((retval == eNOERROR) && (HAVE_LINE_NUMBER))
@@ -279,6 +305,12 @@ static uint16 poffReadAllSectionData(poffHandle_t handle, FILE *poffFile)
retval = poffReadSectionData(&poffInfo->lineNumberSection,
(ubyte**)&poffInfo->lineNumberTable,
poffFile);
+#ifdef CONFIG_POFF_SWAPNEEDED
+ if (retval == eNOERROR)
+ {
+ poffSwapLineNumberData(poffInfo);
+ }
+#endif
}
if ((retval == eNOERROR) && (HAVE_DEBUG_SECTION))
@@ -286,6 +318,12 @@ static uint16 poffReadAllSectionData(poffHandle_t handle, FILE *poffFile)
retval = poffReadSectionData(&poffInfo->debugFuncSection,
(ubyte**)&poffInfo->debugFuncTable,
poffFile);
+#ifdef CONFIG_POFF_SWAPNEEDED
+ if (retval == eNOERROR)
+ {
+ poffSwapDebugData(poffInfo);
+ }
+#endif
}
return retval;