MdePkg/BasePeCoffLib2: Fix ARM Thumb apply relocation routine

Thumb instructions are either 16-bit or 32-bit, and are aligned on
a two-byte boundary

Signed-off-by: Savva Mitrofanov <savvamtr@gmail.com>
This commit is contained in:
Mikhail Krichanov 2023-03-17 12:13:27 +03:00 committed by Marvin Häuser
parent a07a2ce546
commit 60e0471175

View File

@ -195,7 +195,7 @@ ThumbMovwMovtImmediatePatch (
STATIC
VOID
ThumbMovwMovtImmediateFixup (
IN OUT VOID *Fixup,
IN OUT VOID *Instructions,
IN UINT64 Adjust
)
{
@ -203,8 +203,8 @@ ThumbMovwMovtImmediateFixup (
//
// Relocate the instruction pair.
//
Fixup32 = ThumbMovwMovtImmediateAddress (Fixup) + (UINT32) Adjust;
ThumbMovwMovtImmediatePatch (Fixup, Fixup32);
Fixup32 = ThumbMovwMovtImmediateAddress (Instructions) + (UINT32) Adjust;
ThumbMovwMovtImmediatePatch (Instructions, Fixup32);
}
/**
@ -379,9 +379,9 @@ InternalApplyRelocation (
}
//
// Verify the Base Relocation target is sufficiently aligned.
// The ARM THunb instruction pait must start on a 32-bit boundary.
// The ARM Thumb instruction pair must start on a 16-bit boundary.
//
if (!IS_ALIGNED (RelocTargetRva, ALIGNOF (UINT32))) {
if (!IS_ALIGNED (RelocTargetRva, ALIGNOF (UINT16))) {
DEBUG_RAISE ();
return RETURN_VOLUME_CORRUPTED;
}