diff options
Diffstat (limited to 'MdePkg/Library/BasePeCoffLib/Arm/PeCoffLoaderEx.c')
-rw-r--r-- | MdePkg/Library/BasePeCoffLib/Arm/PeCoffLoaderEx.c | 44 |
1 files changed, 19 insertions, 25 deletions
diff --git a/MdePkg/Library/BasePeCoffLib/Arm/PeCoffLoaderEx.c b/MdePkg/Library/BasePeCoffLib/Arm/PeCoffLoaderEx.c index 75e89fc10572..21525c05dcae 100644 --- a/MdePkg/Library/BasePeCoffLib/Arm/PeCoffLoaderEx.c +++ b/MdePkg/Library/BasePeCoffLib/Arm/PeCoffLoaderEx.c @@ -1,15 +1,9 @@ /** @file Specific relocation fixups for ARM architecture. - Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR> + Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR> Portions copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR> - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -18,7 +12,7 @@ /** - Pass in a pointer to an ARM MOVT or MOVW immediate instruciton and + Pass in a pointer to an ARM MOVT or MOVW immediate instruciton and return the immediate data encoded in the instruction. @param Instruction Pointer to ARM MOVT or MOVW immediate instruction @@ -33,10 +27,10 @@ ThumbMovtImmediateAddress ( { UINT32 Movt; UINT16 Address; - + // Thumb2 is two 16-bit instructions working together. Not a single 32-bit instruction // Example MOVT R0, #0 is 0x0000f2c0 or 0xf2c0 0x0000 - Movt = (*Instruction << 16) | (*(Instruction + 1)); + Movt = (*Instruction << 16) | (*(Instruction + 1)); // imm16 = imm4:i:imm3:imm8 // imm4 -> Bit19:Bit16 @@ -65,7 +59,7 @@ ThumbMovtImmediatePatch ( UINT16 Patch; // First 16-bit chunk of instruciton - Patch = ((Address >> 12) & 0x000f); // imm4 + Patch = ((Address >> 12) & 0x000f); // imm4 Patch |= (((Address & BIT11) != 0) ? BIT10 : 0); // i // Mask out instruction bits and or in address *(Instruction) = (*Instruction & ~0x040f) | Patch; @@ -81,7 +75,7 @@ ThumbMovtImmediatePatch ( /** - Pass in a pointer to an ARM MOVW/MOVT instruciton pair and + Pass in a pointer to an ARM MOVW/MOVT instruciton pair and return the immediate data encoded in the two` instruction. @param Instructions Pointer to ARM MOVW/MOVT insturction pair @@ -96,10 +90,10 @@ ThumbMovwMovtImmediateAddress ( { UINT16 *Word; UINT16 *Top; - + Word = Instructions; // MOVW Top = Word + 2; // MOVT - + return (ThumbMovtImmediateAddress (Top) << 16) + ThumbMovtImmediateAddress (Word); } @@ -118,15 +112,15 @@ ThumbMovwMovtImmediatePatch ( { UINT16 *Word; UINT16 *Top; - + Word = Instructions; // MOVW Top = Word + 2; // MOVT ThumbMovtImmediatePatch (Word, (UINT16)(Address & 0xffff)); ThumbMovtImmediatePatch (Top, (UINT16)(Address >> 16)); } - - + + /** Performs an ARM-based specific relocation fixup and is a no-op on other @@ -154,19 +148,19 @@ PeCoffLoaderRelocateImageEx ( Fixup16 = (UINT16 *) Fixup; switch ((*Reloc) >> 12) { - + case EFI_IMAGE_REL_BASED_ARM_MOV32T: FixupVal = ThumbMovwMovtImmediateAddress (Fixup16) + (UINT32)Adjust; ThumbMovwMovtImmediatePatch (Fixup16, FixupVal); if (*FixupData != NULL) { *FixupData = ALIGN_POINTER(*FixupData, sizeof(UINT64)); - // Fixup16 is not aligned so we must copy it. Thumb instructions are streams of 16 bytes. + // Fixup16 is not aligned so we must copy it. Thumb instructions are streams of 16 bytes. CopyMem (*FixupData, Fixup16, sizeof (UINT64)); *FixupData = *FixupData + sizeof(UINT64); } break; - + case EFI_IMAGE_REL_BASED_ARM_MOV32A: ASSERT (FALSE); // break omitted - ARM instruction encoding not implemented @@ -182,7 +176,7 @@ PeCoffLoaderRelocateImageEx ( does not mean the image can be executed it means the PE/COFF loader supports loading and relocating of the image type. It's up to the caller to support the entry point. - + @param Machine Machine type from the PE Header. @return TRUE if this PE/COFF loader can load the image @@ -194,7 +188,7 @@ PeCoffLoaderImageFormatSupported ( ) { if ((Machine == IMAGE_FILE_MACHINE_ARMTHUMB_MIXED) || (Machine == IMAGE_FILE_MACHINE_EBC)) { - return TRUE; + return TRUE; } return FALSE; @@ -236,7 +230,7 @@ PeHotRelocateImageEx ( } *FixupData = *FixupData + sizeof(UINT64); break; - + case EFI_IMAGE_REL_BASED_ARM_MOV32A: ASSERT (FALSE); // break omitted - ARM instruction encoding not implemented @@ -244,7 +238,7 @@ PeHotRelocateImageEx ( DEBUG ((EFI_D_ERROR, "PeHotRelocateEx:unknown fixed type\n")); return RETURN_UNSUPPORTED; } - + return RETURN_SUCCESS; } |