summaryrefslogtreecommitdiff
path: root/BaseTools
diff options
context:
space:
mode:
Diffstat (limited to 'BaseTools')
-rw-r--r--BaseTools/Source/C/GenFw/Elf32Convert.c10
-rw-r--r--BaseTools/Source/C/GenFw/Elf64Convert.c10
2 files changed, 20 insertions, 0 deletions
diff --git a/BaseTools/Source/C/GenFw/Elf32Convert.c b/BaseTools/Source/C/GenFw/Elf32Convert.c
index 53bb14a47d..e1b92ebd71 100644
--- a/BaseTools/Source/C/GenFw/Elf32Convert.c
+++ b/BaseTools/Source/C/GenFw/Elf32Convert.c
@@ -307,6 +307,16 @@ ScanSections32 (
}
//
+ // 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);
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);