
+cc more people involved with ARM
note: purpose of this patch is to 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.
Am 16.04.2017 um 00:04 schrieb Álvaro Fernández Rojas:
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(-)
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
the current behaviour shouldn't be changed where u-boot.elf is only built when requested by a board
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
this should be set in arch/ARCH/config.mk. Also this is already contained in OBJCOPYFLAGS. Either we can filter out the value for -O from OBJCOPYFLAGS or we define an extra variable like PLATFORM_ELFFLAGS or OBJCOPYFLAGS_ELF where we assign the values for -B and -O.
For example: --- a/arch/mips/config.mk +++ b/arch/mips/config.mk @@ -36,6 +36,7 @@ OBJCOPYFLAGS += -O $(64bit-bfd) endif
PLATFORM_CPPFLAGS += -D__MIPS__ +PLATFORM_ELFFLAGS += -B mips $(OBJCOPYFLAGS)
--- a/arch/arm/config.mk +++ b/arch/arm/config.mk @@ -30,6 +30,12 @@ PLATFORM_RELFLAGS += $(LLVM_RELFLAGS)
PLATFORM_CPPFLAGS += -D__ARM__
+ifdef CONFIG_ARM64 +PLATFORM_ELFFLAGS += -B aarch64 -O elf64-littleaarch64 +else +PLATFORM_ELFFLAGS += -B arm -O elf32-littlearm +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) \
I'm not sure but changing to __start for all could break aarch64 boards.
-Ttext=$(CONFIG_SYS_TEXT_BASE)
# Rule to link u-boot