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 <nolt...@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 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 -- 2.1.4 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot