summaryrefslogtreecommitdiff
path: root/BaseTools/Source/C/GenFw/Elf32Convert.c
diff options
context:
space:
mode:
Diffstat (limited to 'BaseTools/Source/C/GenFw/Elf32Convert.c')
-rw-r--r--BaseTools/Source/C/GenFw/Elf32Convert.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/BaseTools/Source/C/GenFw/Elf32Convert.c b/BaseTools/Source/C/GenFw/Elf32Convert.c
index 5c7b689ee8..10d9892ba1 100644
--- a/BaseTools/Source/C/GenFw/Elf32Convert.c
+++ b/BaseTools/Source/C/GenFw/Elf32Convert.c
@@ -96,7 +96,7 @@ STATIC Elf_Phdr *mPhdrBase;
//
// Coff information
//
-STATIC const UINT32 mCoffAlignment = 0x20;
+STATIC UINT32 mCoffAlignment = 0x20;
//
// PE section alignment.
@@ -292,6 +292,20 @@ ScanSections32 (
mCoffOffset += mCoffNbrSections * sizeof(EFI_IMAGE_SECTION_HEADER);
//
+ // Set mCoffAlignment to the maximum alignment of the input sections
+ // we care about
+ //
+ for (i = 0; i < mEhdr->e_shnum; i++) {
+ Elf_Shdr *shdr = GetShdrByIndex(i);
+ if (shdr->sh_addralign <= mCoffAlignment) {
+ continue;
+ }
+ if (IsTextShdr(shdr) || IsDataShdr(shdr) || IsHiiRsrcShdr(shdr)) {
+ mCoffAlignment = (UINT32)shdr->sh_addralign;
+ }
+ }
+
+ //
// First text sections.
//
mCoffOffset = CoffAlign(mCoffOffset);