diff --git a/MdePkg/Library/BasePeCoffLib2/PeCoffRelocate.c b/MdePkg/Library/BasePeCoffLib2/PeCoffRelocate.c index 39a2b26dff..8c91496e28 100644 --- a/MdePkg/Library/BasePeCoffLib2/PeCoffRelocate.c +++ b/MdePkg/Library/BasePeCoffLib2/PeCoffRelocate.c @@ -438,6 +438,13 @@ PeCoffRelocateImage ( ASSERT (RuntimeContext != NULL || RuntimeContextSize == 0); ASSERT (RuntimeContext == NULL || RuntimeContextSize >= sizeof (PE_COFF_LOADER_RUNTIME_CONTEXT) + Context->RelocDirSize * (sizeof (UINT64) / sizeof (UINT16))); // + // Initialise the Image runtime context header. + // + if (RuntimeContext != NULL) { + RuntimeContext->RelocDirRva = Context->RelocDirRva; + RuntimeContext->RelocDirSize = Context->RelocDirSize; + } + // // Verify the Relocation Directory is not empty. // if (Context->RelocDirSize == 0) { @@ -458,13 +465,6 @@ PeCoffRelocateImage ( if (RuntimeContext == NULL && Adjust == 0) { return RETURN_SUCCESS; } - // - // Initialise the Image runtime context header. - // - if (RuntimeContext != NULL) { - RuntimeContext->RelocDirRva = Context->RelocDirRva; - RuntimeContext->RelocDirSize = Context->RelocDirSize; - } RelocBlockOffset = Context->RelocDirRva; TopOfRelocDir = Context->RelocDirRva + Context->RelocDirSize;