mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-05-02 13:44:00 +00:00
hv: further fix to configurable relocatoin
commit ia23549aa915e7dc2c ("build: make relocation-related code configurable") adds CONFIG_RELOC to make relocation configurable This patch corrects the behavior when CONFIG_RELOC is disabled - Don't use "CFLAGS += -fpie" and put back "LDFLAGS += -static" - __emalloc(): forced to allocate exactly the asked address, which is CONFIG_RAM_START
This commit is contained in:
parent
944776f238
commit
621425da20
@ -39,10 +39,15 @@ CFLAGS += -ffunction-sections -fdata-sections
|
|||||||
CFLAGS += -fshort-wchar -ffreestanding
|
CFLAGS += -fshort-wchar -ffreestanding
|
||||||
CFLAGS += -m64 -mno-mmx -mno-sse -mno-sse2 -mno-80387 -mno-fp-ret-in-387
|
CFLAGS += -m64 -mno-mmx -mno-sse -mno-sse2 -mno-80387 -mno-fp-ret-in-387
|
||||||
CFLAGS += -mno-red-zone
|
CFLAGS += -mno-red-zone
|
||||||
CFLAGS += -static -nostdinc -nostdlib -fno-common
|
CFLAGS += -nostdinc -nostdlib -fno-common
|
||||||
CFLAGS += -O2 -D_FORTIFY_SOURCE=2
|
CFLAGS += -O2 -D_FORTIFY_SOURCE=2
|
||||||
CFLAGS += -Wformat -Wformat-security
|
CFLAGS += -Wformat -Wformat-security
|
||||||
|
ifeq (y, $(CONFIG_RELOC))
|
||||||
CFLAGS += -fpie
|
CFLAGS += -fpie
|
||||||
|
else
|
||||||
|
CFLAGS += -static
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
ifdef STACK_PROTECTOR
|
ifdef STACK_PROTECTOR
|
||||||
ifeq (true, $(shell [ $(GCC_MAJOR) -gt 4 ] && echo true))
|
ifeq (true, $(shell [ $(GCC_MAJOR) -gt 4 ] && echo true))
|
||||||
@ -70,6 +75,8 @@ ifeq (y, $(CONFIG_RELOC))
|
|||||||
# We know it's safe because Hypervisor runs under 4GB. "noreloc-overflow"
|
# We know it's safe because Hypervisor runs under 4GB. "noreloc-overflow"
|
||||||
# is used to avoid the compile error
|
# is used to avoid the compile error
|
||||||
LDFLAGS += -pie -z noreloc-overflow
|
LDFLAGS += -pie -z noreloc-overflow
|
||||||
|
else
|
||||||
|
LDFLAGS += -static
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ARCH_CFLAGS += -gdwarf-2
|
ARCH_CFLAGS += -gdwarf-2
|
||||||
|
@ -68,9 +68,9 @@ static uint64_t trampoline_relo_addr(void *addr)
|
|||||||
return (uint64_t)addr - get_hv_image_delta();
|
return (uint64_t)addr - get_hv_image_delta();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_RELOC
|
|
||||||
void _relocate(void)
|
void _relocate(void)
|
||||||
{
|
{
|
||||||
|
#ifdef CONFIG_RELOC
|
||||||
struct Elf64_Dyn *dyn;
|
struct Elf64_Dyn *dyn;
|
||||||
struct Elf64_Rel *start = NULL, *end = NULL;
|
struct Elf64_Rel *start = NULL, *end = NULL;
|
||||||
uint64_t delta, size = 0;
|
uint64_t delta, size = 0;
|
||||||
@ -136,12 +136,8 @@ void _relocate(void)
|
|||||||
}
|
}
|
||||||
start = (struct Elf64_Rel *)((char *)start + size);
|
start = (struct Elf64_Rel *)((char *)start + size);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#else
|
|
||||||
void _relocate(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t read_trampoline_sym(void *sym)
|
uint64_t read_trampoline_sym(void *sym)
|
||||||
{
|
{
|
||||||
|
@ -268,7 +268,11 @@ EFI_STATUS __emalloc(UINTN size, UINTN min_addr, EFI_PHYSICAL_ADDRESS *addr,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef CONFIG_RELOC
|
||||||
aligned = start;
|
aligned = start;
|
||||||
|
#else
|
||||||
|
aligned = min_addr;
|
||||||
|
#endif
|
||||||
err = allocate_pages(AllocateAddress, mem_type,
|
err = allocate_pages(AllocateAddress, mem_type,
|
||||||
nr_pages, &aligned);
|
nr_pages, &aligned);
|
||||||
if (err == EFI_SUCCESS) {
|
if (err == EFI_SUCCESS) {
|
||||||
|
Loading…
Reference in New Issue
Block a user