diff options
-rw-r--r-- | Tools/Source/TianoTools/PeiRebase/PeiRebaseExe.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Tools/Source/TianoTools/PeiRebase/PeiRebaseExe.c b/Tools/Source/TianoTools/PeiRebase/PeiRebaseExe.c index 27c646e486..35329c74d6 100644 --- a/Tools/Source/TianoTools/PeiRebase/PeiRebaseExe.c +++ b/Tools/Source/TianoTools/PeiRebase/PeiRebaseExe.c @@ -624,12 +624,12 @@ Returns: // Allocate a buffer for the image to be loaded into.
//
Pe32ImageSize = GetLength (CurrentPe32Section.Pe32Section->CommonHeader.Size) - sizeof (EFI_PE32_SECTION);
- MemoryImagePointer = (UINTN) (malloc (Pe32ImageSize + 0x1000));
+ MemoryImagePointer = (UINTN) (malloc (Pe32ImageSize + 0x1000 + ImageContext.SectionAlignment));
if (MemoryImagePointer == 0) {
Error (NULL, 0, 0, "memory allocation failure", NULL);
return EFI_OUT_OF_RESOURCES;
}
- memset ((void *) MemoryImagePointer, 0, Pe32ImageSize + 0x1000);
+ memset ((void *) MemoryImagePointer, 0, Pe32ImageSize + 0x1000 + ImageContext.SectionAlignment);
MemoryImagePointerAligned = (MemoryImagePointer + 0x0FFF) & (-1 << 12);
@@ -876,13 +876,13 @@ Returns: //
// Allocate a buffer for the image to be loaded into.
//
- MemoryImagePointer = (UINTN) (malloc (Pe32ImageSize + 0x1000));
+ MemoryImagePointer = (UINTN) (malloc (Pe32ImageSize + 0x1000 + ImageContext.SectionAlignment));
if (MemoryImagePointer == 0) {
Error (NULL, 0, 0, "memory allocation error on rebase of TE image", FileGuidString);
free (TEBuffer);
return EFI_OUT_OF_RESOURCES;
}
- memset ((void *) MemoryImagePointer, 0, Pe32ImageSize + 0x1000);
+ memset ((void *) MemoryImagePointer, 0, Pe32ImageSize + 0x1000 + ImageContext.SectionAlignment);
MemoryImagePointerAligned = (MemoryImagePointer + 0x0FFF) & (-1 << 12);
|