From 7bcd510a7b202f9e4e670dab3e209ea370d02420 Mon Sep 17 00:00:00 2001 From: Ahmad Khalifa Date: Fri, 27 Sep 2024 18:32:06 +0300 Subject: [PATCH] stand: further restrict f_kernphys_relocatable and f_tg_kernel_support f_tg_kernel_support isn't used by any EFI code, and f_kernphys_relocatable isn't used by the non-EFI i386 code. --- stand/common/bootstrap.h | 4 ++-- stand/common/load_elf.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/stand/common/bootstrap.h b/stand/common/bootstrap.h index ab1e5249fc2a..37cef2956f40 100644 --- a/stand/common/bootstrap.h +++ b/stand/common/bootstrap.h @@ -239,10 +239,10 @@ struct preloaded_file size_t f_size; /* file size */ struct kernel_module *f_modules; /* list of modules if any */ struct preloaded_file *f_next; /* next file */ -#if defined(__amd64__) || defined(__i386__) +#if defined(__amd64__) || (defined(__i386__) && defined(EFI)) bool f_kernphys_relocatable; #endif -#if defined(__i386__) +#if defined(__i386__) && !defined(EFI) bool f_tg_kernel_support; #endif }; diff --git a/stand/common/load_elf.c b/stand/common/load_elf.c index eaa6bef6ee86..d3775b9f0017 100644 --- a/stand/common/load_elf.c +++ b/stand/common/load_elf.c @@ -217,7 +217,7 @@ static int elf_section_header_convert(const Elf_Ehdr *ehdr, Elf_Shdr *shdr) } #endif -#if defined(__amd64__) || defined(__i386__) +#if defined(__amd64__) || (defined(__i386__) && defined(EFI)) static bool is_kernphys_relocatable(elf_file_t ef) { @@ -491,10 +491,10 @@ __elfN(loadfile_raw)(char *filename, uint64_t dest, /* Load OK, return module pointer */ *result = (struct preloaded_file *)fp; err = 0; -#if defined(__amd64__) || defined(__i386__) +#if defined(__amd64__) || (defined(__i386__) && defined(EFI)) fp->f_kernphys_relocatable = multiboot || is_kernphys_relocatable(&ef); #endif -#ifdef __i386__ +#if defined(__i386__) && !defined(EFI) fp->f_tg_kernel_support = is_tg_kernel_support(fp, &ef); #endif goto out;