arm64: Properly clear BSS

Brock reports a breakage on an RK3568 SoC. His patch is
correct but he never followed up on the requested changes.

We currently use ldr to calculate the address of __bss_start and
__bss_end. However the absolute addresses of the literal pool are never
relocated and we end up clearing the wrong memory section. Use
PC-relative addressing instead.

Link: https://lore.kernel.org/u-boot/zfknlzcemnnaka5w2er5wjwefwoidrpndc4gjhx6d5xr6nlcjr@pasfayjiutii/

Suggested-by: brock_zheng <yzheng@techyauld.com>
Reported-by: brock_zheng <yzheng@techyauld.com>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
This commit is contained in:
Ilias Apalodimas
2025-09-02 09:08:12 +03:00
committed by Tom Rini
parent a5b483a52a
commit 5d01a97180

View File

@@ -158,8 +158,10 @@ relocation_return:
/*
* Clear BSS section
*/
ldr x0, =__bss_start /* this is auto-relocated! */
ldr x1, =__bss_end /* this is auto-relocated! */
adrp x0, __bss_start
add x0, x0, #:lo12:__bss_start
adrp x1, __bss_end
add x1, x1, #:lo12:__bss_end
clear_loop:
str xzr, [x0], #8
cmp x0, x1