[PATCH] arm: relocate: Introduce data-only relocation mode
Ilias Apalodimas
ilias.apalodimas at linaro.org
Wed Mar 18 07:59:58 CET 2026
Hi Marek
On Mon, 16 Mar 2026 at 01:55, Marek Vasut
<marek.vasut+renesas at mailbox.org> wrote:
>
> Introduce new mode of relocation which relocates only data, not code.
> This is mainly meant to relocate data to read-write portion of the RAM,
> while the code remains in read-only portion of the RAM from which it is
> allowed to execute. This split configuration is present on various secure
> cores.
>
> The result of the relocation is U-Boot running at its original address,
> data relocated to the end of DRAM, but with added read-write area offset.
> The U-Boot binary area is not reserved from the end of the DRAM in this
> relocation mode, because U-Boot itself is not relocated.
We should mention at some point in the commit message that this is for v7 only.
[...]
> +config SKIP_RELOCATE_CODE
> + bool "Skips relocation of U-Boot code to end of RAM"
> + help
> + Skips relocation of U-Boot code to the end of RAM, but still does
> + relocate data to the end of RAM. This is mainly meant to relocate
> + data to read-write portion of the RAM, while the code remains in
> + read-only portion of the RAM from which it is allowed to execute.
> + This split configuration is present on various secure cores.
> +
> +config SKIP_RELOCATE_CODE_DATA_OFFSET
> + hex "Offset of read-write data memory from read-only text memory"
> + default 0x0
> + depends on SKIP_RELOCATE_CODE
> + help
> + Offset of the read-write memory which contains data, from read-only
> + memory which contains executable text.
> +
Similar concerns with Tom for limiting the Kconfig selection. Do we
need a depends on the armv7 arch for now ?
> endif # EXPERT
>
> config PHYS_64BIT
> diff --git a/arch/arm/lib/crt0.S b/arch/arm/lib/crt0.S
> index d10c129705d..f2c5aa37a8f 100644
[...]
>
> /*
> * fix .rel.dyn relocations
> @@ -107,6 +117,15 @@ fixloop:
> /* relative fix: increase location by offset */
> add r0, r0, r4
> ldr r1, [r0]
> +
> +#ifdef CONFIG_SKIP_RELOCATE_CODE
> + /* Test whether this is data, if not, do not relocate. */
> + cmp r1, r5
> + blt fixnext
> + cmp r1, r6
> + bgt fixnext
> +#endif
> +
> add r1, r1, r4
> str r1, [r0]
> fixnext:
> @@ -126,3 +145,9 @@ _rel_dyn_start_ofs:
> .word __rel_dyn_start - relocate_code
> _rel_dyn_end_ofs:
> .word __rel_dyn_end - relocate_code
> +#ifdef CONFIG_SKIP_RELOCATE_CODE
> +_data_start_ofs:
> + .word __data_start - relocate_code
> +_data_end_ofs:
> + .word __data_end - relocate_code
> +#endif
Where are these defined? __data_[start|end] only seem to exist for x86
and microblaze
[...]
Overall this seems to be needed, I am a little concerned about test
coverage, since this will be fragile when changing asm and/or linker
scripts. But OTOH I dont have any bright ideas on how to test it
Thanks
/Ilias
More information about the U-Boot
mailing list