summaryrefslogtreecommitdiff
path: root/Tools/CCode/Source
diff options
context:
space:
mode:
authorjwang36 <jwang36@6f19259b-4bc3-4df7-8a09-765794883524>2007-01-09 02:41:18 +0000
committerjwang36 <jwang36@6f19259b-4bc3-4df7-8a09-765794883524>2007-01-09 02:41:18 +0000
commitd0b053b7c2ec3727d605b1277e7e7f9eeec56951 (patch)
tree043e0c8cadc259ad2ec4868c05321b38b9ec1d2b /Tools/CCode/Source
parentdb608e6b5b00f54a678d7144170ccb5057782e14 (diff)
downloadedk2-platforms-d0b053b7c2ec3727d605b1277e7e7f9eeec56951.tar.xz
Merged back the Yizhong's fix which was overwritten by check-in of r2157,2158.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2197 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Tools/CCode/Source')
-rw-r--r--Tools/CCode/Source/PeiRebase/PeiRebaseExe.c36
1 files changed, 27 insertions, 9 deletions
diff --git a/Tools/CCode/Source/PeiRebase/PeiRebaseExe.c b/Tools/CCode/Source/PeiRebase/PeiRebaseExe.c
index 7519a55e48..5f7dfc25c7 100644
--- a/Tools/CCode/Source/PeiRebase/PeiRebaseExe.c
+++ b/Tools/CCode/Source/PeiRebase/PeiRebaseExe.c
@@ -545,7 +545,7 @@ Returns:
printf (" Where:\n");
printf (" InputFileName is the name of the EFI FV file to rebase.\n");
printf (" OutputFileName is the desired output file name.\n");
- printf (" BaseAddress is the FV base address to rebase agains.\n");
+ printf (" BaseAddress is the FV base address to rebase against.\n");
printf (" Argument pair may be in any order.\n\n");
}
@@ -749,14 +749,14 @@ 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 + 0x10000));
if (MemoryImagePointer == 0) {
Error (NULL, 0, 0, "memory allocation failure", NULL);
return EFI_OUT_OF_RESOURCES;
}
- memset ((void *) MemoryImagePointer, 0, Pe32ImageSize + 0x1000);
- MemoryImagePointerAligned = (MemoryImagePointer + 0x0FFF) & (-1 << 12);
-
+ memset ((void *) MemoryImagePointer, 0, Pe32ImageSize + 0x10000);
+ MemoryImagePointerAligned = (MemoryImagePointer + 0x0FFFF) & (-1 << 16);
+
ImageContext.ImageAddress = MemoryImagePointerAligned;
@@ -766,6 +766,24 @@ Returns:
free ((VOID *) MemoryImagePointer);
return Status;
}
+
+ //
+ // Check if section-alignment and file-alignment match or not
+ //
+ if (!(ImageContext.IsTeImage)) {
+ PeHdr = (EFI_IMAGE_NT_HEADERS *)((UINTN)ImageContext.ImageAddress +
+ ImageContext.PeCoffHeaderOffset);
+ if (PeHdr->OptionalHeader.SectionAlignment != PeHdr->OptionalHeader.FileAlignment) {
+ Error (NULL, 0, 0, "Section-Alignment and File-Alignment does not match", FileGuidString);
+ free ((VOID *) MemoryImagePointer);
+ return EFI_ABORTED;
+ }
+ }
+ else {
+ //
+ // BUGBUG: TE Image Header lack section-alignment and file-alignment info
+ //
+ }
ImageContext.DestinationAddress = NewPe32BaseAddress;
Status = PeCoffLoaderRelocateImage (&ImageContext);
@@ -1060,15 +1078,15 @@ Returns:
//
// Allocate a buffer for the image to be loaded into.
//
- MemoryImagePointer = (UINTN) (malloc (Pe32ImageSize + 0x1000));
+ MemoryImagePointer = (UINTN) (malloc (Pe32ImageSize + 0x10000));
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);
- MemoryImagePointerAligned = (MemoryImagePointer + 0x0FFF) & (-1 << 12);
-
+ memset ((void *) MemoryImagePointer, 0, Pe32ImageSize + 0x10000);
+ MemoryImagePointerAligned = (MemoryImagePointer + 0x0FFFF) & (-1 << 16);
+
ImageContext.ImageAddress = MemoryImagePointerAligned;
Status = PeCoffLoaderLoadImage (&ImageContext);