[PATCH] arm: relocate: Introduce data-only relocation mode

Marek Vasut marek.vasut at mailbox.org
Sat Mar 28 01:07:29 CET 2026


On 3/18/26 7:59 AM, Ilias Apalodimas wrote:

Hello Ilias,

>> 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.

I actually do use this on V8M .

> [...]
> 
>> +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 ?

No, because I use it on V8M.

>> @@ -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

Currently, I have to use own linker script, the data section looks like 
this:

"
	. = ALIGN(4);
	.data : {
		__data_start = .;
		*(.data*)
		__data_end = .;
	}
"

Any system which will use this will have to patch the start/end in their 
data section too, or ideally if they use generic linker script, patch 
that generic linker script to emit those symbols. Maybe we should patch 
at least arch/arm/cpu/u-boot.lds ?

> [...]
> 
> 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
Maybe QEMU can be extended with Cortex-M support ?


More information about the U-Boot mailing list