DebugMsg (NULL, 0, 9, "rebase address", "%s = %s", EFI_FV_BASE_ADDRESS_STRING, Value);\r
\r
FvInfo->BaseAddress = Value64;\r
+ FvInfo->BaseAddressSet = TRUE;\r
}\r
}\r
\r
// Rebase the PE or TE image in FileBuffer of FFS file for XIP \r
// Rebase for the debug genfvmap tool\r
//\r
- FfsRebase (FvInfo, FvInfo->FvFiles[Index], (EFI_FFS_FILE_HEADER *) FileBuffer, (UINTN) *VtfFileImage - (UINTN) FvImage->FileImage, FvMapFile);\r
+ Status = FfsRebase (FvInfo, FvInfo->FvFiles[Index], (EFI_FFS_FILE_HEADER *) FileBuffer, (UINTN) *VtfFileImage - (UINTN) FvImage->FileImage, FvMapFile);\r
+ if (EFI_ERROR (Status)) {\r
+ Error (NULL, 0, 3000, "Invalid", "Could not rebase %s.", FvInfo->FvFiles[Index]);\r
+ return Status;\r
+ } \r
//\r
// copy VTF File\r
//\r
// Rebase the PE or TE image in FileBuffer of FFS file for XIP. \r
// Rebase Bs and Rt drivers for the debug genfvmap tool.\r
//\r
- FfsRebase (FvInfo, FvInfo->FvFiles[Index], (EFI_FFS_FILE_HEADER *) FileBuffer, (UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage, FvMapFile);\r
+ Status = FfsRebase (FvInfo, FvInfo->FvFiles[Index], (EFI_FFS_FILE_HEADER *) FileBuffer, (UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage, FvMapFile);\r
+ if (EFI_ERROR (Status)) {\r
+ Error (NULL, 0, 3000, "Invalid", "Could not rebase %s.", FvInfo->FvFiles[Index]);\r
+ return Status;\r
+ } \r
//\r
// Copy the file\r
//\r
}\r
\r
// Add opcode for an uncondional branch with no link. AKA B SecEntryPoint\r
- ResetVector[0] |= 0xEA000000;\r
+ ResetVector[0] |= 0xEB000000;\r
\r
\r
// Address of PEI Core, if we have one\r
PeFileBuffer = NULL;\r
\r
//\r
- // Don't need to relocate image when BaseAddress is not set.\r
+ // Don't need to relocate image when BaseAddress is zero and no ForceRebase Flag specified.\r
+ //\r
+ if ((FvInfo->BaseAddress == 0) && (FvInfo->ForceRebase == -1)) {\r
+ return EFI_SUCCESS;\r
+ }\r
+ \r
+ //\r
+ // If ForceRebase Flag specified to FALSE, will always not take rebase action.\r
//\r
- if (FvInfo->BaseAddress == 0) {\r
+ if (FvInfo->ForceRebase == 0) {\r
return EFI_SUCCESS;\r
}\r
+\r
+\r
XipBase = FvInfo->BaseAddress + XipOffset;\r
\r
//\r
return EFI_OUT_OF_RESOURCES;\r
}\r
memset ((VOID *) MemoryImagePointer, 0, (UINTN) ImageContext.ImageSize + ImageContext.SectionAlignment);\r
- ImageContext.ImageAddress = ((UINTN) MemoryImagePointer + ImageContext.SectionAlignment - 1) & (~((INT64)ImageContext.SectionAlignment - 1));\r
+ ImageContext.ImageAddress = ((UINTN) MemoryImagePointer + ImageContext.SectionAlignment - 1) & (~((UINTN) ImageContext.SectionAlignment - 1));\r
\r
Status = PeCoffLoaderLoadImage (&ImageContext);\r
if (EFI_ERROR (Status)) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
memset ((VOID *) MemoryImagePointer, 0, (UINTN) ImageContext.ImageSize + ImageContext.SectionAlignment);\r
- ImageContext.ImageAddress = ((UINTN) MemoryImagePointer + ImageContext.SectionAlignment - 1) & (~(ImageContext.SectionAlignment - 1));\r
+ ImageContext.ImageAddress = ((UINTN) MemoryImagePointer + ImageContext.SectionAlignment - 1) & (~((UINTN) ImageContext.SectionAlignment - 1));\r
\r
Status = PeCoffLoaderLoadImage (&ImageContext);\r
if (EFI_ERROR (Status)) {\r