Skip to contentSkip to conversation

x86: add support for CONFIG_REMAKE_ELF

PATCH In review [email protected] 4 participants 4 messages Jul 16 – Jul 23

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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
index 8cb9a06f6a41..31db0d37a631 100644
@@ -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
index c2bb5549b7c8..4a6404344679 100644
@@ -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
#2 lore raw
In reply to [email protected]

Hi Denis,

Quoted 8 lines · None

x86: add support for CONFIG_REMAKE_ELF

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.

Quoted 8 lines

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

#3 lore raw
Quoted 46 lines · Simon Glass

Hi Denis,

Quoted 8 lines · None

x86: add support for CONFIG_REMAKE_ELF

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.

Quoted 8 lines

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 +=

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_ELFLDFLAGS the 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