git: 9e239e67c460 - main - stand: further restrict f_kernphys_relocatable and f_tg_kernel_support

From: Warner Losh <imp_at_FreeBSD.org>
Date: Thu, 05 Dec 2024 00:18:50 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=9e239e67c460c5ad9878a000c4c63d4154cb21af

commit 9e239e67c460c5ad9878a000c4c63d4154cb21af
Author:     Ahmad Khalifa <ahmadkhalifa570@gmail.com>
AuthorDate: 2024-09-27 15:32:06 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-12-05 00:19:17 +0000

    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.
    
    Reviewed by: imp
    Pull Request: https://github.com/freebsd/freebsd-src/pull/1446
---
 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;