mirror of https://github.com/acidanthera/audk.git
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
This commit is contained in:
parent
db608e6b5b
commit
d0b053b7c2
|
@ -545,7 +545,7 @@ Returns:
|
||||||
printf (" Where:\n");
|
printf (" Where:\n");
|
||||||
printf (" InputFileName is the name of the EFI FV file to rebase.\n");
|
printf (" InputFileName is the name of the EFI FV file to rebase.\n");
|
||||||
printf (" OutputFileName is the desired output file name.\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");
|
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.
|
// Allocate a buffer for the image to be loaded into.
|
||||||
//
|
//
|
||||||
Pe32ImageSize = GetLength (CurrentPe32Section.Pe32Section->CommonHeader.Size) - sizeof (EFI_PE32_SECTION);
|
Pe32ImageSize = GetLength (CurrentPe32Section.Pe32Section->CommonHeader.Size) - sizeof (EFI_PE32_SECTION);
|
||||||
MemoryImagePointer = (UINTN) (malloc (Pe32ImageSize + 0x1000));
|
MemoryImagePointer = (UINTN) (malloc (Pe32ImageSize + 0x10000));
|
||||||
if (MemoryImagePointer == 0) {
|
if (MemoryImagePointer == 0) {
|
||||||
Error (NULL, 0, 0, "memory allocation failure", NULL);
|
Error (NULL, 0, 0, "memory allocation failure", NULL);
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
memset ((void *) MemoryImagePointer, 0, Pe32ImageSize + 0x1000);
|
memset ((void *) MemoryImagePointer, 0, Pe32ImageSize + 0x10000);
|
||||||
MemoryImagePointerAligned = (MemoryImagePointer + 0x0FFF) & (-1 << 12);
|
MemoryImagePointerAligned = (MemoryImagePointer + 0x0FFFF) & (-1 << 16);
|
||||||
|
|
||||||
|
|
||||||
ImageContext.ImageAddress = MemoryImagePointerAligned;
|
ImageContext.ImageAddress = MemoryImagePointerAligned;
|
||||||
|
|
||||||
|
@ -766,6 +766,24 @@ Returns:
|
||||||
free ((VOID *) MemoryImagePointer);
|
free ((VOID *) MemoryImagePointer);
|
||||||
return Status;
|
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;
|
ImageContext.DestinationAddress = NewPe32BaseAddress;
|
||||||
Status = PeCoffLoaderRelocateImage (&ImageContext);
|
Status = PeCoffLoaderRelocateImage (&ImageContext);
|
||||||
|
@ -1060,15 +1078,15 @@ Returns:
|
||||||
//
|
//
|
||||||
// Allocate a buffer for the image to be loaded into.
|
// Allocate a buffer for the image to be loaded into.
|
||||||
//
|
//
|
||||||
MemoryImagePointer = (UINTN) (malloc (Pe32ImageSize + 0x1000));
|
MemoryImagePointer = (UINTN) (malloc (Pe32ImageSize + 0x10000));
|
||||||
if (MemoryImagePointer == 0) {
|
if (MemoryImagePointer == 0) {
|
||||||
Error (NULL, 0, 0, "memory allocation error on rebase of TE image", FileGuidString);
|
Error (NULL, 0, 0, "memory allocation error on rebase of TE image", FileGuidString);
|
||||||
free (TEBuffer);
|
free (TEBuffer);
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
memset ((void *) MemoryImagePointer, 0, Pe32ImageSize + 0x1000);
|
memset ((void *) MemoryImagePointer, 0, Pe32ImageSize + 0x10000);
|
||||||
MemoryImagePointerAligned = (MemoryImagePointer + 0x0FFF) & (-1 << 12);
|
MemoryImagePointerAligned = (MemoryImagePointer + 0x0FFFF) & (-1 << 16);
|
||||||
|
|
||||||
|
|
||||||
ImageContext.ImageAddress = MemoryImagePointerAligned;
|
ImageContext.ImageAddress = MemoryImagePointerAligned;
|
||||||
Status = PeCoffLoaderLoadImage (&ImageContext);
|
Status = PeCoffLoaderLoadImage (&ImageContext);
|
||||||
|
|
Loading…
Reference in New Issue