Commit f4dc714aaa2d86b84724ec01fb848da63aa63666

Authored by Scott Wood
Committed by Albert ARIBAUD
1 parent 8137af19e7

arm64: Turn u-boot.bin back into an ELF file after relocate-rela

While performing relocations on u-boot.bin should be good enough for
booting on real hardware, some simulators insist on booting an ELF file
(and yet don't perform ELF relocations), so convert the relocated
binary back into an ELF file.  This can go away in the future if we
change relocate-rela to operate directly on the ELF file, or if and
when we stop caring about a simulator with this restriction.

Signed-off-by: Scott Wood <scottwood@freescale.com>
Signed-off-by: David Feng <fenghua@phytium.com.cn>

Showing 1 changed file with 13 additions and 0 deletions Side-by-side Diff

... ... @@ -358,6 +358,7 @@
358 358 ifneq ($(CONFIG_SPL_TARGET),)
359 359 ALL-$(CONFIG_SPL) += $(obj)$(subst ",,$(CONFIG_SPL_TARGET))
360 360 endif
  361 +ALL-$(CONFIG_REMAKE_ELF) += $(obj)u-boot.elf
361 362  
362 363 # enable combined SPL/u-boot/dtb rules for tegra
363 364 ifneq ($(CONFIG_TEGRA),)
... ... @@ -527,6 +528,18 @@
527 528 dd if=$(obj)u-boot.img of=$(obj)u-boot-pad.img \
528 529 conv=notrunc 2>/dev/null
529 530 cat $(obj)u-boot-pad.img $(obj)spl/u-boot-spl.bin > $@
  531 +
  532 +# Create a new ELF from a raw binary file. This is useful for arm64
  533 +# where static relocation needs to be performed on the raw binary,
  534 +# but certain simulators only accept an ELF file (but don't do the
  535 +# relocation).
  536 +# FIXME refactor dts/Makefile to share target/arch detection
  537 +$(obj)u-boot.elf: $(obj)u-boot.bin
  538 + @$(OBJCOPY) -B aarch64 -I binary -O elf64-littleaarch64 \
  539 + $< $(obj)u-boot-elf.o
  540 + @$(LD) $(obj)u-boot-elf.o -o $@ \
  541 + --defsym=_start=$(CONFIG_SYS_TEXT_BASE) \
  542 + -Ttext=$(CONFIG_SYS_TEXT_BASE)
530 543  
531 544 ifeq ($(CONFIG_SANDBOX),y)
532 545 GEN_UBOOT = \