]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/C/GenFw/ElfConvert.c
BaseTools/GenFw: recognize MM file types as EFI Boot Service Drivers.
[mirror_edk2.git] / BaseTools / Source / C / GenFw / ElfConvert.c
index 17689cf27f1312f40f16ef8bd18bf5faba0cf817..17913ff2dfbe118664ad06a0971143923da42090 100644 (file)
@@ -1,6 +1,7 @@
 /** @file\r
+Elf convert solution\r
 \r
-Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2010 - 2016, 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
@@ -23,6 +24,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #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
@@ -95,11 +97,15 @@ CoffAddFixup(
 \r
     mCoffFile = realloc (\r
       mCoffFile,\r
-      mCoffOffset + sizeof(EFI_IMAGE_BASE_RELOCATION) + 2*0x1000\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*0x1000\r
+      sizeof(EFI_IMAGE_BASE_RELOCATION) + 2 * MAX_COFF_ALIGNMENT\r
       );\r
 \r
     mCoffBaseRel = (EFI_IMAGE_BASE_RELOCATION*)(mCoffFile + mCoffOffset);\r