x86: add support for CONFIG_REMAKE_ELF
PATCH 1/1 x86: add support for CONFIG_REMAKE_ELF
From: Denis Mukhin <[email protected]>
Fix objcopy/ld parameters for x86 to enable CONFIG_REMAKE_ELF configurations.
That adds new 'PLATFORM_ELF_ELFLDFLAGS' make variable for injecting proper linker arguments when u-boot.elf is requested.
---
CI: https://github.com/u-boot/u-boot/pull/1013
--- Makefile | 1 + arch/x86/config.mk | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-)
Makefile +1 -0
@@ -1937,6 +1937,7 @@ u-boot-with-spl-pbl.bin: spl/u-boot-spl.pbl $(UBOOT_BINLOAD) FORCE quiet_cmd_u-boot-elf ?= LD $@ cmd_u-boot-elf ?= $(LD) u-boot-elf.o -o $@ \ $(if $(CONFIG_SYS_BIG_ENDIAN),-EB,-EL) \ + $(PLATFORM_ELFLDFLAGS) \ -T u-boot-elf.lds --defsym=$(CONFIG_PLATFORM_ELFENTRY)=$(CONFIG_TEXT_BASE) \ -Ttext=$(CONFIG_TEXT_BASE) u-boot.elf: u-boot.bin u-boot-elf.lds
arch/x86/config.mk +6 -2
@@ -24,9 +24,13 @@ EFI_IS_32BIT := endif ifeq ($(IS_32BIT),y) -PLATFORM_CPPFLAGS += -march=i386 -m32 +PLATFORM_CPPFLAGS += -march=i386 -m32 +PLATFORM_ELFFLAGS += -O elf32-i386 -B i386 +PLATFORM_ELFLDFLAGS += -m elf_i386 else -PLATFORM_CPPFLAGS += $(if $(CONFIG_XPL_BUILD),,-fpic) -fno-common -march=core2 -m64 +PLATFORM_CPPFLAGS += $(if $(CONFIG_XPL_BUILD),,-fpic) -fno-common -march=core2 -m64 +PLATFORM_ELFFLAGS += -O elf64-x86-64 -B i386:x86-64 +PLATFORM_ELFLDFLAGS += -m elf_x86_64 ifndef CONFIG_X86_HARDFP PLATFORM_CPPFLAGS += -mno-mmx -mno-sse
Signature · 1 line
2.54.0
Quoted 9 lines · On Thu, Jul 16, 2026 at 01:52:14PM -0700, [email protected] wrote:
From: Denis Mukhin <[email protected]>
Fix objcopy/ld parameters for x86 to enable
CONFIG_REMAKE_ELFconfigurations.That adds new '
PLATFORM_ELF_ELFLDFLAGS' make variable for injecting proper linker arguments when u-boot.elf is requested.Signed-off-by Denis Mukhin <[email protected]>
Signature · 1 line
Tom
Hi Denis,
Quoted 8 lines · None
x86: add support for
CONFIG_REMAKE_ELFFix objcopy/ld parameters for x86 to enable
CONFIG_REMAKE_ELFconfigurations.That adds new '
PLATFORM_ELF_ELFLDFLAGS' make variable for injecting proper linker arguments when u-boot.elf is requested.
Quoted 8 lines
Signed-off-by Denis Mukhin <[email protected]>
Makefile| 1 +arch/x86/config.mk | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-)That adds new '
PLATFORM_ELF_ELFLDFLAGS' make variable for injecting proper linker arguments when u-boot.elf is requested.
The variable is actually called PLATFORM_ELFLDFLAGS - please can you fix the name here. Also, please use the imperative ("Add a new ... variable") and mention what fails today when CONFIG_REMAKE_ELF is enabled on x86 (presumably ld picking the wrong emulation).
Makefile u-boot-with-spl-pbl.bin: spl/u-boot-spl.pbl $(UBOOT_BINLOAD) FORCE · line 2006
Quoted 6 lines
Makefile +1
-0@@ -2003,6 +2003,7 @@ u-boot-with-spl-pbl.bin: spl/u-boot-spl.pbl $(UBOOT_BINLOAD) FORCE quiet_cmd_u-boot-elf ?= LD $@ cmd_u-boot-elf ?= $(LD) u-boot-elf.o -o $@ \ $(if $(CONFIG_SYS_BIG_ENDIAN),-EB,-EL) \ + $(PLATFORM_ELFLDFLAGS) \
Please can you add the same to cmd_u-boot-spl-elf just below, otherwise CONFIG_SPL_REMAKE_ELF still fails on x86 (SPL is always 32-bit, so it wants -m elf_i386).
arch/x86/config.mk EFI_IS_32BIT := · line 26
Quoted 6 lines
arch/x86/config.mk +3
-1@@ -24,9 +24,13 @@ EFI_IS_32BIT := -PLATFORM_CPPFLAGS += -march=i386 -m32 +PLATFORM_CPPFLAGS += -march=i386 -m32 +PLATFORM_ELFFLAGS += -O elf32-i386 -B i386 +PLATFORM_ELFLDFLAGS += -m elf_i386
Please drop the whitespace churn on the existing PLATFORM_CPPFLAGS lines - the rest of the file uses a single space before +=
BTW, further down this file there is already:
KBUILD_LDFLAGS += -m $(if $(IS_32BIT),elf_i386,elf_x86_64)
so you could set PLATFORM_ELFLDFLAGS the same way in one line outside the ifeq, next to that. What do you think?
I'm also interested in which x86 platform you are using - I am working on getting Alder Lake supported at the moment.
Regards,
Simon
Quoted 46 lines · Simon Glass
Hi Denis,
Quoted 8 lines · None
x86: add support for
CONFIG_REMAKE_ELFFix objcopy/ld parameters for x86 to enable
CONFIG_REMAKE_ELFconfigurations.That adds new '
PLATFORM_ELF_ELFLDFLAGS' make variable for injecting proper linker arguments when u-boot.elf is requested.Quoted 8 lines
Signed-off-by Denis Mukhin <[email protected]>
Makefile| 1 +arch/x86/config.mk | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-)That adds new '
PLATFORM_ELF_ELFLDFLAGS' make variable for injecting proper linker arguments when u-boot.elf is requested.The variable is actually called
PLATFORM_ELFLDFLAGS- please can you fix the name here. Also, please use the imperative ("Add a new ... variable") and mention what fails today whenCONFIG_REMAKE_ELFis enabled on x86 (presumably ld picking the wrong emulation).Makefile u-boot-with-spl-pbl.bin: spl/u-boot-spl.pbl $(UBOOT_BINLOAD) FORCE · line 2006
Quoted 6 lines
Makefile +1
-0@@ -2003,6 +2003,7 @@ u-boot-with-spl-pbl.bin: spl/u-boot-spl.pbl $(UBOOT_BINLOAD) FORCE quiet_cmd_u-boot-elf ?= LD $@ cmd_u-boot-elf ?= $(LD) u-boot-elf.o -o $@ \ $(if $(CONFIG_SYS_BIG_ENDIAN),-EB,-EL) \ + $(PLATFORM_ELFLDFLAGS) \Please can you add the same to cmd_u-boot-spl-elf just below, otherwise
CONFIG_SPL_REMAKE_ELFstill fails on x86 (SPL is always 32-bit, so it wants -melf_i386).arch/x86/config.mk EFI_IS_32BIT := · line 26
Quoted 6 lines
arch/x86/config.mk +3
-1@@ -24,9 +24,13 @@ EFI_IS_32BIT := -PLATFORM_CPPFLAGS += -march=i386 -m32 +PLATFORM_CPPFLAGS += -march=i386 -m32 +PLATFORM_ELFFLAGS += -O elf32-i386 -B i386 +PLATFORM_ELFLDFLAGS += -m elf_i386Please drop the whitespace churn on the existing
PLATFORM_CPPFLAGSlines - the rest of the file uses a single space before +=
Quoted 6 lines
BTW, further down this file there is already:
KBUILD_LDFLAGS += -m $(if $(IS_32BIT),elf_i386,elf_x86_64)so you could set
PLATFORM_ELFLDFLAGSthe same way in one line outside the ifeq, next to that. What do you think?
Will update!
Quoted 3 lines
I'm also interested in which x86 platform you are using - I am working on getting Alder Lake supported at the moment.
Thanks for asking.
Unfortunately, I'm not able to share details about the platform.
Quoted 3 lines
Regards,
Simon