summaryrefslogtreecommitdiff
path: root/BaseTools
diff options
context:
space:
mode:
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
);
}