From b9a0a023829f90b2f9a8fd319ba39234e34b63d6 Mon Sep 17 00:00:00 2001 From: David Karoly Date: Fri, 17 Dec 2021 16:36:15 +0100 Subject: [PATCH] arch/x86: select between 32-bit and 64-bit ELF based on arch and platform arch_elf is reused between the kernel and boot loader No change for kernel mode compilation. How to select 32-bit or 64-bit when building boot loader: * build both when building BIOS loader * build only 32-bit when building 32-bit EFI loader * build only 64-bit when building 64-bit EFI loader Change-Id: I9caa1248c7eb24318911a0c369137cedb638e4e4 Reviewed-on: https://review.haiku-os.org/c/haiku/+/4817 Tested-by: Commit checker robot Reviewed-by: Adrien Destugues Reviewed-by: Fredrik Holmqvist --- src/system/boot/arch/x86/Jamfile | 14 ++++++++++++++ src/system/kernel/arch/x86/arch_elf.cpp | 9 ++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/system/boot/arch/x86/Jamfile b/src/system/boot/arch/x86/Jamfile index 1a4f30cbcf..1f90ef1a3e 100644 --- a/src/system/boot/arch/x86/Jamfile +++ b/src/system/boot/arch/x86/Jamfile @@ -1,10 +1,24 @@ SubDir HAIKU_TOP src system boot arch x86 ; +local defines = $(DEFINES) ; + local platform ; for platform in [ MultiBootSubDirSetup bios_ia32 efi pxe_ia32 ] { on $(platform) { + DEFINES = $(defines) ; DEFINES += _BOOT_MODE ; + if $(TARGET_BOOT_PLATFORM) = efi { + if $(TARGET_ARCH) = x86_64 { + DEFINES += BOOT_SUPPORT_ELF64 ; + } else { + DEFINES += BOOT_SUPPORT_ELF32 ; + } + } else { + DEFINES += BOOT_SUPPORT_ELF64 ; + DEFINES += BOOT_SUPPORT_ELF32 ; + } + local kernelArchSources = arch_elf.cpp ; diff --git a/src/system/kernel/arch/x86/arch_elf.cpp b/src/system/kernel/arch/x86/arch_elf.cpp index cb1d0f2363..7e991137d3 100644 --- a/src/system/kernel/arch/x86/arch_elf.cpp +++ b/src/system/kernel/arch/x86/arch_elf.cpp @@ -184,10 +184,12 @@ arch_elf_relocate_rela(struct elf_image_info *image, } -#endif // !__x86_64__ || defined(ELF32_COMPAT) || (_BOOT_MODE && _BOOT_PLATFORM != efi) +#endif // !defined(__x86_64__) || defined(ELF32_COMPAT) || + // (defined(_BOOT_MODE) && _BOOT_PLATFORM != efi) -#if (defined(__x86_64__) && !defined(ELF32_COMPAT)) || defined(_BOOT_MODE) +#if (defined(__x86_64__) && !defined(ELF32_COMPAT)) || \ + (defined(_BOOT_MODE) && defined(BOOT_SUPPORT_ELF64)) #ifdef _BOOT_MODE @@ -280,4 +282,5 @@ arch_elf_relocate_rela(struct elf_image_info *image, } -#endif // (defined(__x86_64__) && !defined(ELF32_COMPAT)) || defined(_BOOT_MODE) +#endif // (defined(__x86_64__) && !defined(ELF32_COMPAT)) || + // (defined(_BOOT_MODE) && defined(BOOT_SUPPORT_ELF64))