MdePkg/PeCoffLib2: Expose ARM Thumb MOVW/MOVT relocation helpers

This commit is contained in:
Marvin Häuser 2023-04-16 18:26:50 +02:00 committed by Mikhail Krichanov
parent fff229d0cb
commit a8f69bde96
2 changed files with 29 additions and 14 deletions

View File

@ -564,4 +564,28 @@ PeCoffLoaderGetImageAddress (
IN CONST PE_COFF_LOADER_IMAGE_CONTEXT *Context
);
/**
Retrieve the immediate data encoded in an ARM MOVW/MOVT instruciton pair.
@param[in] Instructions Pointer to an ARM MOVW/MOVT insturction pair.
@returns The Immediate address encoded in the instructions.
**/
UINT32
PeCoffThumbMovwMovtImmediateAddress (
IN CONST VOID *Instructions
);
/**
Relocate an ARM MOVW/MOVT immediate instruction instruction pair.
@param[in,out] Instructions Pointer to ARM MOVW/MOVT instruction pair.
@param[in] Adjust The delta to add to the addresses.
**/
VOID
PeCoffThumbMovwMovtImmediateFixup (
IN OUT VOID *Instructions,
IN UINT64 Adjust
);
#endif // PE_COFF_LIB2_H_

View File

@ -137,16 +137,8 @@ ThumbMovtImmediatePatch (
(PatchedInstruction & ~(UINT16) 0x70FFU) | Patch;
}
/**
Retrieve the immediate data encoded in an ARM MOVW/MOVT instruciton pair.
@param[in] Instructions Pointer to an ARM MOVW/MOVT insturction pair.
@returns The Immediate address encoded in the instructions.
**/
STATIC
UINT32
ThumbMovwMovtImmediateAddress (
PeCoffThumbMovwMovtImmediateAddress (
IN CONST VOID *Instructions
)
{
@ -192,9 +184,8 @@ ThumbMovwMovtImmediatePatch (
@param[in,out] Instructions Pointer to ARM MOVW/MOVT instruction pair.
@param[in] Adjust The delta to add to the addresses.
**/
STATIC
VOID
ThumbMovwMovtImmediateFixup (
PeCoffThumbMovwMovtImmediateFixup (
IN OUT VOID *Instructions,
IN UINT64 Adjust
)
@ -203,7 +194,7 @@ ThumbMovwMovtImmediateFixup (
//
// Relocate the instruction pair.
//
Fixup32 = ThumbMovwMovtImmediateAddress (Instructions) + (UINT32) Adjust;
Fixup32 = PeCoffThumbMovwMovtImmediateAddress (Instructions) + (UINT32) Adjust;
ThumbMovwMovtImmediatePatch (Instructions, Fixup32);
}
@ -396,7 +387,7 @@ InternalApplyRelocation (
//
// Relocate the target instruction.
//
ThumbMovwMovtImmediateFixup (Fixup, Adjust);
PeCoffThumbMovwMovtImmediateFixup (Fixup, Adjust);
//
// Record the relocated value for Image runtime relocation.
//
@ -715,7 +706,7 @@ InternalApplyRelocationRuntime (
return RETURN_VOLUME_CORRUPTED;
}
ThumbMovwMovtImmediateFixup (Fixup, Adjust);
PeCoffThumbMovwMovtImmediateFixup (Fixup, Adjust);
break;