summaryrefslogtreecommitdiff
path: root/BaseTools/Source/C/GenFw/Elf64Convert.c
diff options
context:
space:
mode:
Diffstat (limited to 'BaseTools/Source/C/GenFw/Elf64Convert.c')
-rw-r--r--BaseTools/Source/C/GenFw/Elf64Convert.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/BaseTools/Source/C/GenFw/Elf64Convert.c b/BaseTools/Source/C/GenFw/Elf64Convert.c
index 7650afe54c..1c0f4a4dc8 100644
--- a/BaseTools/Source/C/GenFw/Elf64Convert.c
+++ b/BaseTools/Source/C/GenFw/Elf64Convert.c
@@ -301,6 +301,16 @@ ScanSections64 (
}
//
+ // Move the PE/COFF header right before the first section. This will help us
+ // save space when converting to TE.
+ //
+ if (mCoffAlignment > mCoffOffset) {
+ mNtHdrOffset += mCoffAlignment - mCoffOffset;
+ mTableOffset += mCoffAlignment - mCoffOffset;
+ mCoffOffset = mCoffAlignment;
+ }
+
+ //
// First text sections.
//
mCoffOffset = CoffAlign(mCoffOffset);