diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2008-02-06 15:24:18 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2008-02-06 15:24:18 +0000 |
commit | bb5ede8152f14cc757ff4ee6f44ff3128c3ff144 (patch) | |
tree | db2726eb2b79bde890812a8227dae075f8ca2a3b /misc/pascal/libpoff | |
parent | a26dad80f4d004a4a0f6effedc803b3902389b39 (diff) | |
download | nuttx-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')
-rw-r--r-- | misc/pascal/libpoff/Make.defs | 2 | ||||
-rw-r--r-- | misc/pascal/libpoff/Makefile | 2 | ||||
-rw-r--r-- | misc/pascal/libpoff/pfprivate.h | 16 | ||||
-rw-r--r-- | misc/pascal/libpoff/pfread.c | 38 | ||||
-rw-r--r-- | misc/pascal/libpoff/pfswap.c | 250 | ||||
-rw-r--r-- | misc/pascal/libpoff/pfwrite.c | 115 |
6 files changed, 395 insertions, 28 deletions
diff --git a/misc/pascal/libpoff/Make.defs b/misc/pascal/libpoff/Make.defs index 8ffcd4d62..67852b705 100644 --- a/misc/pascal/libpoff/Make.defs +++ b/misc/pascal/libpoff/Make.defs @@ -45,4 +45,4 @@ POFF_CSRCS = pfhandle.c pfproghandle.c pftprog.c \ pfrelease.c pfdbgcontainer.c pfdbgdiscard.c \ pfxprog.c pfxrodata.c pfiprog.c pfirodata.c \ pfdhdr.c pfdsymbol.c pfdreloc.c pflabel.c \ - pflineno.c pfdbginfo.c + pflineno.c pfdbginfo.c pfswap.c diff --git a/misc/pascal/libpoff/Makefile b/misc/pascal/libpoff/Makefile index ece3ccb16..ebbf1e2ac 100644 --- a/misc/pascal/libpoff/Makefile +++ b/misc/pascal/libpoff/Makefile @@ -26,7 +26,7 @@ LIBPOFFSRCS = pfhandle.c pfproghandle.c pftprog.c \ pfrelease.c pfdbgcontainer.c pfdbgdiscard.c \ pfxprog.c pfxrodata.c pfiprog.c pfirodata.c \ pfdhdr.c pfdsymbol.c pfdreloc.c pflabel.c \ - pflineno.c pfdbginfo.c + pflineno.c pfdbginfo.c pfswap.c LIBPOFFOBJS = $(LIBPOFFSRCS:.c=.o) all: libpoff.a diff --git a/misc/pascal/libpoff/pfprivate.h b/misc/pascal/libpoff/pfprivate.h index 3bcdf89dc..ed5e239e6 100644 --- a/misc/pascal/libpoff/pfprivate.h +++ b/misc/pascal/libpoff/pfprivate.h @@ -48,6 +48,7 @@ #include "keywords.h" #include "poff.h" +#include "paslib.h" /* Endian-ness support */ /*************************************************************************** * Definitions @@ -86,6 +87,11 @@ #define HAVE_LINE_NUMBER (poffInfo->lineNumberSection.sh_size > 0) #define HAVE_DEBUG_SECTION (poffInfo->debugFuncSection.sh_size > 0) +#ifndef CONFIG_POFF_SWAPNEEDED +# define poffSwapFileHeader(p) +# define poffSwapSectionHeader(p) +#endif + /*************************************************************************** * Public Types ***************************************************************************/ @@ -169,4 +175,14 @@ typedef struct poffSymInfo_s poffSymInfo_t; * Public Function Prototypes ***************************************************************************/ +#ifdef CONFIG_POFF_SWAPNEEDED +extern void poffSwapFileHeader(poffFileHeader_t *pFileHeader); +extern void poffSwapSectionHeader(poffSectionHeader_t *pSectionHeader); +extern void poffSwapSymbolTableData(poffInfo_t *poffInfo); +extern void poffSwapRelocationData(poffInfo_t *poffInfo); +extern void poffSwapFileTableData(poffInfo_t *poffInfo); +extern void poffSwapLineNumberData(poffInfo_t *poffInfo); +extern void poffSwapDebugData(poffInfo_t *poffInfo); +#endif + #endif /* __PFPRIVATE_H */ 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;
diff --git a/misc/pascal/libpoff/pfswap.c b/misc/pascal/libpoff/pfswap.c new file mode 100644 index 000000000..bb99190bc --- /dev/null +++ b/misc/pascal/libpoff/pfswap.c @@ -0,0 +1,250 @@ +/**********************************************************************
+ * libpoff/pfswap.c
+ * Handle POFF Endian-ness
+ *
+ * Copyright (C) 2008 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ **********************************************************************/
+
+/**********************************************************************
+ * Included Files
+ **********************************************************************/
+
+#include "keywords.h" /* Standard types */
+#include "paslib.h" /* Common library */
+#include "pfprivate.h" /* POFF private definitions */
+
+/**********************************************************************
+ * Definitions
+ **********************************************************************/
+
+/**********************************************************************
+ * Global Variables
+ **********************************************************************/
+
+/**********************************************************************
+ * Private Variables
+ **********************************************************************/
+
+/***********************************************************************
+ * Private Function Prototypes
+ ***********************************************************************/
+
+/***********************************************************************
+ * Private Functions
+ ***********************************************************************/
+
+#ifdef CONFIG_POFF_SWAPNEEDED
+static inline void poffSwapRelocationEntry(poffRelocation_t *prel)
+{
+ prel->rl_info = poff32(prel->rl_info);
+ prel->rl_offset = poff32(prel->rl_offset);
+}
+#endif
+
+/***********************************************************************/
+
+#ifdef CONFIG_POFF_SWAPNEEDED
+static inline void poffSwapSymbolTableEntry(poffSymbol_t *psym)
+{
+ psym->st_name = poff32(psym->st_name);
+ psym->st_value = poff32(psym->st_value);
+ psym->st_size = poff32(psym->st_size);
+}
+#endif
+
+/***********************************************************************/
+
+#ifdef CONFIG_POFF_SWAPNEEDED
+static inline void poffSwapFileTabEntry(poffFileTab_t *pfile)
+{
+ *pfile = poff32((uint32)*pfile);
+}
+#endif
+
+/***********************************************************************/
+
+#ifdef CONFIG_POFF_SWAPNEEDED
+static inline void poffSwaplineno(poffLineNumber_t *plineno)
+{
+ plineno->ln_lineno = poff16(plineno->ln_lineno);
+ plineno->ln_fileno = poff16(plineno->ln_fileno);
+ plineno->ln_poffset = poff32(plineno->ln_poffset);
+}
+#endif
+
+/***********************************************************************/
+
+#ifdef CONFIG_POFF_SWAPNEEDED
+static inline void poffDebugFuncEntry(poffDebugFuncInfo_t *pdbg)
+{
+ pdbg->df_value = poff32(pdbg->df_value);
+ pdbg->df_size = poff32(pdbg->df_size);
+ pdbg->df_nparms = poff32(pdbg->df_nparms);
+}
+#endif
+
+/***********************************************************************/
+
+#ifdef CONFIG_POFF_SWAPNEEDED
+static inline void poffDebugArgEntry(poffDebugArgInfo_t *parg)
+{
+ parg->da_size = poff32(parg->da_size);
+}
+#endif
+
+/***********************************************************************
+ * Public Functions
+ ***********************************************************************/
+
+#ifdef CONFIG_POFF_SWAPNEEDED
+void poffSwapFileHeader(poffFileHeader_t *pFileHeader)
+{
+ pFileHeader->fh_shsize = poff16(pFileHeader->fh_shsize);
+ pFileHeader->fh_shnum = poff16(pFileHeader->fh_shnum);
+ pFileHeader->fh_name = poff32(pFileHeader->fh_name);
+ pFileHeader->fh_entry = poff32(pFileHeader->fh_entry);
+ pFileHeader->fh_shoff = poff32(pFileHeader->fh_shoff);
+}
+#endif
+
+/***********************************************************************/
+
+#ifdef CONFIG_POFF_SWAPNEEDED
+void poffSwapSectionHeader(poffSectionHeader_t *pSectionHeader)
+{
+ pSectionHeader->sh_entsize = poff16(pSectionHeader->sh_entsize);
+ pSectionHeader->sh_name = poff32(pSectionHeader->sh_name);
+ pSectionHeader->sh_addr = poff32(pSectionHeader->sh_addr);
+ pSectionHeader->sh_offset = poff32(pSectionHeader->sh_offset);
+ pSectionHeader->sh_size = poff32(pSectionHeader->sh_size);
+}
+#endif
+
+/***********************************************************************/
+
+#ifdef CONFIG_POFF_SWAPNEEDED
+void poffSwapSymbolTableData(poffInfo_t *poffInfo)
+{
+ poffSymbol_t *psym;
+ uint32 index;
+
+ for (index = 0;
+ index < poffInfo->symbolTableSection.sh_size;
+ index += poffInfo->symbolTableSection.sh_entsize)
+ {
+ psym = (poffSymbol_t*)&poffInfo->symbolTable[index];
+ poffSwapSymbolTableEntry(psym);
+ }
+}
+#endif
+
+/***********************************************************************/
+
+#ifdef CONFIG_POFF_SWAPNEEDED
+void poffSwapRelocationData(poffInfo_t *poffInfo)
+{
+ poffRelocation_t *prel;
+ uint32 index;
+
+ for (index = 0;
+ index < poffInfo->relocSection.sh_size;
+ index += poffInfo->relocSection.sh_entsize)
+ {
+ prel = (poffRelocation_t*)&poffInfo->relocTable[index];
+ poffSwapRelocationEntry(prel);
+ }
+}
+#endif
+
+/***********************************************************************/
+
+#ifdef CONFIG_POFF_SWAPNEEDED
+void poffSwapFileTableData(poffInfo_t *poffInfo)
+{
+ poffFileTab_t *pfile;
+ uint32 index;
+
+ for (index = 0;
+ index < poffInfo->relocSection.sh_size;
+ index += poffInfo->relocSection.sh_entsize)
+ {
+ pfile = (poffFileTab_t*)&poffInfo->relocTable[index];
+ poffSwapFileTabEntry(pfile);
+ }
+}
+#endif
+
+/***********************************************************************/
+
+#ifdef CONFIG_POFF_SWAPNEEDED
+void poffSwapLineNumberData(poffInfo_t *poffInfo)
+{
+ poffLineNumber_t *plineno;
+ uint32 index;
+
+ for (index = 0;
+ index < poffInfo->relocSection.sh_size;
+ index += poffInfo->relocSection.sh_entsize)
+ {
+ plineno = (poffLineNumber_t*)&poffInfo->relocTable[index];
+ poffSwaplineno(plineno);
+ }
+}
+#endif
+
+/***********************************************************************/
+
+#ifdef CONFIG_POFF_SWAPNEEDED
+void poffSwapDebugData(poffInfo_t *poffInfo)
+{
+ poffDebugFuncInfo_t *pdbg;
+ poffDebugArgInfo_t *parg;
+ uint32 i;
+ int j;
+
+ for (i = 0; i + sizeof(poffDebugFuncInfo_t) < poffInfo->relocSection.sh_size;)
+ {
+ pdbg = (poffDebugFuncInfo_t*)&poffInfo->debugFuncTable[i];
+ poffDebugFuncEntry(pdbg);
+
+ i += sizeof(poffDebugFuncInfo_t);
+ for (j = 0; j < pdbg->df_nparms; j++)
+ {
+ parg = (poffDebugArgInfo_t*)&poffInfo->debugFuncTable[i];
+ poffDebugArgEntry(parg);
+ i += sizeof(poffDebugArgInfo_t);
+ }
+ }
+}
+#endif
+
+/***********************************************************************/
diff --git a/misc/pascal/libpoff/pfwrite.c b/misc/pascal/libpoff/pfwrite.c index 75eac9497..c655dba71 100644 --- a/misc/pascal/libpoff/pfwrite.c +++ b/misc/pascal/libpoff/pfwrite.c @@ -1,5 +1,5 @@ /**********************************************************************
- * pfwrite.c
+ * libpoff/pfwrite.c
* Write a POFF file
*
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
@@ -116,6 +116,10 @@ static void poffWriteFileHeader(poffHandle_t handle, FILE *poffFile) poffInfo->fileHeader.fh_shnum = poffCountSections(handle);
+ /* The POFF file is retained in big-endian order. Fixup fields as necessary */
+
+ poffSwapFileHeader(&poffInfo->fileHeader);
+
/* Write the POFF file header */
entriesWritten = fwrite(&poffInfo->fileHeader, sizeof(poffFileHeader_t),
@@ -125,6 +129,30 @@ static void poffWriteFileHeader(poffHandle_t handle, FILE *poffFile) errmsg("Failed to write POFF header: %s\n", strerror(errno));
fatal(ePOFFWRITEERROR);
}
+
+ /* Restore fields to host order */
+
+ poffSwapFileHeader(&poffInfo->fileHeader);
+}
+
+/***********************************************************************/
+
+static size_t poffWriteSectionHeader(poffSectionHeader_t *pheader, FILE *poffFile)
+{
+ size_t entriesWritten;
+
+ /* The POFF file is retained in big-endian order. Fixup fields as necessary */
+
+ poffSwapSectionHeader(pheader);
+
+ /* Write the POFF section header */
+
+ entriesWritten = fwrite(pheader, sizeof(poffSectionHeader_t), 1, poffFile);
+
+ /* Restore fields to host order */
+
+ poffSwapSectionHeader(pheader);
+ return entriesWritten;
}
/***********************************************************************/
@@ -153,9 +181,7 @@ static void poffWriteSectionHeaders(poffHandle_t handle, FILE *poffFile) /* Then write the section header to the output file */
- entriesWritten = fwrite(&poffInfo->progSection,
- sizeof(poffSectionHeader_t),
- 1, poffFile);
+ entriesWritten = poffWriteSectionHeader(&poffInfo->progSection, poffFile);
if (entriesWritten != 1)
{
errmsg("Failed to write program section header: %s\n",
@@ -176,9 +202,7 @@ static void poffWriteSectionHeaders(poffHandle_t handle, FILE *poffFile) /* Then write the section header to the output file */
- entriesWritten = fwrite(&poffInfo->roDataSection,
- sizeof(poffSectionHeader_t),
- 1, poffFile);
+ entriesWritten = poffWriteSectionHeader(&poffInfo->roDataSection, poffFile);
if (entriesWritten != 1)
{
errmsg("Failed to write data section header: %s\n",
@@ -199,9 +223,7 @@ static void poffWriteSectionHeaders(poffHandle_t handle, FILE *poffFile) /* Then write the section header to the output file */
- entriesWritten = fwrite(&poffInfo->symbolTableSection,
- sizeof(poffSectionHeader_t),
- 1, poffFile);
+ entriesWritten = poffWriteSectionHeader(&poffInfo->symbolTableSection, poffFile);
if (entriesWritten != 1)
{
errmsg("Failed to write symbol table section header: %s\n",
@@ -222,9 +244,7 @@ static void poffWriteSectionHeaders(poffHandle_t handle, FILE *poffFile) /* Then write the section header to the output file */
- entriesWritten = fwrite(&poffInfo->relocSection,
- sizeof(poffSectionHeader_t),
- 1, poffFile);
+ entriesWritten = poffWriteSectionHeader(&poffInfo->relocSection, poffFile);
if (entriesWritten != 1)
{
errmsg("Failed to write relocation section header: %s\n",
@@ -245,9 +265,7 @@ static void poffWriteSectionHeaders(poffHandle_t handle, FILE *poffFile) /* Then write the section header to the output file */
- entriesWritten = fwrite(&poffInfo->fileNameTableSection,
- sizeof(poffSectionHeader_t),
- 1, poffFile);
+ entriesWritten = poffWriteSectionHeader(&poffInfo->fileNameTableSection, poffFile);
if (entriesWritten != 1)
{
errmsg("Failed to write file table section header: %s\n",
@@ -268,9 +286,7 @@ static void poffWriteSectionHeaders(poffHandle_t handle, FILE *poffFile) /* Then write the section header to the output file */
- entriesWritten = fwrite(&poffInfo->lineNumberSection,
- sizeof(poffSectionHeader_t),
- 1, poffFile);
+ entriesWritten = poffWriteSectionHeader(&poffInfo->lineNumberSection, poffFile);
if (entriesWritten != 1)
{
errmsg("Failed to write line number section header: %s\n",
@@ -291,9 +307,7 @@ static void poffWriteSectionHeaders(poffHandle_t handle, FILE *poffFile) /* Then write the section header to the output file */
- entriesWritten = fwrite(&poffInfo->debugFuncSection,
- sizeof(poffSectionHeader_t),
- 1, poffFile);
+ entriesWritten = poffWriteSectionHeader(&poffInfo->debugFuncSection, poffFile);
if (entriesWritten != 1)
{
errmsg("Failed to write debug section header: %s\n",
@@ -314,9 +328,7 @@ static void poffWriteSectionHeaders(poffHandle_t handle, FILE *poffFile) /* Then write the section header to the output file */
- entriesWritten = fwrite(&poffInfo->stringTableSection,
- sizeof(poffSectionHeader_t),
- 1, poffFile);
+ entriesWritten = poffWriteSectionHeader(&poffInfo->stringTableSection, poffFile);
if (entriesWritten != 1)
{
errmsg("Failed to write string table section header: %s\n",
@@ -370,6 +382,12 @@ static void poffWriteSectionData(poffHandle_t handle, FILE *poffFile) {
if (!poffInfo->symbolTable) fatal(ePOFFCONFUSION);
+ /* The POFF file is retained in big-endian order. Fixup fields as necessary */
+
+ poffSwapSymbolTableData(poffInfo);
+
+ /* Write the symbol table entries in big-endian order */
+
entriesWritten = fwrite(poffInfo->symbolTable, sizeof(ubyte),
poffInfo->symbolTableSection.sh_size, poffFile);
if (entriesWritten != poffInfo->symbolTableSection.sh_size)
@@ -378,6 +396,11 @@ static void poffWriteSectionData(poffHandle_t handle, FILE *poffFile) strerror(errno));
fatal(ePOFFWRITEERROR);
}
+
+ /* Restore host data order */
+
+ poffSwapSymbolTableData(poffInfo);
+
}
/* Write the relocation table section data (if we have one) */
@@ -386,6 +409,12 @@ static void poffWriteSectionData(poffHandle_t handle, FILE *poffFile) {
if (!poffInfo->relocTable) fatal(ePOFFCONFUSION);
+ /* The POFF file is retained in big-endian order. Fixup fields as necessary */
+
+ poffSwapRelocationData(poffInfo);
+
+ /* Write the relocation table entries in big-endian order */
+
entriesWritten = fwrite(poffInfo->relocTable, sizeof(ubyte),
poffInfo->relocSection.sh_size, poffFile);
if (entriesWritten != poffInfo->relocSection.sh_size)
@@ -394,6 +423,10 @@ static void poffWriteSectionData(poffHandle_t handle, FILE *poffFile) strerror(errno));
fatal(ePOFFWRITEERROR);
}
+
+ /* Restore host data order */
+
+ poffSwapRelocationData(poffInfo);
}
/* Write the file table section data (if we have one) */
@@ -402,6 +435,12 @@ static void poffWriteSectionData(poffHandle_t handle, FILE *poffFile) {
if (!poffInfo->fileNameTable) fatal(ePOFFCONFUSION);
+ /* The POFF file is retained in big-endian order. Fixup fields as necessary */
+
+ poffSwapFileTableData(poffInfo);
+
+ /* Write the file table entries in big-endian order */
+
entriesWritten = fwrite(poffInfo->fileNameTable, sizeof(ubyte),
poffInfo->fileNameTableSection.sh_size,
poffFile);
@@ -411,6 +450,10 @@ static void poffWriteSectionData(poffHandle_t handle, FILE *poffFile) strerror(errno));
fatal(ePOFFWRITEERROR);
}
+
+ /* Restore host data order */
+
+ poffSwapFileTableData(poffInfo);
}
/* Write the line number section data (if we have one) */
@@ -419,6 +462,12 @@ static void poffWriteSectionData(poffHandle_t handle, FILE *poffFile) {
if (!poffInfo->lineNumberTable) fatal(ePOFFCONFUSION);
+ /* The POFF file is retained in big-endian order. Fixup fields as necessary */
+
+ poffSwapLineNumberData(poffInfo);
+
+ /* Write the line number table entries in big-endian order */
+
entriesWritten = fwrite(poffInfo->lineNumberTable, sizeof(ubyte),
poffInfo->lineNumberSection.sh_size,
poffFile);
@@ -428,14 +477,24 @@ static void poffWriteSectionData(poffHandle_t handle, FILE *poffFile) strerror(errno));
fatal(ePOFFWRITEERROR);
}
+
+ /* Restore host order */
+
+ poffSwapLineNumberData(poffInfo);
}
- /* Write the line number section data (if we have one) */
+ /* Write the debug section data (if we have one) */
if (HAVE_DEBUG_SECTION)
{
if (!poffInfo->debugFuncTable) fatal(ePOFFCONFUSION);
+ /* The POFF file is retained in big-endian order. Fixup fields as necessary */
+
+ poffSwapDebugData(poffInfo);
+
+ /* Write the debug entries in big-endian order */
+
entriesWritten = fwrite(poffInfo->debugFuncTable, sizeof(ubyte),
poffInfo->debugFuncSection.sh_size,
poffFile);
@@ -445,6 +504,10 @@ static void poffWriteSectionData(poffHandle_t handle, FILE *poffFile) strerror(errno));
fatal(ePOFFWRITEERROR);
}
+
+ /* Restore host order */
+
+ poffSwapDebugData(poffInfo);
}
/* Write the string table section data LAST (because we may have
|