diff mbox

[U-Boot,v2,14/14] u-boot.elf: build it for every arch

Message ID 1492293846-10640-15-git-send-email-noltari@gmail.com
State Superseded, archived
Delegated to: Daniel Schwierzeck
Headers show

Commit Message

Álvaro Fernández Rojas April 15, 2017, 10:04 p.m. UTC
ARM64 isn't the only arch that needs it, since BMIPS CFE supports loading .elf
images instead of raw binaries.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
 v2: Introduce changes suggested by Daniel Schwierzeck:
  - Avoid using a linker script.
  - Reuse aarch64 u-boot.elf generation for other archs.
  - Fix _start vs __start symbol.

 Makefile | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

Comments

Álvaro Fernández Rojas April 18, 2017, 8:35 p.m. UTC | #1
Provide an u-boot.elf binary for Broadcom MIPS platforms by re-using
the already existing Makefile target for aarch64.
This u-boot.elf binary should be used as a stage 2 loader
until U-Boot can be replace the original Broadcom boot loader.

Split patches from main BMIPS support.

Álvaro Fernández Rojas (3):
  u-boot.elf: remove hard-coded arm64 flags
  u-boot.elf: fix entry symbol not found warning
  MIPS: add support for generating u-boot.elf

 Makefile            | 14 ++++++--------
 arch/arm/config.mk  |  6 ++++++
 arch/mips/config.mk |  1 +
 3 files changed, 13 insertions(+), 8 deletions(-)
Tom Rini April 19, 2017, 5:29 p.m. UTC | #2
On Tue, Apr 18, 2017 at 10:35:30PM +0200, Álvaro Fernández Rojas wrote:

> Provide an u-boot.elf binary for Broadcom MIPS platforms by re-using
> the already existing Makefile target for aarch64.
> This u-boot.elf binary should be used as a stage 2 loader
> until U-Boot can be replace the original Broadcom boot loader.
> 
> Split patches from main BMIPS support.
> 
> Álvaro Fernández Rojas (3):
>   u-boot.elf: remove hard-coded arm64 flags
>   u-boot.elf: fix entry symbol not found warning
>   MIPS: add support for generating u-boot.elf
> 
>  Makefile            | 14 ++++++--------
>  arch/arm/config.mk  |  6 ++++++
>  arch/mips/config.mk |  1 +
>  3 files changed, 13 insertions(+), 8 deletions(-)

Can you please do a patch #4 that moves from using '@' in the command to
quiet_cmd_xxx/cmd_xxx so that we see output normally about building
u-boot.elf?  Thanks!
diff mbox

Patch

diff --git a/Makefile b/Makefile
index 8d4e605..8093a6b 100644
--- a/Makefile
+++ b/Makefile
@@ -747,6 +747,9 @@  BOARD_SIZE_CHECK =
 endif
 
 # Statically apply RELA-style relocations (currently arm64 only)
+# This is useful for arm64 where static relocation needs to be performed on
+# the raw binary, but certain simulators only accept an ELF file (but don't
+# do the relocation).
 ifneq ($(CONFIG_STATIC_RELA),)
 # $(1) is u-boot ELF, $(2) is u-boot bin, $(3) is text base
 DO_STATIC_RELA = \
@@ -758,7 +761,8 @@  DO_STATIC_RELA =
 endif
 
 # Always append ALL so that arch config.mk's can add custom ones
-ALL-y += u-boot.srec u-boot.bin u-boot.sym System.map binary_size_check
+ALL-y += u-boot.srec u-boot.bin u-boot.elf u-boot.sym
+ALL-y += System.map binary_size_check
 
 ALL-$(CONFIG_ONENAND_U_BOOT) += u-boot-onenand.bin
 ifeq ($(CONFIG_SPL_FSL_PBL),y)
@@ -785,7 +789,6 @@  ALL-$(CONFIG_OF_HOSTFILE) += u-boot.dtb
 ifneq ($(CONFIG_SPL_TARGET),)
 ALL-$(CONFIG_SPL) += $(CONFIG_SPL_TARGET:"%"=%)
 endif
-ALL-$(CONFIG_REMAKE_ELF) += u-boot.elf
 ALL-$(CONFIG_EFI_APP) += u-boot-app.efi
 ALL-$(CONFIG_EFI_STUB) += u-boot-payload.efi
 
@@ -1180,16 +1183,18 @@  OBJCOPYFLAGS_u-boot-img-spl-at-end.bin := -I binary -O binary \
 u-boot-img-spl-at-end.bin: u-boot.img spl/u-boot-spl.bin FORCE
 	$(call if_changed,pad_cat)
 
-# Create a new ELF from a raw binary file.  This is useful for arm64
-# where static relocation needs to be performed on the raw binary,
-# but certain simulators only accept an ELF file (but don't do the
-# relocation).
+# Create a new ELF from a raw binary file.
 # FIXME refactor dts/Makefile to share target/arch detection
+ifdef CONFIG_64BIT
+O_FORMAT := $(shell $(OBJDUMP) -i | head -2 | grep elf64)
+else
+O_FORMAT := $(shell $(OBJDUMP) -i | head -2 | grep elf32)
+endif
 u-boot.elf: u-boot.bin
-	@$(OBJCOPY)  -B aarch64 -I binary -O elf64-littleaarch64 \
+	@$(OBJCOPY) -B $(ARCH) -I binary -O $(O_FORMAT) \
 		$< u-boot-elf.o
 	@$(LD) u-boot-elf.o -o $@ \
-		--defsym=_start=$(CONFIG_SYS_TEXT_BASE) \
+		--defsym=__start=$(CONFIG_SYS_TEXT_BASE) \
 		-Ttext=$(CONFIG_SYS_TEXT_BASE)
 
 # Rule to link u-boot