summaryrefslogtreecommitdiff
path: root/BaseTools
diff options
context:
space:
mode:
authorLiming Gao <liming.gao@intel.com>2019-10-17 14:55:47 +0800
committerLiming Gao <liming.gao@intel.com>2019-10-24 09:41:31 +0800
commit3d312a1fec2eff60212859849fdb407018e47ca8 (patch)
treecfa4883547d97494209acb41730eeec564f7cdd0 /BaseTools
parent15330934dc860c20b2143c802f3b4285e89021e3 (diff)
downloadedk2-3d312a1fec2eff60212859849fdb407018e47ca8.zip
edk2-3d312a1fec2eff60212859849fdb407018e47ca8.tar.gz
edk2-3d312a1fec2eff60212859849fdb407018e47ca8.tar.bz2
BaseTools GenFw: Fix the issue to update the wrong size as SectionSize
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1603 CLANG9 generated PE image exposes below two issues. 1. SectionSize is used to copy PE section data. It should be smaller than section raw size. 2. The real data is required to be copied. So, copy the min size of VirtualSize and SizeOfRawData. Signed-off-by: Liming Gao <liming.gao@intel.com> Cc: Bob Feng <bob.c.feng@intel.com> Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
Diffstat (limited to 'BaseTools')
-rw-r--r--BaseTools/Source/C/GenFw/GenFw.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/BaseTools/Source/C/GenFw/GenFw.c b/BaseTools/Source/C/GenFw/GenFw.c
index c99782b..8cab70b 100644
--- a/BaseTools/Source/C/GenFw/GenFw.c
+++ b/BaseTools/Source/C/GenFw/GenFw.c
@@ -653,7 +653,11 @@ PeCoffConvertImageToXip (
//
// Make the size of raw data in section header alignment.
//
- SectionHeader->SizeOfRawData = (SectionHeader->Misc.VirtualSize + PeHdr->Pe32.OptionalHeader.FileAlignment - 1) & (~(PeHdr->Pe32.OptionalHeader.FileAlignment - 1));
+ SectionSize = (SectionHeader->Misc.VirtualSize + PeHdr->Pe32.OptionalHeader.FileAlignment - 1) & (~(PeHdr->Pe32.OptionalHeader.FileAlignment - 1));
+ if (SectionSize < SectionHeader->SizeOfRawData) {
+ SectionHeader->SizeOfRawData = SectionSize;
+ }
+
SectionHeader->PointerToRawData = SectionHeader->VirtualAddress;
}
@@ -999,7 +1003,7 @@ Returns:
CopyMem (
FileBuffer + SectionHeader->PointerToRawData,
(VOID*) (UINTN) (ImageContext.ImageAddress + SectionHeader->VirtualAddress),
- SectionHeader->SizeOfRawData
+ SectionHeader->SizeOfRawData < SectionHeader->Misc.VirtualSize ? SectionHeader->SizeOfRawData : SectionHeader->Misc.VirtualSize
);
}