Skip to contentSkip to conversation

x86: add support for CONFIG_REMAKE_ELF

PATCH In review Denis Mukhin via U-Boot 3 participants 3 messages Jul 23 – Jul 30

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

PATCH v2 1/1 x86: add support for CONFIG_REMAKE_ELF

From: Denis Mukhin <[email protected]>

x86 builds with CONFIG_REMAKE_ELF fail as the following:
...
u-boot-elf.o: file not recognized: file format not recognized
...

Fix objcopy/ld parameters for x86 to enable CONFIG_REMAKE_ELF configurations in both SPL and U-Boot proper builds.

Add a new 'PLATFORM_ELFLDFLAGS' make variable for injecting proper linker arguments when u-boot.elf is requested.

---
Changes since v1:
- added SPL build
- fixed commit message
- CI: https://github.com/u-boot/u-boot/pull/1016
- v1: https://lore.kernel.org/u-boot/[email protected]/

---
 Makefile           | 2 ++
 arch/x86/config.mk | 3 +++
 2 files changed, 5 insertions(+)
Makefile +2 -0
index 56f59c24cf89..ab2121c87007 100644
@@ -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) \
 	-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 FORCE
@@ -2012,6 +2013,7 @@ u-boot.elf: u-boot.bin u-boot-elf.lds FORCE
 quiet_cmd_u-boot-spl-elf ?= LD      $@
 	cmd_u-boot-spl-elf ?= $(LD) spl/u-boot-spl-elf.o -o $@ \
 	$(if $(CONFIG_SYS_BIG_ENDIAN),-EB,-EL) \
+	$(PLATFORM_ELFLDFLAGS) \
 	-T u-boot-elf.lds --defsym=$(CONFIG_PLATFORM_ELFENTRY)=$(CONFIG_SPL_TEXT_BASE) \
 	-Ttext=$(CONFIG_SPL_TEXT_BASE)
 spl/u-boot-spl.elf: spl/u-boot-spl.bin u-boot-elf.lds
arch/x86/config.mk +3 -0
index c2bb5549b7c8..a62015e1a64c 100644
@@ -25,8 +25,10 @@ endif
 
 ifeq ($(IS_32BIT),y)
 PLATFORM_CPPFLAGS += -march=i386 -m32
+PLATFORM_ELFFLAGS += -O elf32-i386 -B i386
 else
 PLATFORM_CPPFLAGS += $(if $(CONFIG_XPL_BUILD),,-fpic) -fno-common -march=core2 -m64
+PLATFORM_ELFFLAGS += -O elf64-x86-64 -B i386:x86-64
 
 ifndef CONFIG_X86_HARDFP
 PLATFORM_CPPFLAGS += -mno-mmx -mno-sse
@@ -38,6 +40,7 @@ PLATFORM_RELFLAGS += -fdata-sections -ffunction-sections -fvisibility=hidden
 
 KBUILD_LDFLAGS += -Bsymbolic -Bsymbolic-functions
 KBUILD_LDFLAGS += -m $(if $(IS_32BIT),elf_i386,elf_x86_64)
+PLATFORM_ELFLDFLAGS += -m $(if $(IS_32BIT),elf_i386,elf_x86_64)
 
 # This is used in the top-level Makefile which does not include
 # KBUILD_LDFLAGS
Signature · 1 line
2.54.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 10 lines · Jamie.Gibbons--- via U-Boot

x86: add support for CONFIG_REMAKE_ELF

x86 builds with CONFIG_REMAKE_ELF fail as the following:
...
u-boot-elf.o: file not recognized: file format not recognized
...

Fix objcopy/ld parameters for x86 to enable CONFIG_REMAKE_ELF configurations in both SPL and U-Boot proper builds.

Quoted 8 lines

Add a new 'PLATFORM_ELFLDFLAGS' make variable for injecting proper linker arguments when u-boot.elf is requested.

Makefile | 2 ++

 arch/x86/config.mk | 3 +++
 2 files changed, 5 insertions(+)
#2 lore raw
In reply to Denis Mukhin via U-Boot
Quoted 9 lines · Denis Mukhin via U-Boot

x86 builds with CONFIG_REMAKE_ELF fail as the following:
...
u-boot-elf.o: file not recognized: file format not recognized
...

Fix objcopy/ld parameters for x86 to enable CONFIG_REMAKE_ELF configurations in both SPL and U-Boot proper builds.

[...]

Applied to u-boot/main, thanks!

[1/1] x86: add support for CONFIG_REMAKE_ELF

      commit: f6a37207b84342441ed8af4226cd85048931cc61
Signature · 1 line
Tom