mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-23 05:57:33 +00:00
HV: MISRA clean in reloc.c
The patch is to fix MISRA violation in reloc.c by: - remove multi-returns in relocate(); - remove non useful checking in relocate(); - add suffix U to macro definition Tracked-On: #861 Signed-off-by: Chaohong guo <chaohong.guo@intel.com> Acked-by: Anthony Xu <anthony.xu@intel.com>
This commit is contained in:
parent
723ff1f4ee
commit
89b6dc593f
@ -9,10 +9,10 @@
|
|||||||
#include <ld_sym.h>
|
#include <ld_sym.h>
|
||||||
|
|
||||||
#ifdef CONFIG_RELOC
|
#ifdef CONFIG_RELOC
|
||||||
#define DT_NULL 0 /* end of .dynamic section */
|
#define DT_NULL 0U /* end of .dynamic section */
|
||||||
#define DT_RELA 7 /* relocation table */
|
#define DT_RELA 7U /* relocation table */
|
||||||
#define DT_RELASZ 8 /* size of reloc table */
|
#define DT_RELASZ 8U /* size of reloc table */
|
||||||
#define DT_RELAENT 9 /* size of one entry */
|
#define DT_RELAENT 9U /* size of one entry */
|
||||||
|
|
||||||
#define R_X86_64_RELATIVE 8UL
|
#define R_X86_64_RELATIVE 8UL
|
||||||
|
|
||||||
@ -67,9 +67,7 @@ void relocate(void)
|
|||||||
|
|
||||||
/* get the delta that needs to be patched */
|
/* get the delta that needs to be patched */
|
||||||
delta = get_hv_image_delta();
|
delta = get_hv_image_delta();
|
||||||
if (delta == 0U) {
|
if (delta != 0U) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Look for the descriptoin of relocation sections */
|
/* Look for the descriptoin of relocation sections */
|
||||||
for (dyn = (struct Elf64_Dyn *)_DYNAMIC; dyn->d_tag != DT_NULL; dyn++) {
|
for (dyn = (struct Elf64_Dyn *)_DYNAMIC; dyn->d_tag != DT_NULL; dyn++) {
|
||||||
@ -83,14 +81,12 @@ void relocate(void)
|
|||||||
case DT_RELAENT:
|
case DT_RELAENT:
|
||||||
size = dyn->d_ptr;
|
size = dyn->d_ptr;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
/* if no RELA/RELASZ found, both start and end will be initialized to NULL, and later while loop won't be executed */
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sanity check */
|
|
||||||
if ((start == NULL) || (size == 0U)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Need to subtract the relocation delta to get the correct
|
* Need to subtract the relocation delta to get the correct
|
||||||
* absolute addresses
|
* absolute addresses
|
||||||
@ -125,5 +121,6 @@ void relocate(void)
|
|||||||
}
|
}
|
||||||
start = (struct Elf64_Rel *)((char *)start + size);
|
start = (struct Elf64_Rel *)((char *)start + size);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user