mirror of https://github.com/acidanthera/audk.git
BaseTools/PeCoffLib: Check 'RelocDir' before finding relocation block
To match the code logics in MdePkg/Library/BasePeCoffLib, add checks for 'RelocDir' before finding the relocation block. Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
parent
14e8137c82
commit
49d8f534cc
|
@ -645,6 +645,7 @@ Returns:
|
|||
//
|
||||
if (OptionHeader.Optional32->NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {
|
||||
RelocDir = &OptionHeader.Optional32->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];
|
||||
if ((RelocDir != NULL) && (RelocDir->Size > 0)) {
|
||||
RelocBase = PeCoffLoaderImageAddress (ImageContext, RelocDir->VirtualAddress);
|
||||
RelocBaseEnd = PeCoffLoaderImageAddress (
|
||||
ImageContext,
|
||||
|
@ -660,6 +661,12 @@ Returns:
|
|||
//
|
||||
RelocBase = RelocBaseEnd = 0;
|
||||
}
|
||||
} else {
|
||||
//
|
||||
// Set base and end to bypass processing below.
|
||||
//
|
||||
RelocBase = RelocBaseEnd = 0;
|
||||
}
|
||||
} else {
|
||||
Adjust = (UINT64) BaseAddress - OptionHeader.Optional64->ImageBase;
|
||||
OptionHeader.Optional64->ImageBase = BaseAddress;
|
||||
|
@ -673,6 +680,7 @@ Returns:
|
|||
//
|
||||
if (OptionHeader.Optional64->NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {
|
||||
RelocDir = &OptionHeader.Optional64->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];
|
||||
if ((RelocDir != NULL) && (RelocDir->Size > 0)) {
|
||||
RelocBase = PeCoffLoaderImageAddress (ImageContext, RelocDir->VirtualAddress);
|
||||
RelocBaseEnd = PeCoffLoaderImageAddress (
|
||||
ImageContext,
|
||||
|
@ -688,6 +696,12 @@ Returns:
|
|||
//
|
||||
RelocBase = RelocBaseEnd = 0;
|
||||
}
|
||||
} else {
|
||||
//
|
||||
// Set base and end to bypass processing below.
|
||||
//
|
||||
RelocBase = RelocBaseEnd = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
TeHdr = (EFI_TE_IMAGE_HEADER *) (UINTN) (ImageContext->ImageAddress);
|
||||
|
|
Loading…
Reference in New Issue