diff mbox series

[U-Boot,v2,03/11] efi_loader: Use compiler constants for image loader

Message ID 20180614182232.78201-4-agraf@suse.de
State Superseded
Delegated to: Alexander Graf
Headers show
Series sandbox: efi_loader support | expand

Commit Message

Alexander Graf June 14, 2018, 6:22 p.m. UTC
The EFI image loader tries to determine which target architecture we're
working with to only load PE binaries that match.

So far this has worked based on CONFIG defines, because the target CPU
was always indicated by a config define. With sandbox however, this is
not longer true as all sandbox targets only encompass a single CONFIG
option and so we need to use compiler defines to determine the CPU
architecture.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 lib/efi_loader/efi_image_loader.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Simon Glass June 14, 2018, 7:01 p.m. UTC | #1
Hi Alex,

On 14 June 2018 at 12:22, Alexander Graf <agraf@suse.de> wrote:
> The EFI image loader tries to determine which target architecture we're
> working with to only load PE binaries that match.
>
> So far this has worked based on CONFIG defines, because the target CPU
> was always indicated by a config define. With sandbox however, this is
> not longer true as all sandbox targets only encompass a single CONFIG
> option and so we need to use compiler defines to determine the CPU
> architecture.
>
> Signed-off-by: Alexander Graf <agraf@suse.de>
> ---
>  lib/efi_loader/efi_image_loader.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>

NAK to this for now until we figure out a response to my concerns
previously expressed.

Regards,
Simon
diff mbox series

Patch

diff --git a/lib/efi_loader/efi_image_loader.c b/lib/efi_loader/efi_image_loader.c
index ecdb77e5b6..fdf40a62c8 100644
--- a/lib/efi_loader/efi_image_loader.c
+++ b/lib/efi_loader/efi_image_loader.c
@@ -19,25 +19,25 @@  const efi_guid_t efi_simple_file_system_protocol_guid =
 const efi_guid_t efi_file_info_guid = EFI_FILE_INFO_GUID;
 
 static int machines[] = {
-#if defined(CONFIG_ARM64)
+#if defined(__aarch64__)
 	IMAGE_FILE_MACHINE_ARM64,
-#elif defined(CONFIG_ARM)
+#elif defined(__arm__)
 	IMAGE_FILE_MACHINE_ARM,
 	IMAGE_FILE_MACHINE_THUMB,
 	IMAGE_FILE_MACHINE_ARMNT,
 #endif
 
-#if defined(CONFIG_X86_64)
+#if defined(__x86_64__)
 	IMAGE_FILE_MACHINE_AMD64,
-#elif defined(CONFIG_X86)
+#elif defined(__i386__)
 	IMAGE_FILE_MACHINE_I386,
 #endif
 
-#if defined(CONFIG_CPU_RISCV_32)
+#if defined(__riscv) && (__riscv_xlen == 32)
 	IMAGE_FILE_MACHINE_RISCV32,
 #endif
 
-#if defined(CONFIG_CPU_RISCV_64)
+#if defined(__riscv) && (__riscv_xlen == 64)
 	IMAGE_FILE_MACHINE_RISCV64,
 #endif
 	0 };