From: Heinrich Schuchardt <xypron.glpk@gmx.de>
Date: Fri, 6 Apr 2018 13:36:31 +0000 (+0200)
Subject: efi_loader: correctly set the machine type in the PE header
X-Git-Tag: v2025.01-rc5-pxa1908~4520^2
X-Git-Url: http://git.dujemihanovic.xyz/img/static/%7B%7B%20%24image.RelPermalink%20%7D%7D?a=commitdiff_plain;h=f4cf153a487486428a061b5d866fe2f68653b2f8;p=u-boot.git

efi_loader: correctly set the machine type in the PE header

The portable executable header has a field describing the machine type.
The machine type should match the binary. So on i386 we should use
IMAGE_FILE_MACHINE_I386 and on x86_64 we should use
IMAGE_FILE_MACHINE_AMD64. The actual value is issued by the objcopy
command invoked in scripts/Makefile.lib in depdendence of the value of
EFI_TARGET.

The value is used both for EFI_STUB and for EFI_LOADER.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
---

diff --git a/arch/x86/config.mk b/arch/x86/config.mk
index 472ada5490..69074f4711 100644
--- a/arch/x86/config.mk
+++ b/arch/x86/config.mk
@@ -94,12 +94,16 @@ ifneq ($(CONFIG_EFI_STUB_64BIT),)
 EFI_LDS := elf_x86_64_efi.lds
 EFI_CRT0 := crt0_x86_64_efi.o
 EFI_RELOC := reloc_x86_64_efi.o
-EFI_TARGET := --target=efi-app-ia32
 else
 EFI_LDS := elf_ia32_efi.lds
 EFI_CRT0 := crt0_ia32_efi.o
 EFI_RELOC := reloc_ia32_efi.o
+endif
+
+ifdef CONFIG_X86_64
 EFI_TARGET := --target=efi-app-x86_64
+else
+EFI_TARGET := --target=efi-app-ia32
 endif
 
 endif