diff options
author | wuyizhong <wuyizhong@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-11-23 08:22:43 +0000 |
---|---|---|
committer | wuyizhong <wuyizhong@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-11-23 08:22:43 +0000 |
commit | c4da10831678e40a80071b7234273545bbc2a38b (patch) | |
tree | bb5dc87bdd6390d8a733573b5ae522531069c411 /Tools | |
parent | 822698dca92da4b87214d24dcbafc3381d0a6d65 (diff) | |
download | edk2-c4da10831678e40a80071b7234273545bbc2a38b.zip edk2-c4da10831678e40a80071b7234273545bbc2a38b.tar.gz edk2-c4da10831678e40a80071b7234273545bbc2a38b.tar.bz2 |
Change supporting section alignment from 4k to 64k. Add check whether section-alignment and file-alignment match or not.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2004 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Tools')
-rw-r--r-- | Tools/CCode/Source/PeiRebase/PeiRebaseExe.c | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/Tools/CCode/Source/PeiRebase/PeiRebaseExe.c b/Tools/CCode/Source/PeiRebase/PeiRebaseExe.c index d27083a..8537d69 100644 --- a/Tools/CCode/Source/PeiRebase/PeiRebaseExe.c +++ b/Tools/CCode/Source/PeiRebase/PeiRebaseExe.c @@ -680,13 +680,13 @@ 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;
@@ -697,6 +697,25 @@ 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);
+ _asm int 3;
+ free ((VOID *) MemoryImagePointer);
+ return EFI_ABORTED;
+ }
+ }
+ else {
+ //
+ // BUGBUG: TE Image Header lack section-alignment and file-alignment info
+ //
+ }
ImageContext.DestinationAddress = NewPe32BaseAddress;
Status = PeCoffLoaderRelocateImage (&ImageContext);
@@ -932,14 +951,14 @@ 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;
@@ -950,6 +969,11 @@ Returns: free ((VOID *) MemoryImagePointer);
return Status;
}
+
+ //
+ // Check if section-alignment and file-alignment match or not
+ // BUGBUG: TE Image Header lack section-alignment and file-alignment info
+ //
ImageContext.DestinationAddress = NewPe32BaseAddress;
Status = PeCoffLoaderRelocateImage (&ImageContext);
|