/** @file\r
Elf convert solution\r
\r
-Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>\r
\r
This program and the accompanying materials are licensed and made available \r
under the terms and conditions of the BSD License which accompanies this \r
#include <string.h>\r
#include <time.h>\r
#include <ctype.h>\r
+#include <assert.h>\r
\r
#include <Common/UefiBaseTypes.h>\r
#include <IndustryStandard/PeImage.h>\r
//\r
UINT32 mTableOffset;\r
\r
+//\r
+//mFileBufferSize\r
+//\r
+UINT32 mFileBufferSize;\r
+\r
//\r
//*****************************************************************************\r
// Common ELF Functions\r
mCoffFile,\r
mCoffOffset + sizeof(EFI_IMAGE_BASE_RELOCATION) + 2 * MAX_COFF_ALIGNMENT\r
);\r
+ if (mCoffFile == NULL) {\r
+ Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");\r
+ }\r
+ assert (mCoffFile != NULL);\r
memset (\r
mCoffFile + mCoffOffset, 0,\r
sizeof(EFI_IMAGE_BASE_RELOCATION) + 2 * MAX_COFF_ALIGNMENT\r
ELF_FUNCTION_TABLE ElfFunctions;\r
UINT8 EiClass;\r
\r
+ mFileBufferSize = *FileLength;\r
//\r
// Determine ELF type and set function table pointer correctly.\r
//\r
// Write and relocate sections.\r
//\r
VerboseMsg ("Write and relocate sections.");\r
- ElfFunctions.WriteSections (SECTION_TEXT);\r
- ElfFunctions.WriteSections (SECTION_DATA);\r
- ElfFunctions.WriteSections (SECTION_HII);\r
+ if (!ElfFunctions.WriteSections (SECTION_TEXT)) {\r
+ return FALSE;\r
+ }\r
+ if (!ElfFunctions.WriteSections (SECTION_DATA)) {\r
+ return FALSE;\r
+ }\r
+ if (!ElfFunctions.WriteSections (SECTION_HII)) {\r
+ return FALSE;\r
+ }\r
\r
//\r
// Translate and write relocations.\r