mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-28 08:04:07 +02:00
1. Adjust might be 64bit, so we need to typecast it to UINT32 firstly.
2. Synchronization modification described in Tracker EDKT182 to all dependent files. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1270 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
ff225cbbae
commit
9c7790d2cb
@ -536,7 +536,7 @@ Returns:
|
|||||||
break;
|
break;
|
||||||
case EFI_IMAGE_REL_BASED_HIGH:
|
case EFI_IMAGE_REL_BASED_HIGH:
|
||||||
F16 = (UINT16 *) Fixup;
|
F16 = (UINT16 *) Fixup;
|
||||||
*F16 = (UINT16)((*F16 << 16) + (UINT16) Adjust);
|
*F16 = (UINT16) (*F16 + ((UINT16) ((UINT32) Adjust >> 16)));
|
||||||
if (FixupData != NULL) {
|
if (FixupData != NULL) {
|
||||||
*(UINT16 *) FixupData = *F16;
|
*(UINT16 *) FixupData = *F16;
|
||||||
FixupData = FixupData + sizeof(UINT16);
|
FixupData = FixupData + sizeof(UINT16);
|
||||||
|
@ -62,10 +62,10 @@ PeHotRelocateImageEx (
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns TRUE if the machine type of PE/COFF image is supported. Supported
|
Returns TRUE if the machine type of PE/COFF image is supported. Supported
|
||||||
does not mean the image can be executed it means the PE/COFF loader supports
|
does not mean the image can be executed it means the PE/COFF loader supports
|
||||||
loading and relocating of the image type. It's up to the caller to support
|
loading and relocating of the image type. It's up to the caller to support
|
||||||
the entry point.
|
the entry point.
|
||||||
|
|
||||||
@param Machine Machine type from the PE Header.
|
@param Machine Machine type from the PE Header.
|
||||||
|
|
||||||
@ -117,16 +117,16 @@ PeCoffLoaderGetPeHeader (
|
|||||||
ImageContext->PeCoffHeaderOffset = 0;
|
ImageContext->PeCoffHeaderOffset = 0;
|
||||||
if (DosHdr.e_magic == EFI_IMAGE_DOS_SIGNATURE) {
|
if (DosHdr.e_magic == EFI_IMAGE_DOS_SIGNATURE) {
|
||||||
//
|
//
|
||||||
// DOS image header is present, so read the PE header after the DOS image
|
// DOS image header is present, so read the PE header after the DOS image
|
||||||
// header
|
// header
|
||||||
//
|
//
|
||||||
ImageContext->PeCoffHeaderOffset = DosHdr.e_lfanew;
|
ImageContext->PeCoffHeaderOffset = DosHdr.e_lfanew;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Read the PE/COFF Header. For PE32 (32-bit) this will read in too much
|
// Read the PE/COFF Header. For PE32 (32-bit) this will read in too much
|
||||||
// data, but that should not hurt anythine. Hdr.Pe32->OptionalHeader.Magic
|
// data, but that should not hurt anythine. Hdr.Pe32->OptionalHeader.Magic
|
||||||
// determins if this is a PE32 or PE32+ image. The magic is in the same
|
// determins if this is a PE32 or PE32+ image. The magic is in the same
|
||||||
// location in both images.
|
// location in both images.
|
||||||
//
|
//
|
||||||
Size = sizeof (EFI_IMAGE_OPTIONAL_HEADER_UNION);
|
Size = sizeof (EFI_IMAGE_OPTIONAL_HEADER_UNION);
|
||||||
@ -155,7 +155,7 @@ PeCoffLoaderGetPeHeader (
|
|||||||
} else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {
|
} else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {
|
||||||
ImageContext->IsTeImage = FALSE;
|
ImageContext->IsTeImage = FALSE;
|
||||||
ImageContext->Machine = Hdr.Pe32->FileHeader.Machine;
|
ImageContext->Machine = Hdr.Pe32->FileHeader.Machine;
|
||||||
|
|
||||||
if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
|
if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
|
||||||
//
|
//
|
||||||
// Use PE32 offset
|
// Use PE32 offset
|
||||||
@ -175,7 +175,7 @@ PeCoffLoaderGetPeHeader (
|
|||||||
ImageContext->SizeOfHeaders = Hdr.Pe32Plus->OptionalHeader.SizeOfHeaders;
|
ImageContext->SizeOfHeaders = Hdr.Pe32Plus->OptionalHeader.SizeOfHeaders;
|
||||||
} else {
|
} else {
|
||||||
ImageContext->ImageError = IMAGE_ERROR_INVALID_MACHINE_TYPE;
|
ImageContext->ImageError = IMAGE_ERROR_INVALID_MACHINE_TYPE;
|
||||||
return RETURN_UNSUPPORTED;
|
return RETURN_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ImageContext->ImageError = IMAGE_ERROR_INVALID_MACHINE_TYPE;
|
ImageContext->ImageError = IMAGE_ERROR_INVALID_MACHINE_TYPE;
|
||||||
@ -187,7 +187,7 @@ PeCoffLoaderGetPeHeader (
|
|||||||
// If the PE/COFF loader does not support the image type return
|
// If the PE/COFF loader does not support the image type return
|
||||||
// unsupported. This library can suport lots of types of images
|
// unsupported. This library can suport lots of types of images
|
||||||
// this does not mean the user of this library can call the entry
|
// this does not mean the user of this library can call the entry
|
||||||
// point of the image.
|
// point of the image.
|
||||||
//
|
//
|
||||||
return RETURN_UNSUPPORTED;
|
return RETURN_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
@ -205,7 +205,7 @@ PeCoffLoaderGetPeHeader (
|
|||||||
If the PE/COFF image accessed through the ImageRead service in the ImageContext structure is not
|
If the PE/COFF image accessed through the ImageRead service in the ImageContext structure is not
|
||||||
a supported PE/COFF image type, then return RETURN_UNSUPPORTED. If any errors occur while
|
a supported PE/COFF image type, then return RETURN_UNSUPPORTED. If any errors occur while
|
||||||
computing the fields of ImageContext, then the error status is returned in the ImageError field of
|
computing the fields of ImageContext, then the error status is returned in the ImageError field of
|
||||||
ImageContext.
|
ImageContext.
|
||||||
|
|
||||||
@param ImageContext Pointer to the image context structure that describes the PE/COFF
|
@param ImageContext Pointer to the image context structure that describes the PE/COFF
|
||||||
image that needs to be examined by this function.
|
image that needs to be examined by this function.
|
||||||
@ -298,19 +298,19 @@ PeCoffLoaderGetImageInfo (
|
|||||||
|
|
||||||
if (!(ImageContext->IsTeImage)) {
|
if (!(ImageContext->IsTeImage)) {
|
||||||
if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
|
if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
|
||||||
//
|
//
|
||||||
// Use PE32 offset
|
// Use PE32 offset
|
||||||
//
|
//
|
||||||
NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes;
|
NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes;
|
||||||
DebugDirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
|
DebugDirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
|
||||||
} else {
|
} else {
|
||||||
//
|
//
|
||||||
// Use PE32+ offset
|
// Use PE32+ offset
|
||||||
//
|
//
|
||||||
NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;
|
NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;
|
||||||
DebugDirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
|
DebugDirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) {
|
if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) {
|
||||||
|
|
||||||
DebugDirectoryEntryRva = DebugDirectoryEntry->VirtualAddress;
|
DebugDirectoryEntryRva = DebugDirectoryEntry->VirtualAddress;
|
||||||
@ -324,8 +324,8 @@ PeCoffLoaderGetImageInfo (
|
|||||||
|
|
||||||
SectionHeaderOffset = (UINTN)(
|
SectionHeaderOffset = (UINTN)(
|
||||||
ImageContext->PeCoffHeaderOffset +
|
ImageContext->PeCoffHeaderOffset +
|
||||||
sizeof (UINT32) +
|
sizeof (UINT32) +
|
||||||
sizeof (EFI_IMAGE_FILE_HEADER) +
|
sizeof (EFI_IMAGE_FILE_HEADER) +
|
||||||
Hdr.Pe32->FileHeader.SizeOfOptionalHeader
|
Hdr.Pe32->FileHeader.SizeOfOptionalHeader
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -428,8 +428,8 @@ PeCoffLoaderGetImageInfo (
|
|||||||
|
|
||||||
//
|
//
|
||||||
// In Te image header there is not a field to describe the ImageSize.
|
// In Te image header there is not a field to describe the ImageSize.
|
||||||
// Actually, the ImageSize equals the RVA plus the VirtualSize of
|
// Actually, the ImageSize equals the RVA plus the VirtualSize of
|
||||||
// the last section mapped into memory (Must be rounded up to
|
// the last section mapped into memory (Must be rounded up to
|
||||||
// a mulitple of Section Alignment). Per the PE/COFF specification, the
|
// a mulitple of Section Alignment). Per the PE/COFF specification, the
|
||||||
// section headers in the Section Table must appear in order of the RVA
|
// section headers in the Section Table must appear in order of the RVA
|
||||||
// values for the corresponding sections. So the ImageSize can be determined
|
// values for the corresponding sections. So the ImageSize can be determined
|
||||||
@ -489,7 +489,7 @@ PeCoffLoaderImageAddress (
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// @bug Check to make sure ImageSize is correct for the relocated image.
|
// @bug Check to make sure ImageSize is correct for the relocated image.
|
||||||
// it may only work for the file we start with and not the relocated image
|
// it may only work for the file we start with and not the relocated image
|
||||||
//
|
//
|
||||||
if (Address >= ImageContext->ImageSize) {
|
if (Address >= ImageContext->ImageSize) {
|
||||||
@ -506,7 +506,7 @@ PeCoffLoaderImageAddress (
|
|||||||
If the DestinationAddress field of ImageContext is 0, then use the ImageAddress field of
|
If the DestinationAddress field of ImageContext is 0, then use the ImageAddress field of
|
||||||
ImageContext as the relocation base address. Otherwise, use the DestinationAddress field
|
ImageContext as the relocation base address. Otherwise, use the DestinationAddress field
|
||||||
of ImageContext as the relocation base address. The caller must allocate the relocation
|
of ImageContext as the relocation base address. The caller must allocate the relocation
|
||||||
fixup log buffer and fill in the FixupData field of ImageContext prior to calling this function.
|
fixup log buffer and fill in the FixupData field of ImageContext prior to calling this function.
|
||||||
If ImageContext is NULL, then ASSERT().
|
If ImageContext is NULL, then ASSERT().
|
||||||
|
|
||||||
@param ImageContext Pointer to the image context structure that describes the PE/COFF
|
@param ImageContext Pointer to the image context structure that describes the PE/COFF
|
||||||
@ -537,7 +537,7 @@ PeCoffLoaderRelocateImage (
|
|||||||
CHAR8 *Fixup;
|
CHAR8 *Fixup;
|
||||||
CHAR8 *FixupBase;
|
CHAR8 *FixupBase;
|
||||||
UINT16 *F16;
|
UINT16 *F16;
|
||||||
UINT32 *F32;
|
UINT32 *F32;
|
||||||
UINT64 *F64;
|
UINT64 *F64;
|
||||||
CHAR8 *FixupData;
|
CHAR8 *FixupData;
|
||||||
PHYSICAL_ADDRESS BaseAddress;
|
PHYSICAL_ADDRESS BaseAddress;
|
||||||
@ -575,7 +575,7 @@ PeCoffLoaderRelocateImage (
|
|||||||
//
|
//
|
||||||
Adjust = (UINT64)BaseAddress - Hdr.Pe32->OptionalHeader.ImageBase;
|
Adjust = (UINT64)BaseAddress - Hdr.Pe32->OptionalHeader.ImageBase;
|
||||||
Hdr.Pe32->OptionalHeader.ImageBase = (UINT32)BaseAddress;
|
Hdr.Pe32->OptionalHeader.ImageBase = (UINT32)BaseAddress;
|
||||||
|
|
||||||
NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes;
|
NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes;
|
||||||
RelocDir = &Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];
|
RelocDir = &Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];
|
||||||
} else {
|
} else {
|
||||||
@ -618,14 +618,14 @@ PeCoffLoaderRelocateImage (
|
|||||||
//
|
//
|
||||||
RelocDir = &Hdr.Te->DataDirectory[0];
|
RelocDir = &Hdr.Te->DataDirectory[0];
|
||||||
RelocBase = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(
|
RelocBase = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(
|
||||||
ImageContext->ImageAddress +
|
ImageContext->ImageAddress +
|
||||||
RelocDir->VirtualAddress +
|
RelocDir->VirtualAddress +
|
||||||
sizeof(EFI_TE_IMAGE_HEADER) -
|
sizeof(EFI_TE_IMAGE_HEADER) -
|
||||||
Hdr.Te->StrippedSize
|
Hdr.Te->StrippedSize
|
||||||
);
|
);
|
||||||
RelocBaseEnd = (EFI_IMAGE_BASE_RELOCATION *) ((UINTN) RelocBase + (UINTN) RelocDir->Size - 1);
|
RelocBaseEnd = (EFI_IMAGE_BASE_RELOCATION *) ((UINTN) RelocBase + (UINTN) RelocDir->Size - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Run the relocation information and apply the fixups
|
// Run the relocation information and apply the fixups
|
||||||
//
|
//
|
||||||
@ -639,13 +639,13 @@ PeCoffLoaderRelocateImage (
|
|||||||
} else {
|
} else {
|
||||||
FixupBase = (CHAR8 *)(UINTN)(ImageContext->ImageAddress +
|
FixupBase = (CHAR8 *)(UINTN)(ImageContext->ImageAddress +
|
||||||
RelocBase->VirtualAddress +
|
RelocBase->VirtualAddress +
|
||||||
sizeof(EFI_TE_IMAGE_HEADER) -
|
sizeof(EFI_TE_IMAGE_HEADER) -
|
||||||
Hdr.Te->StrippedSize
|
Hdr.Te->StrippedSize
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((CHAR8 *) RelocEnd < (CHAR8 *) ((UINTN) ImageContext->ImageAddress) ||
|
if ((CHAR8 *) RelocEnd < (CHAR8 *) ((UINTN) ImageContext->ImageAddress) ||
|
||||||
(CHAR8 *) RelocEnd > (CHAR8 *)((UINTN)ImageContext->ImageAddress +
|
(CHAR8 *) RelocEnd > (CHAR8 *)((UINTN)ImageContext->ImageAddress +
|
||||||
(UINTN)ImageContext->ImageSize)) {
|
(UINTN)ImageContext->ImageSize)) {
|
||||||
ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION;
|
ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION;
|
||||||
return RETURN_LOAD_ERROR;
|
return RETURN_LOAD_ERROR;
|
||||||
@ -663,7 +663,7 @@ PeCoffLoaderRelocateImage (
|
|||||||
|
|
||||||
case EFI_IMAGE_REL_BASED_HIGH:
|
case EFI_IMAGE_REL_BASED_HIGH:
|
||||||
F16 = (UINT16 *) Fixup;
|
F16 = (UINT16 *) Fixup;
|
||||||
*F16 = (UINT16) ((*F16 << 16) + (UINT16) Adjust);
|
*F16 = (UINT16) (*F16 + ((UINT16) ((UINT32) Adjust >> 16)));
|
||||||
if (FixupData != NULL) {
|
if (FixupData != NULL) {
|
||||||
*(UINT16 *) FixupData = *F16;
|
*(UINT16 *) FixupData = *F16;
|
||||||
FixupData = FixupData + sizeof (UINT16);
|
FixupData = FixupData + sizeof (UINT16);
|
||||||
@ -852,8 +852,8 @@ PeCoffLoaderLoadImage (
|
|||||||
FirstSection = (EFI_IMAGE_SECTION_HEADER *) (
|
FirstSection = (EFI_IMAGE_SECTION_HEADER *) (
|
||||||
(UINTN)ImageContext->ImageAddress +
|
(UINTN)ImageContext->ImageAddress +
|
||||||
ImageContext->PeCoffHeaderOffset +
|
ImageContext->PeCoffHeaderOffset +
|
||||||
sizeof(UINT32) +
|
sizeof(UINT32) +
|
||||||
sizeof(EFI_IMAGE_FILE_HEADER) +
|
sizeof(EFI_IMAGE_FILE_HEADER) +
|
||||||
Hdr.Pe32->FileHeader.SizeOfOptionalHeader
|
Hdr.Pe32->FileHeader.SizeOfOptionalHeader
|
||||||
);
|
);
|
||||||
NumberOfSections = (UINTN) (Hdr.Pe32->FileHeader.NumberOfSections);
|
NumberOfSections = (UINTN) (Hdr.Pe32->FileHeader.NumberOfSections);
|
||||||
@ -965,7 +965,7 @@ PeCoffLoaderLoadImage (
|
|||||||
if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
|
if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
|
||||||
//
|
//
|
||||||
// Use PE32 offset
|
// Use PE32 offset
|
||||||
//
|
//
|
||||||
ImageContext->EntryPoint = (PHYSICAL_ADDRESS)(UINTN)PeCoffLoaderImageAddress (
|
ImageContext->EntryPoint = (PHYSICAL_ADDRESS)(UINTN)PeCoffLoaderImageAddress (
|
||||||
ImageContext,
|
ImageContext,
|
||||||
(UINTN)Hdr.Pe32->OptionalHeader.AddressOfEntryPoint
|
(UINTN)Hdr.Pe32->OptionalHeader.AddressOfEntryPoint
|
||||||
@ -1009,7 +1009,7 @@ PeCoffLoaderLoadImage (
|
|||||||
NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;
|
NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;
|
||||||
DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];
|
DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {
|
if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {
|
||||||
ImageContext->FixupDataSize = DirectoryEntry->Size / sizeof (UINT16) * sizeof (UINTN);
|
ImageContext->FixupDataSize = DirectoryEntry->Size / sizeof (UINT16) * sizeof (UINTN);
|
||||||
} else {
|
} else {
|
||||||
@ -1124,8 +1124,8 @@ PeCoffLoaderLoadImage (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Reapply fixups on a fixed up PE32/PE32+ image to allow virutal calling at EFI
|
Reapply fixups on a fixed up PE32/PE32+ image to allow virutal calling at EFI
|
||||||
runtime.
|
runtime.
|
||||||
|
|
||||||
PE_COFF_LOADER_IMAGE_CONTEXT.FixupData stores information needed to reapply
|
PE_COFF_LOADER_IMAGE_CONTEXT.FixupData stores information needed to reapply
|
||||||
the fixups with a virtual mapping.
|
the fixups with a virtual mapping.
|
||||||
|
|
||||||
@ -1134,7 +1134,7 @@ PeCoffLoaderLoadImage (
|
|||||||
@param VirtImageBase Virtual mapping for ImageBase
|
@param VirtImageBase Virtual mapping for ImageBase
|
||||||
@param ImageSize Size of the image to relocate
|
@param ImageSize Size of the image to relocate
|
||||||
@param RelocationData Location to place results of read
|
@param RelocationData Location to place results of read
|
||||||
|
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
@ -1196,18 +1196,18 @@ PeCoffLoaderRelocateImageForRuntime (
|
|||||||
// Get some data from the PE type dependent data
|
// Get some data from the PE type dependent data
|
||||||
//
|
//
|
||||||
if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
|
if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
|
||||||
//
|
//
|
||||||
// Use PE32 offset
|
// Use PE32 offset
|
||||||
//
|
//
|
||||||
NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes;
|
NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes;
|
||||||
DataDirectory = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32->OptionalHeader.DataDirectory[0]);
|
DataDirectory = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32->OptionalHeader.DataDirectory[0]);
|
||||||
} else {
|
} else {
|
||||||
//
|
//
|
||||||
// Use PE32+ offset
|
// Use PE32+ offset
|
||||||
//
|
//
|
||||||
NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;
|
NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;
|
||||||
DataDirectory = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[0]);
|
DataDirectory = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Find the relocation block
|
// Find the relocation block
|
||||||
@ -1215,7 +1215,7 @@ PeCoffLoaderRelocateImageForRuntime (
|
|||||||
// Per the PE/COFF spec, you can't assume that a given data directory
|
// Per the PE/COFF spec, you can't assume that a given data directory
|
||||||
// is present in the image. You have to check the NumberOfRvaAndSizes in
|
// is present in the image. You have to check the NumberOfRvaAndSizes in
|
||||||
// the optional header to verify a desired directory entry is there.
|
// the optional header to verify a desired directory entry is there.
|
||||||
//
|
//
|
||||||
if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {
|
if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {
|
||||||
RelocDir = DataDirectory + EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC;
|
RelocDir = DataDirectory + EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC;
|
||||||
RelocBase = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(ImageBase + RelocDir->VirtualAddress);
|
RelocBase = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(ImageBase + RelocDir->VirtualAddress);
|
||||||
@ -1258,7 +1258,7 @@ PeCoffLoaderRelocateImageForRuntime (
|
|||||||
case EFI_IMAGE_REL_BASED_HIGH:
|
case EFI_IMAGE_REL_BASED_HIGH:
|
||||||
F16 = (UINT16 *) Fixup;
|
F16 = (UINT16 *) Fixup;
|
||||||
if (*(UINT16 *) FixupData == *F16) {
|
if (*(UINT16 *) FixupData == *F16) {
|
||||||
*F16 = (UINT16) (*F16 + ((UINT16)(Adjust >> 16)));
|
*F16 = (UINT16) (*F16 + ((UINT16) ((UINT32) Adjust >> 16)));
|
||||||
}
|
}
|
||||||
|
|
||||||
FixupData = FixupData + sizeof (UINT16);
|
FixupData = FixupData + sizeof (UINT16);
|
||||||
@ -1324,14 +1324,14 @@ PeCoffLoaderRelocateImageForRuntime (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
ImageRead function that operates on a memory buffer whos base is passed into
|
ImageRead function that operates on a memory buffer whos base is passed into
|
||||||
FileHandle.
|
FileHandle.
|
||||||
|
|
||||||
@param FileHandle Ponter to baes of the input stream
|
@param FileHandle Ponter to baes of the input stream
|
||||||
@param FileOffset Offset to the start of the buffer
|
@param FileOffset Offset to the start of the buffer
|
||||||
@param ReadSize Number of bytes to copy into the buffer
|
@param ReadSize Number of bytes to copy into the buffer
|
||||||
@param Buffer Location to place results of read
|
@param Buffer Location to place results of read
|
||||||
|
|
||||||
@retval RETURN_SUCCESS Data is read from FileOffset from the Handle into
|
@retval RETURN_SUCCESS Data is read from FileOffset from the Handle into
|
||||||
the buffer.
|
the buffer.
|
||||||
**/
|
**/
|
||||||
RETURN_STATUS
|
RETURN_STATUS
|
||||||
|
@ -643,7 +643,7 @@ Returns:
|
|||||||
|
|
||||||
case EFI_IMAGE_REL_BASED_HIGH:
|
case EFI_IMAGE_REL_BASED_HIGH:
|
||||||
F16 = (UINT16 *) Fixup;
|
F16 = (UINT16 *) Fixup;
|
||||||
*F16 = (UINT16) ((*F16 << 16) + (UINT16) Adjust);
|
*F16 = (UINT16) (*F16 + ((UINT16) ((UINT32) Adjust >> 16)));
|
||||||
if (FixupData != NULL) {
|
if (FixupData != NULL) {
|
||||||
*(UINT16 *) FixupData = *F16;
|
*(UINT16 *) FixupData = *F16;
|
||||||
FixupData = FixupData + sizeof (UINT16);
|
FixupData = FixupData + sizeof (UINT16);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user