]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: Check elf sections alignment with MAX_COFF_ALIGNMENT
authorYunhua Feng <yunhuax.feng@intel.com>
Mon, 4 Jun 2018 08:12:28 +0000 (16:12 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Fri, 8 Jun 2018 07:45:28 +0000 (15:45 +0800)
Add the logic to check whether mCoffAlignment is larger than
MAX_COFF_ALIGNMENT, and report error for it.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
BaseTools/Source/C/GenFw/Elf32Convert.c
BaseTools/Source/C/GenFw/Elf64Convert.c

index 14fe4a285857d694a2e1ab038f05c14a02d73be7..436eb529ee37727d1d18194ecebe8402c4beeb7b 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Elf32 Convert solution\r
 \r
-Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>\r
 Portions copyright (c) 2013, ARM Ltd. All rights reserved.<BR>\r
 \r
 This program and the accompanying materials are licensed and made available\r
@@ -383,6 +383,14 @@ ScanSections32 (
     }\r
   }\r
 \r
+  //\r
+  // Check if mCoffAlignment is larger than MAX_COFF_ALIGNMENT\r
+  //\r
+  if (mCoffAlignment > MAX_COFF_ALIGNMENT) {\r
+    Error (NULL, 0, 3000, "Invalid", "Section alignment is larger than MAX_COFF_ALIGNMENT.");\r
+    assert (FALSE);\r
+  }\r
+\r
   //\r
   // Move the PE/COFF header right before the first section. This will help us\r
   // save space when converting to TE.\r
index c39bdff063ab4cecbd6bb49c16fe32a22e9b5de6..54011d75f1ec6c9951071be5b5261a091200e058 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Elf64 convert solution\r
 \r
-Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>\r
 Portions copyright (c) 2013-2014, ARM Ltd. All rights reserved.<BR>\r
 \r
 This program and the accompanying materials are licensed and made available\r
@@ -376,6 +376,15 @@ ScanSections64 (
     }\r
   }\r
 \r
+  //\r
+  // Check if mCoffAlignment is larger than MAX_COFF_ALIGNMENT\r
+  //\r
+  if (mCoffAlignment > MAX_COFF_ALIGNMENT) {\r
+    Error (NULL, 0, 3000, "Invalid", "Section alignment is larger than MAX_COFF_ALIGNMENT.");\r
+    assert (FALSE);\r
+  }\r
+\r
+\r
   //\r
   // Move the PE/COFF header right before the first section. This will help us\r
   // save space when converting to TE.\r