summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/C/GenFw
diff options
context:
space:
mode:
authorYunhua Feng <yunhuax.feng@intel.com>2018-06-04 16:12:28 +0800
committerYonghong Zhu <yonghong.zhu@intel.com>2018-06-08 15:45:28 +0800
commit3f0218003141ae38152f5a2520c969445afc721f (patch)
tree0290e70381206f06e12eca30c383ad47c0840d5d /BaseTools/Source/C/GenFw
parentd69e8a7b79bdfb282f35616d3030f02934d6271e (diff)
downloadedk2-3f0218003141ae38152f5a2520c969445afc721f.tar.gz
edk2-3f0218003141ae38152f5a2520c969445afc721f.tar.bz2
edk2-3f0218003141ae38152f5a2520c969445afc721f.zip
BaseTools: Check elf sections alignment with MAX_COFF_ALIGNMENT
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>
Diffstat (limited to 'BaseTools/Source/C/GenFw')
-rw-r--r--BaseTools/Source/C/GenFw/Elf32Convert.c10
-rw-r--r--BaseTools/Source/C/GenFw/Elf64Convert.c11
2 files changed, 19 insertions, 2 deletions
diff --git a/BaseTools/Source/C/GenFw/Elf32Convert.c b/BaseTools/Source/C/GenFw/Elf32Convert.c
index 14fe4a2858..436eb529ee 100644
--- a/BaseTools/Source/C/GenFw/Elf32Convert.c
+++ b/BaseTools/Source/C/GenFw/Elf32Convert.c
@@ -1,7 +1,7 @@
/** @file
Elf32 Convert solution
-Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
Portions copyright (c) 2013, ARM Ltd. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
@@ -384,6 +384,14 @@ ScanSections32 (
}
//
+ // Check if mCoffAlignment is larger than MAX_COFF_ALIGNMENT
+ //
+ if (mCoffAlignment > MAX_COFF_ALIGNMENT) {
+ Error (NULL, 0, 3000, "Invalid", "Section alignment is larger than MAX_COFF_ALIGNMENT.");
+ assert (FALSE);
+ }
+
+ //
// Move the PE/COFF header right before the first section. This will help us
// save space when converting to TE.
//
diff --git a/BaseTools/Source/C/GenFw/Elf64Convert.c b/BaseTools/Source/C/GenFw/Elf64Convert.c
index c39bdff063..54011d75f1 100644
--- a/BaseTools/Source/C/GenFw/Elf64Convert.c
+++ b/BaseTools/Source/C/GenFw/Elf64Convert.c
@@ -1,7 +1,7 @@
/** @file
Elf64 convert solution
-Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
Portions copyright (c) 2013-2014, ARM Ltd. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
@@ -377,6 +377,15 @@ ScanSections64 (
}
//
+ // Check if mCoffAlignment is larger than MAX_COFF_ALIGNMENT
+ //
+ if (mCoffAlignment > MAX_COFF_ALIGNMENT) {
+ Error (NULL, 0, 3000, "Invalid", "Section alignment is larger than MAX_COFF_ALIGNMENT.");
+ assert (FALSE);
+ }
+
+
+ //
// Move the PE/COFF header right before the first section. This will help us
// save space when converting to TE.
//