Revision: 17942
http://sourceforge.net/p/edk2/code/17942
Author: abiesheuvel
Date: 2015-07-14 08:15:28 +0000 (Tue, 14 Jul 2015)
Log Message:
-----------
BaseTools/PeCoffLib: handle EFI_IMAGE_REL_BASED_DIR64 in generic code
Relocations of type EFI_IMAGE_REL_BASED_DIR64 are handled in exactly
the same way on all 64-bit machine types (IPF, X64 and AARCH64).
So move the handling of this type to the generic part of the relocation
routine PeCoffLoaderRelocateImage ().
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <[email protected]>
Reviewed-by: Liming Gao <[email protected]>
Reviewed-by: Yingke Liu <[email protected]>
Modified Paths:
--------------
trunk/edk2/BaseTools/Source/C/Common/BasePeCoff.c
trunk/edk2/BaseTools/Source/C/Common/PeCoffLoaderEx.c
Modified: trunk/edk2/BaseTools/Source/C/Common/BasePeCoff.c
===================================================================
--- trunk/edk2/BaseTools/Source/C/Common/BasePeCoff.c 2015-07-14 04:02:35 UTC
(rev 17941)
+++ trunk/edk2/BaseTools/Source/C/Common/BasePeCoff.c 2015-07-14 08:15:28 UTC
(rev 17942)
@@ -57,14 +57,6 @@
);
RETURN_STATUS
-PeCoffLoaderRelocateX64Image (
- IN UINT16 *Reloc,
- IN OUT CHAR8 *Fixup,
- IN OUT CHAR8 **FixupData,
- IN UINT64 Adjust
- );
-
-RETURN_STATUS
PeCoffLoaderRelocateIpfImage (
IN UINT16 *Reloc,
IN OUT CHAR8 *Fixup,
@@ -80,14 +72,6 @@
IN UINT64 Adjust
);
-RETURN_STATUS
-PeCoffLoaderRelocateAArch64Image (
- IN UINT16 *Reloc,
- IN OUT CHAR8 *Fixup,
- IN OUT CHAR8 **FixupData,
- IN UINT64 Adjust
- );
-
STATIC
RETURN_STATUS
PeCoffLoaderGetPeHeader (
@@ -619,6 +603,7 @@
CHAR8 *FixupBase;
UINT16 *F16;
UINT32 *F32;
+ UINT64 *F64;
CHAR8 *FixupData;
PHYSICAL_ADDRESS BaseAddress;
UINT16 MachineType;
@@ -778,6 +763,16 @@
}
break;
+ case EFI_IMAGE_REL_BASED_DIR64:
+ F64 = (UINT64 *) Fixup;
+ *F64 = *F64 + (UINT64) Adjust;
+ if (FixupData != NULL) {
+ FixupData = ALIGN_POINTER (FixupData, sizeof (UINT64));
+ *(UINT64 *) FixupData = *F64;
+ FixupData = FixupData + sizeof (UINT64);
+ }
+ break;
+
case EFI_IMAGE_REL_BASED_HIGHADJ:
//
// Return the same EFI_UNSUPPORTED return code as
@@ -795,15 +790,9 @@
case EFI_IMAGE_MACHINE_ARMT:
Status = PeCoffLoaderRelocateArmImage (&Reloc, Fixup, &FixupData,
Adjust);
break;
- case EFI_IMAGE_MACHINE_X64:
- Status = PeCoffLoaderRelocateX64Image (Reloc, Fixup, &FixupData,
Adjust);
- break;
case EFI_IMAGE_MACHINE_IA64:
Status = PeCoffLoaderRelocateIpfImage (Reloc, Fixup, &FixupData,
Adjust);
break;
- case EFI_IMAGE_MACHINE_AARCH64:
- Status = PeCoffLoaderRelocateAArch64Image (Reloc, Fixup, &FixupData,
Adjust);
- break;
default:
Status = RETURN_UNSUPPORTED;
break;
Modified: trunk/edk2/BaseTools/Source/C/Common/PeCoffLoaderEx.c
===================================================================
--- trunk/edk2/BaseTools/Source/C/Common/PeCoffLoaderEx.c 2015-07-14
04:02:35 UTC (rev 17941)
+++ trunk/edk2/BaseTools/Source/C/Common/PeCoffLoaderEx.c 2015-07-14
08:15:28 UTC (rev 17942)
@@ -133,16 +133,6 @@
switch ((*Reloc) >> 12) {
- case EFI_IMAGE_REL_BASED_DIR64:
- F64 = (UINT64 *) Fixup;
- *F64 = *F64 + (UINT64) Adjust;
- if (*FixupData != NULL) {
- *FixupData = ALIGN_POINTER(*FixupData, sizeof(UINT64));
- *(UINT64 *)(*FixupData) = *F64;
- *FixupData = *FixupData + sizeof(UINT64);
- }
- break;
-
case EFI_IMAGE_REL_BASED_IA64_IMM64:
//
@@ -270,47 +260,7 @@
return RETURN_SUCCESS;
}
-RETURN_STATUS
-PeCoffLoaderRelocateX64Image (
- IN UINT16 *Reloc,
- IN OUT CHAR8 *Fixup,
- IN OUT CHAR8 **FixupData,
- IN UINT64 Adjust
- )
/**
- Performs an x64 specific relocation fixup
-
- @param Reloc Pointer to the relocation record
- @param Fixup Pointer to the address to fix up
- @param FixupData Pointer to a buffer to log the fixups
- @param Adjust The offset to adjust the fixup
-
- @retval RETURN_SUCCESS Success to perform relocation
- @retval RETURN_UNSUPPORTED Unsupported.
-**/
-{
- UINT64 *F64;
-
- switch ((*Reloc) >> 12) {
-
- case EFI_IMAGE_REL_BASED_DIR64:
- F64 = (UINT64 *) Fixup;
- *F64 = *F64 + (UINT64) Adjust;
- if (*FixupData != NULL) {
- *FixupData = ALIGN_POINTER(*FixupData, sizeof(UINT64));
- *(UINT64 *)(*FixupData) = *F64;
- *FixupData = *FixupData + sizeof(UINT64);
- }
- break;
-
- default:
- return RETURN_UNSUPPORTED;
- }
-
- return RETURN_SUCCESS;
-}
-
-/**
Pass in a pointer to an ARM MOVT or MOVW immediate instruciton and
return the immediate data encoded in the instruction
@@ -465,43 +415,3 @@
return RETURN_SUCCESS;
}
-
-RETURN_STATUS
-PeCoffLoaderRelocateAArch64Image (
- IN UINT16 *Reloc,
- IN OUT CHAR8 *Fixup,
- IN OUT CHAR8 **FixupData,
- IN UINT64 Adjust
- )
-/**
- Performs an AArch64 specific relocation fixup
-
- @param Reloc Pointer to the relocation record
- @param Fixup Pointer to the address to fix up
- @param FixupData Pointer to a buffer to log the fixups
- @param Adjust The offset to adjust the fixup
-
- @retval RETURN_SUCCESS Success to perform relocation
- @retval RETURN_UNSUPPORTED Unsupported.
-**/
-{
- UINT64 *F64;
-
- switch ((*Reloc) >> 12) {
-
- case EFI_IMAGE_REL_BASED_DIR64:
- F64 = (UINT64 *) Fixup;
- *F64 = *F64 + (UINT64) Adjust;
- if (*FixupData != NULL) {
- *FixupData = ALIGN_POINTER(*FixupData, sizeof(UINT64));
- *(UINT64 *)(*FixupData) = *F64;
- *FixupData = *FixupData + sizeof(UINT64);
- }
- break;
-
- default:
- return RETURN_UNSUPPORTED;
- }
-
- return RETURN_SUCCESS;
-}
------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits