From bb5ede8152f14cc757ff4ee6f44ff3128c3ff144 Mon Sep 17 00:00:00 2001 From: patacongo Date: Wed, 6 Feb 2008 15:24:18 +0000 Subject: Standardize to big-endian binary git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@637 42af7a65-404d-4744-a932-0658087f49c3 --- misc/pascal/libpoff/pfread.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'misc/pascal/libpoff/pfread.c') 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(§ionHeader); + /* 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; -- cgit v1.2.3