@@ -102,6 +102,12 @@ endif
# needed for relocation
LDFLAGS_u-boot += -pie
+ifndef CONFIG_SPL_SKIP_RELOCATE
+LDFLAGS_u-boot-spl = -pie
+else
+SPL_LDFLAGS_u-boot-spl =
+endif
+
#
# FIXME: binutils versions < 2.22 have a bug in the assembler where
# branches to weak symbols can be incorrectly optimized in thumb mode
@@ -35,7 +35,11 @@ _start:
.globl _TEXT_BASE
_TEXT_BASE:
+#if defined(CONFIG_SPL_BUILD)
+ .quad CONFIG_SPL_TEXT_BASE
+#else
.quad CONFIG_SYS_TEXT_BASE
+#endif
/*
* These are defined in the linker script.
@@ -53,6 +53,23 @@ SECTIONS
*(.__end)
} >.sram
+#ifndef CONFIG_SPL_SKIP_RELOCATE
+ . = ALIGN(8);
+
+ .rel_dyn_start :
+ {
+ *(.__rel_dyn_start)
+ } >.sram
+
+ .rela.dyn : {
+ *(.rela*)
+ } >.sram
+
+ .rel_dyn_end :
+ {
+ *(.__rel_dyn_end)
+ } >.sram
+#endif
_image_binary_end = .;
.bss_start (NOLOAD) : {
@@ -21,7 +21,7 @@ else
obj-y += setjmp.o
endif
-ifndef CONFIG_SPL_BUILD
+ifndef CONFIG_TPL_BUILD
ifdef CONFIG_ARM64
obj-y += relocate_64.o
else
@@ -89,7 +89,8 @@ ENTRY(_main)
mov x0, #0
bl board_init_f
-#if !defined(CONFIG_SPL_BUILD)
+#if (defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD) && !defined(CONFIG_SPL_SKIP_RELOCATE)) || \
+ !defined(CONFIG_SPL_BUILD)
/*
* Set up intermediate environment (new sp and gd) and call
* relocate_code(addr_moni). Trick here is that we'll return
Some times we want to relocate spl code to dram after dram initialization or relocate spl code to a high memory to avoid code overid. For example on Rockchip armv8 platform, we run with boot flow TPL->SPL->ATF->U-Boot. TPL run in sram and is responsible for dram initialization. SPL run from the start address of dram and is responsible for loading ATF and U-Boot. The case here is that the ATF load address is from 64KB of dram, which overlaps with spl code itself. So we want to relocate spl itself to high memory to aovid this. Signed-off-by: Andy Yan <andy.yan@rock-chips.com> --- Changes in v2: - Add more detial commit message arch/arm/config.mk | 6 ++++++ arch/arm/cpu/armv8/start.S | 4 ++++ arch/arm/cpu/armv8/u-boot-spl.lds | 17 +++++++++++++++++ arch/arm/lib/Makefile | 2 +- arch/arm/lib/crt0_64.S | 3 ++- 5 files changed, 30 insertions(+), 2 deletions(-)