On 10/15/19 2:26 AM, Liming Gao wrote:
Signed-off-by: Liming Gao <[email protected]> --- BaseTools/Source/C/GenFw/GenFw.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)diff --git a/BaseTools/Source/C/GenFw/GenFw.c b/BaseTools/Source/C/GenFw/GenFw.c index c99782b78e..d8d3360c24 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 ); }
Reviewed-by: Philippe Mathieu-Daude <[email protected]> -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#48989): https://edk2.groups.io/g/devel/message/48989 Mute This Topic: https://groups.io/mt/34540584/21656 Group Owner: [email protected] Unsubscribe: https://edk2.groups.io/g/devel/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
