\r
Functions to get info and load PE/COFF image.\r
\r
-Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
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
}\r
\r
//\r
- // If the destination address is not 0, use that rather than the\r
- // image address as the relocation target.\r
+ // Use DestinationAddress field of ImageContext as the relocation address even if it is 0.\r
//\r
- if (ImageContext->DestinationAddress) {\r
- BaseAddress = ImageContext->DestinationAddress;\r
- } else {\r
- BaseAddress = ImageContext->ImageAddress;\r
- }\r
-\r
+ BaseAddress = ImageContext->DestinationAddress;\r
+ \r
if (!(ImageContext->IsTeImage)) {\r
PeHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)((UINTN)ImageContext->ImageAddress + \r
ImageContext->PeCoffHeaderOffset);\r
ImageContext,\r
Section->VirtualAddress + Section->Misc.VirtualSize - 1\r
);\r
+ //\r
+ // If the base start or end address resolved to 0, then fail.\r
+ //\r
+ if ((Base == NULL) || (End == NULL)) {\r
+ ImageContext->ImageError = IMAGE_ERROR_SECTION_NOT_LOADED;\r
+ return RETURN_LOAD_ERROR;\r
+ }\r
+\r
if (ImageContext->IsTeImage) {\r
Base = (CHAR8 *) ((UINTN) Base + sizeof (EFI_TE_IMAGE_HEADER) - (UINTN) TeHdr->StrippedSize);\r
End = (CHAR8 *) ((UINTN) End + sizeof (EFI_TE_IMAGE_HEADER) - (UINTN) TeHdr->StrippedSize);\r
if (End > MaxEnd) {\r
MaxEnd = End;\r
}\r
- //\r
- // If the base start or end address resolved to 0, then fail.\r
- //\r
- if ((Base == NULL) || (End == NULL)) {\r
- ImageContext->ImageError = IMAGE_ERROR_SECTION_NOT_LOADED;\r
- return RETURN_LOAD_ERROR;\r
- }\r
\r
//\r
// Read the section\r