Confusing memory layout after spl_relocate_stack_gd()

Ronald Wahl rwahl at gmx.de
Sat Feb 7 13:42:18 CET 2026


Hi,

I'm a bit confused about the stack location after calling 
spl_relocate_stack_gd(). Looking at the code of this function I see that 
the stack pointer is in the simple_malloc heap before the global data. 
That means that the stack is growing downwards into the heap. Also the 
malloc_limit includes the global data memory. This looks quite odd. 
Wouldn't it be better to set the stack base the same address as malloc_base?

In the documentation[1] there is also a picture (DRAM SPL after 
relocation) that illustrates this. The Stack region is just placed wrong 
there and never used as the stack grows downwards. It must be above 
malloc_base.

If you think my thoughts are correct I can prepare a patch.

thanks,
ron

[1] https://docs.u-boot.org/en/latest/develop/memory.html


More information about the U-Boot mailing list