Base PE/COFF loader supports loading any PE32/PE32+ or TE image, but\r
only supports relocating IA32, x64, IPF, and EBC images.\r
\r
- Copyright (c) 2006 - 2008, Intel Corporation\r
+ Copyright (c) 2006 - 2008, Intel Corporation<BR>\r
+ Portions copyright (c) 2008-2009 Apple Inc. All rights reserved.<BR>\r
All rights reserved. This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
UINT16 Magic;\r
\r
//\r
- // Read the DOS image header to check for it's existance\r
+ // Read the DOS image header to check for its existence\r
//\r
Size = sizeof (EFI_IMAGE_DOS_HEADER);\r
Status = ImageContext->ImageRead (\r
ImageContext->DestinationAddress = 0;\r
\r
//\r
- // Initialize the codeview pointer.\r
+ // Initialize the debug codeview pointer.\r
//\r
- ImageContext->CodeView = NULL;\r
- ImageContext->PdbPointer = NULL;\r
+ ImageContext->DebugDirectoryEntryRva = 0;\r
+ ImageContext->CodeView = NULL;\r
+ ImageContext->PdbPointer = NULL;\r
\r
//\r
// Three cases with regards to relocations:\r
\r
If ImageContext is NULL, then ASSERT().\r
\r
+ Note that if the platform does not maintain coherency between the instruction cache(s) and the data\r
+ cache(s) in hardware, then the caller is responsible for performing cache maintenance operations\r
+ prior to transferring control to a PE/COFF image that is loaded using this library.\r
+\r
@param ImageContext Pointer to the image context structure that describes the PE/COFF\r
image that is being relocated.\r
\r
if (ImageContext->RelocationsStripped) {\r
// Applies additional environment specific actions to relocate fixups \r
// to a PE/COFF image if needed\r
- PeCoffLoaderRelocateImageExtraAction (ImageContext); \r
+ PeCoffLoaderRelocateImageExtraAction (ImageContext); \r
return RETURN_SUCCESS;\r
}\r
\r
\r
If ImageContext is NULL, then ASSERT().\r
\r
+ Note that if the platform does not maintain coherency between the instruction cache(s) and the data\r
+ cache(s) in hardware, then the caller is responsible for performing cache maintenance operations\r
+ prior to transferring control to a PE/COFF image that is loaded using this library.\r
+\r
@param ImageContext Pointer to the image context structure that describes the PE/COFF\r
image that is being loaded.\r
\r
ImageContext->PdbPointer = (CHAR8 *)ImageContext->CodeView + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY);\r
break;\r
\r
+ case CODEVIEW_SIGNATURE_MTOC:\r
+ ImageContext->PdbPointer = (CHAR8 *)ImageContext->CodeView + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_MTOC_ENTRY);\r
+ break;\r
+\r
default:\r
break;\r
}\r
\r
if (DirectoryEntry->Size != 0) {\r
Base = PeCoffLoaderImageAddress (ImageContext, DirectoryEntry->VirtualAddress);\r
-\r
- ResourceDirectory = (EFI_IMAGE_RESOURCE_DIRECTORY *) Base;\r
- ResourceDirectoryEntry = (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *) (ResourceDirectory + 1);\r
-\r
- for (Index = 0; Index < ResourceDirectory->NumberOfNamedEntries; Index++) {\r
- if (ResourceDirectoryEntry->u1.s.NameIsString) {\r
- ResourceDirectoryString = (EFI_IMAGE_RESOURCE_DIRECTORY_STRING *) (Base + ResourceDirectoryEntry->u1.s.NameOffset);\r
-\r
- if (ResourceDirectoryString->Length == 3 &&\r
- ResourceDirectoryString->String[0] == L'H' &&\r
- ResourceDirectoryString->String[1] == L'I' &&\r
- ResourceDirectoryString->String[2] == L'I') {\r
- //\r
- // Resource Type "HII" found\r
- //\r
- if (ResourceDirectoryEntry->u2.s.DataIsDirectory) {\r
+ if (Base != NULL) {\r
+ ResourceDirectory = (EFI_IMAGE_RESOURCE_DIRECTORY *) Base;\r
+ ResourceDirectoryEntry = (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *) (ResourceDirectory + 1);\r
+\r
+ for (Index = 0; Index < ResourceDirectory->NumberOfNamedEntries; Index++) {\r
+ if (ResourceDirectoryEntry->u1.s.NameIsString) {\r
+ ResourceDirectoryString = (EFI_IMAGE_RESOURCE_DIRECTORY_STRING *) (Base + ResourceDirectoryEntry->u1.s.NameOffset);\r
+\r
+ if (ResourceDirectoryString->Length == 3 &&\r
+ ResourceDirectoryString->String[0] == L'H' &&\r
+ ResourceDirectoryString->String[1] == L'I' &&\r
+ ResourceDirectoryString->String[2] == L'I') {\r
//\r
- // Move to next level - resource Name\r
+ // Resource Type "HII" found\r
//\r
- ResourceDirectory = (EFI_IMAGE_RESOURCE_DIRECTORY *) (Base + ResourceDirectoryEntry->u2.s.OffsetToDirectory);\r
- ResourceDirectoryEntry = (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *) (ResourceDirectory + 1);\r
-\r
if (ResourceDirectoryEntry->u2.s.DataIsDirectory) {\r
//\r
- // Move to next level - resource Language\r
+ // Move to next level - resource Name\r
//\r
ResourceDirectory = (EFI_IMAGE_RESOURCE_DIRECTORY *) (Base + ResourceDirectoryEntry->u2.s.OffsetToDirectory);\r
ResourceDirectoryEntry = (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *) (ResourceDirectory + 1);\r
+\r
+ if (ResourceDirectoryEntry->u2.s.DataIsDirectory) {\r
+ //\r
+ // Move to next level - resource Language\r
+ //\r
+ ResourceDirectory = (EFI_IMAGE_RESOURCE_DIRECTORY *) (Base + ResourceDirectoryEntry->u2.s.OffsetToDirectory);\r
+ ResourceDirectoryEntry = (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *) (ResourceDirectory + 1);\r
+ }\r
}\r
- }\r
\r
- //\r
- // Now it ought to be resource Data\r
- //\r
- if (!ResourceDirectoryEntry->u2.s.DataIsDirectory) {\r
- ResourceDataEntry = (EFI_IMAGE_RESOURCE_DATA_ENTRY *) (Base + ResourceDirectoryEntry->u2.OffsetToData);\r
- ImageContext->HiiResourceData = (PHYSICAL_ADDRESS) (UINTN) PeCoffLoaderImageAddress (ImageContext, ResourceDataEntry->OffsetToData);\r
- break;\r
+ //\r
+ // Now it ought to be resource Data\r
+ //\r
+ if (!ResourceDirectoryEntry->u2.s.DataIsDirectory) {\r
+ ResourceDataEntry = (EFI_IMAGE_RESOURCE_DATA_ENTRY *) (Base + ResourceDirectoryEntry->u2.OffsetToData);\r
+ ImageContext->HiiResourceData = (PHYSICAL_ADDRESS) (UINTN) PeCoffLoaderImageAddress (ImageContext, ResourceDataEntry->OffsetToData);\r
+ break;\r
+ }\r
}\r
}\r
+ ResourceDirectoryEntry++;\r
}\r
-\r
- ResourceDirectoryEntry++;\r
}\r
}\r
}\r
to the FiuxupData buffer from the PE_COFF_LOADER_IMAGE_CONTEXT structure \r
after this PE/COFF image was relocated with PeCoffLoaderRelocateImage().\r
\r
+ Note that if the platform does not maintain coherency between the instruction cache(s) and the data\r
+ cache(s) in hardware, then the caller is responsible for performing cache maintenance operations\r
+ prior to transferring control to a PE/COFF image that is loaded using this library.\r
+\r
@param ImageBase Base address of a PE/COFF image that has been loaded \r
and relocated into system memory.\r
@param VirtImageBase The request virtual address that the PE/COFF image is to\r