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 <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
Reviewed-by: Fredrik Holmqvist <[email protected]>
This commit is contained in:
David Karoly
2021-12-27 15:17:54 +00:00
committed by Adrien Destugues
parent 182eaee962
commit b9a0a02382
2 changed files with 20 additions and 3 deletions
+14
View File
@@ -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
;
+6 -3
View File
@@ -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))