ar71xx: add relocation loader
authorMatthias Schiffer <mschiffer@universe-factory.net>
Tue, 11 Oct 2016 18:32:25 +0000 (20:32 +0200)
committerMatthias Schiffer <mschiffer@universe-factory.net>
Tue, 11 Oct 2016 18:39:16 +0000 (20:39 +0200)
Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
target/linux/ar71xx/image/Makefile
target/linux/ar71xx/image/legacy.mk

index bce5cd3774457f65c5379a968df447d12b4a2383..56e07d82f3338d2fe2b05a495a2297818372b80e 100644 (file)
@@ -78,6 +78,15 @@ define Build/loader-okli
        mv "$@.new" "$@"
 endef
 
+define Build/relocate-kernel
+       ( \
+               dd if=$(KDIR)/relocate.bin bs=32 conv=sync && \
+               perl -e '@s = stat("$@"); print pack("N", @s[7])' && \
+               cat "$@" \
+       ) > "$@.new"
+       mv "$@.new" "$@"
+endef
+
 define Build/copy-file
        cat "$(1)" > "$@"
 endef
index 92f3469b7328d6454072692077a6860e0a717a5b..ed01dc77c127136649e08c319effb0551a6931f4 100644 (file)
@@ -1103,6 +1103,12 @@ ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
        $(call Image/BuildLoader,generic,elf,,,-initramfs)
 endif
        $(call Image/BuildLoader,generic,elf)
+
+       # Note: not only used for legacy images
+       rm -rf $(KDIR)/relocate
+       $(CP) ../../generic/image/relocate $(KDIR)
+       $(MAKE) -C $(KDIR)/relocate KERNEL_ADDR=$(KERNEL_LOADADDR) CROSS_COMPILE=$(TARGET_CROSS)
+       $(CP) $(KDIR)/relocate/loader.bin $(KDIR)/relocate.bin
 endef
 
 define Image/Prepare/Profile