Fix ECC issue

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6214 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
klu2 2008-10-24 06:51:40 +00:00
parent 44b013bd6e
commit 1fa524e97d
2 changed files with 84 additions and 84 deletions

View File

@ -514,9 +514,9 @@ PeCoffLoaderRelocateImage (
UINT16 *RelocEnd; UINT16 *RelocEnd;
CHAR8 *Fixup; CHAR8 *Fixup;
CHAR8 *FixupBase; CHAR8 *FixupBase;
UINT16 *F16; UINT16 *Fixup16;
UINT32 *F32; UINT32 *Fixup32;
UINT64 *F64; UINT64 *Fixup64;
CHAR8 *FixupData; CHAR8 *FixupData;
PHYSICAL_ADDRESS BaseAddress; PHYSICAL_ADDRESS BaseAddress;
UINT32 NumberOfRvaAndSizes; UINT32 NumberOfRvaAndSizes;
@ -644,39 +644,39 @@ PeCoffLoaderRelocateImage (
break; break;
case EFI_IMAGE_REL_BASED_HIGH: case EFI_IMAGE_REL_BASED_HIGH:
F16 = (UINT16 *) Fixup; Fixup16 = (UINT16 *) Fixup;
*F16 = (UINT16) (*F16 + ((UINT16) ((UINT32) Adjust >> 16))); *Fixup16 = (UINT16) (*Fixup16 + ((UINT16) ((UINT32) Adjust >> 16)));
if (FixupData != NULL) { if (FixupData != NULL) {
*(UINT16 *) FixupData = *F16; *(UINT16 *) FixupData = *Fixup16;
FixupData = FixupData + sizeof (UINT16); FixupData = FixupData + sizeof (UINT16);
} }
break; break;
case EFI_IMAGE_REL_BASED_LOW: case EFI_IMAGE_REL_BASED_LOW:
F16 = (UINT16 *) Fixup; Fixup16 = (UINT16 *) Fixup;
*F16 = (UINT16) (*F16 + (UINT16) Adjust); *Fixup16 = (UINT16) (*Fixup16 + (UINT16) Adjust);
if (FixupData != NULL) { if (FixupData != NULL) {
*(UINT16 *) FixupData = *F16; *(UINT16 *) FixupData = *Fixup16;
FixupData = FixupData + sizeof (UINT16); FixupData = FixupData + sizeof (UINT16);
} }
break; break;
case EFI_IMAGE_REL_BASED_HIGHLOW: case EFI_IMAGE_REL_BASED_HIGHLOW:
F32 = (UINT32 *) Fixup; Fixup32 = (UINT32 *) Fixup;
*F32 = *F32 + (UINT32) Adjust; *Fixup32 = *Fixup32 + (UINT32) Adjust;
if (FixupData != NULL) { if (FixupData != NULL) {
FixupData = ALIGN_POINTER (FixupData, sizeof (UINT32)); FixupData = ALIGN_POINTER (FixupData, sizeof (UINT32));
*(UINT32 *)FixupData = *F32; *(UINT32 *)FixupData = *Fixup32;
FixupData = FixupData + sizeof (UINT32); FixupData = FixupData + sizeof (UINT32);
} }
break; break;
case EFI_IMAGE_REL_BASED_DIR64: case EFI_IMAGE_REL_BASED_DIR64:
F64 = (UINT64 *) Fixup; Fixup64 = (UINT64 *) Fixup;
*F64 = *F64 + (UINT64) Adjust; *Fixup64 = *Fixup64 + (UINT64) Adjust;
if (FixupData != NULL) { if (FixupData != NULL) {
FixupData = ALIGN_POINTER (FixupData, sizeof(UINT64)); FixupData = ALIGN_POINTER (FixupData, sizeof(UINT64));
*(UINT64 *)(FixupData) = *F64; *(UINT64 *)(FixupData) = *Fixup64;
FixupData = FixupData + sizeof(UINT64); FixupData = FixupData + sizeof(UINT64);
} }
break; break;
@ -1149,9 +1149,9 @@ PeCoffLoaderRelocateImageForRuntime (
UINT16 *RelocEnd; UINT16 *RelocEnd;
CHAR8 *Fixup; CHAR8 *Fixup;
CHAR8 *FixupBase; CHAR8 *FixupBase;
UINT16 *F16; UINT16 *Fixup16;
UINT32 *F32; UINT32 *Fixup32;
UINT64 *F64; UINT64 *Fixup64;
CHAR8 *FixupData; CHAR8 *FixupData;
UINTN Adjust; UINTN Adjust;
RETURN_STATUS Status; RETURN_STATUS Status;
@ -1250,38 +1250,38 @@ PeCoffLoaderRelocateImageForRuntime (
break; break;
case EFI_IMAGE_REL_BASED_HIGH: case EFI_IMAGE_REL_BASED_HIGH:
F16 = (UINT16 *) Fixup; Fixup16 = (UINT16 *) Fixup;
if (*(UINT16 *) FixupData == *F16) { if (*(UINT16 *) FixupData == *Fixup16) {
*F16 = (UINT16) (*F16 + ((UINT16) ((UINT32) Adjust >> 16))); *Fixup16 = (UINT16) (*Fixup16 + ((UINT16) ((UINT32) Adjust >> 16)));
} }
FixupData = FixupData + sizeof (UINT16); FixupData = FixupData + sizeof (UINT16);
break; break;
case EFI_IMAGE_REL_BASED_LOW: case EFI_IMAGE_REL_BASED_LOW:
F16 = (UINT16 *) Fixup; Fixup16 = (UINT16 *) Fixup;
if (*(UINT16 *) FixupData == *F16) { if (*(UINT16 *) FixupData == *Fixup16) {
*F16 = (UINT16) (*F16 + ((UINT16) Adjust & 0xffff)); *Fixup16 = (UINT16) (*Fixup16 + ((UINT16) Adjust & 0xffff));
} }
FixupData = FixupData + sizeof (UINT16); FixupData = FixupData + sizeof (UINT16);
break; break;
case EFI_IMAGE_REL_BASED_HIGHLOW: case EFI_IMAGE_REL_BASED_HIGHLOW:
F32 = (UINT32 *) Fixup; Fixup32 = (UINT32 *) Fixup;
FixupData = ALIGN_POINTER (FixupData, sizeof (UINT32)); FixupData = ALIGN_POINTER (FixupData, sizeof (UINT32));
if (*(UINT32 *) FixupData == *F32) { if (*(UINT32 *) FixupData == *Fixup32) {
*F32 = *F32 + (UINT32) Adjust; *Fixup32 = *Fixup32 + (UINT32) Adjust;
} }
FixupData = FixupData + sizeof (UINT32); FixupData = FixupData + sizeof (UINT32);
break; break;
case EFI_IMAGE_REL_BASED_DIR64: case EFI_IMAGE_REL_BASED_DIR64:
F64 = (UINT64 *)Fixup; Fixup64 = (UINT64 *)Fixup;
FixupData = ALIGN_POINTER (FixupData, sizeof (UINT64)); FixupData = ALIGN_POINTER (FixupData, sizeof (UINT64));
if (*(UINT64 *) FixupData == *F64) { if (*(UINT64 *) FixupData == *Fixup64) {
*F64 = *F64 + (UINT64)Adjust; *Fixup64 = *Fixup64 + (UINT64)Adjust;
} }
FixupData = FixupData + sizeof (UINT64); FixupData = FixupData + sizeof (UINT64);

View File

@ -43,20 +43,20 @@
#define IMM64_IC_INST_WORD_POS_X 12 #define IMM64_IC_INST_WORD_POS_X 12
#define IMM64_IC_VAL_POS_X 21 #define IMM64_IC_VAL_POS_X 21
#define IMM64_IMM41a_INST_WORD_X 1 #define IMM64_IMM41A_INST_WORD_X 1
#define IMM64_IMM41a_SIZE_X 10 #define IMM64_IMM41A_SIZE_X 10
#define IMM64_IMM41a_INST_WORD_POS_X 14 #define IMM64_IMM41A_INST_WORD_POS_X 14
#define IMM64_IMM41a_VAL_POS_X 22 #define IMM64_IMM41A_VAL_POS_X 22
#define IMM64_IMM41b_INST_WORD_X 1 #define IMM64_IMM41B_INST_WORD_X 1
#define IMM64_IMM41b_SIZE_X 8 #define IMM64_IMM41B_SIZE_X 8
#define IMM64_IMM41b_INST_WORD_POS_X 24 #define IMM64_IMM41B_INST_WORD_POS_X 24
#define IMM64_IMM41b_VAL_POS_X 32 #define IMM64_IMM41B_VAL_POS_X 32
#define IMM64_IMM41c_INST_WORD_X 2 #define IMM64_IMM41C_INST_WORD_X 2
#define IMM64_IMM41c_SIZE_X 23 #define IMM64_IMM41C_SIZE_X 23
#define IMM64_IMM41c_INST_WORD_POS_X 0 #define IMM64_IMM41C_INST_WORD_POS_X 0
#define IMM64_IMM41c_VAL_POS_X 40 #define IMM64_IMM41C_VAL_POS_X 40
#define IMM64_SIGN_INST_WORD_X 3 #define IMM64_SIGN_INST_WORD_X 3
#define IMM64_SIGN_SIZE_X 1 #define IMM64_SIGN_SIZE_X 1
@ -83,7 +83,7 @@ PeCoffLoaderRelocateImageEx (
IN UINT64 Adjust IN UINT64 Adjust
) )
{ {
UINT64 *F64; UINT64 *Fixup64;
UINT64 FixupVal; UINT64 FixupVal;
switch ((*Reloc) >> 12) { switch ((*Reloc) >> 12) {
@ -129,10 +129,10 @@ PeCoffLoaderRelocateImageEx (
); );
EXT_IMM64(FixupVal, EXT_IMM64(FixupVal,
(UINT32 *)Fixup + IMM64_IMM41a_INST_WORD_X, (UINT32 *)Fixup + IMM64_IMM41A_INST_WORD_X,
IMM64_IMM41a_SIZE_X, IMM64_IMM41A_SIZE_X,
IMM64_IMM41a_INST_WORD_POS_X, IMM64_IMM41A_INST_WORD_POS_X,
IMM64_IMM41a_VAL_POS_X IMM64_IMM41A_VAL_POS_X
); );
// //
@ -172,24 +172,24 @@ PeCoffLoaderRelocateImageEx (
); );
INS_IMM64(FixupVal, INS_IMM64(FixupVal,
((UINT32 *)Fixup + IMM64_IMM41a_INST_WORD_X), ((UINT32 *)Fixup + IMM64_IMM41A_INST_WORD_X),
IMM64_IMM41a_SIZE_X, IMM64_IMM41A_SIZE_X,
IMM64_IMM41a_INST_WORD_POS_X, IMM64_IMM41A_INST_WORD_POS_X,
IMM64_IMM41a_VAL_POS_X IMM64_IMM41A_VAL_POS_X
); );
INS_IMM64(FixupVal, INS_IMM64(FixupVal,
((UINT32 *)Fixup + IMM64_IMM41b_INST_WORD_X), ((UINT32 *)Fixup + IMM64_IMM41B_INST_WORD_X),
IMM64_IMM41b_SIZE_X, IMM64_IMM41B_SIZE_X,
IMM64_IMM41b_INST_WORD_POS_X, IMM64_IMM41B_INST_WORD_POS_X,
IMM64_IMM41b_VAL_POS_X IMM64_IMM41B_VAL_POS_X
); );
INS_IMM64(FixupVal, INS_IMM64(FixupVal,
((UINT32 *)Fixup + IMM64_IMM41c_INST_WORD_X), ((UINT32 *)Fixup + IMM64_IMM41C_INST_WORD_X),
IMM64_IMM41c_SIZE_X, IMM64_IMM41C_SIZE_X,
IMM64_IMM41c_INST_WORD_POS_X, IMM64_IMM41C_INST_WORD_POS_X,
IMM64_IMM41c_VAL_POS_X IMM64_IMM41C_VAL_POS_X
); );
INS_IMM64(FixupVal, INS_IMM64(FixupVal,
@ -199,10 +199,10 @@ PeCoffLoaderRelocateImageEx (
IMM64_SIGN_VAL_POS_X IMM64_SIGN_VAL_POS_X
); );
F64 = (UINT64 *) Fixup; Fixup64 = (UINT64 *) Fixup;
if (*FixupData != NULL) { if (*FixupData != NULL) {
*FixupData = ALIGN_POINTER(*FixupData, sizeof(UINT64)); *FixupData = ALIGN_POINTER(*FixupData, sizeof(UINT64));
*(UINT64 *)(*FixupData) = *F64; *(UINT64 *)(*FixupData) = *Fixup64;
*FixupData = *FixupData + sizeof(UINT64); *FixupData = *FixupData + sizeof(UINT64);
} }
break; break;
@ -267,24 +267,24 @@ PeHotRelocateImageEx (
IN UINT64 Adjust IN UINT64 Adjust
) )
{ {
UINT64 *F64; UINT64 *Fixup64;
UINT64 FixupVal; UINT64 FixupVal;
switch ((*Reloc) >> 12) { switch ((*Reloc) >> 12) {
case EFI_IMAGE_REL_BASED_DIR64: case EFI_IMAGE_REL_BASED_DIR64:
F64 = (UINT64 *) Fixup; Fixup64 = (UINT64 *) Fixup;
*FixupData = ALIGN_POINTER (*FixupData, sizeof (UINT64)); *FixupData = ALIGN_POINTER (*FixupData, sizeof (UINT64));
if (*(UINT64 *) (*FixupData) == *F64) { if (*(UINT64 *) (*FixupData) == *Fixup64) {
*F64 = *F64 + (UINT64) Adjust; *Fixup64 = *Fixup64 + (UINT64) Adjust;
} }
*FixupData = *FixupData + sizeof (UINT64); *FixupData = *FixupData + sizeof (UINT64);
break; break;
case EFI_IMAGE_REL_BASED_IA64_IMM64: case EFI_IMAGE_REL_BASED_IA64_IMM64:
F64 = (UINT64 *) Fixup; Fixup64 = (UINT64 *) Fixup;
*FixupData = ALIGN_POINTER (*FixupData, sizeof (UINT64)); *FixupData = ALIGN_POINTER (*FixupData, sizeof (UINT64));
if (*(UINT64 *) (*FixupData) == *F64) { if (*(UINT64 *) (*FixupData) == *Fixup64) {
// //
// Align it to bundle address before fixing up the // Align it to bundle address before fixing up the
// 64-bit immediate value of the movl instruction. // 64-bit immediate value of the movl instruction.
@ -330,10 +330,10 @@ PeHotRelocateImageEx (
EXT_IMM64 ( EXT_IMM64 (
FixupVal, FixupVal,
(UINT32 *) Fixup + IMM64_IMM41a_INST_WORD_X, (UINT32 *) Fixup + IMM64_IMM41A_INST_WORD_X,
IMM64_IMM41a_SIZE_X, IMM64_IMM41A_SIZE_X,
IMM64_IMM41a_INST_WORD_POS_X, IMM64_IMM41A_INST_WORD_POS_X,
IMM64_IMM41a_VAL_POS_X IMM64_IMM41A_VAL_POS_X
); );
// //
@ -378,26 +378,26 @@ PeHotRelocateImageEx (
INS_IMM64 ( INS_IMM64 (
FixupVal, FixupVal,
((UINT32 *) Fixup + IMM64_IMM41a_INST_WORD_X), ((UINT32 *) Fixup + IMM64_IMM41A_INST_WORD_X),
IMM64_IMM41a_SIZE_X, IMM64_IMM41A_SIZE_X,
IMM64_IMM41a_INST_WORD_POS_X, IMM64_IMM41A_INST_WORD_POS_X,
IMM64_IMM41a_VAL_POS_X IMM64_IMM41A_VAL_POS_X
); );
INS_IMM64 ( INS_IMM64 (
FixupVal, FixupVal,
((UINT32 *) Fixup + IMM64_IMM41b_INST_WORD_X), ((UINT32 *) Fixup + IMM64_IMM41B_INST_WORD_X),
IMM64_IMM41b_SIZE_X, IMM64_IMM41B_SIZE_X,
IMM64_IMM41b_INST_WORD_POS_X, IMM64_IMM41B_INST_WORD_POS_X,
IMM64_IMM41b_VAL_POS_X IMM64_IMM41B_VAL_POS_X
); );
INS_IMM64 ( INS_IMM64 (
FixupVal, FixupVal,
((UINT32 *) Fixup + IMM64_IMM41c_INST_WORD_X), ((UINT32 *) Fixup + IMM64_IMM41C_INST_WORD_X),
IMM64_IMM41c_SIZE_X, IMM64_IMM41C_SIZE_X,
IMM64_IMM41c_INST_WORD_POS_X, IMM64_IMM41C_INST_WORD_POS_X,
IMM64_IMM41c_VAL_POS_X IMM64_IMM41C_VAL_POS_X
); );
INS_IMM64 ( INS_IMM64 (
@ -408,7 +408,7 @@ PeHotRelocateImageEx (
IMM64_SIGN_VAL_POS_X IMM64_SIGN_VAL_POS_X
); );
*(UINT64 *) (*FixupData) = *F64; *(UINT64 *) (*FixupData) = *Fixup64;
} }
*FixupData = *FixupData + sizeof (UINT64); *FixupData = *FixupData + sizeof (UINT64);