[PATCH 1/2] ARM: cpu: setupc: relocate BSS in relocate_to_adr()

Ahmad Fatoum a.fatoum at pengutronix.de
Thu Mar 12 12:20:42 PDT 2026


When calling relocate_to_adr(), barebox is copied without BSS to a new
place. The new BSS region is not necessarily zeroed, but setupc()
following relocate_to_adr() will take care of that.

With incoming change to make setupc() idempotent, this will become
problematic as the variable in .data will indicate that the BSS is
zeroed, while the new BSS region isn't actually.

We usually have very little BSS in the PBL, so copying it is not much
more effort, so let's just do that.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
Please apply before "ARM: setup_c: avoid clearing BSS twice"
---
 arch/arm/cpu/setupc_32.S | 4 ++--
 arch/arm/cpu/setupc_64.S | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm/cpu/setupc_32.S b/arch/arm/cpu/setupc_32.S
index 61b8152599f1..c5348353b129 100644
--- a/arch/arm/cpu/setupc_32.S
+++ b/arch/arm/cpu/setupc_32.S
@@ -39,12 +39,12 @@ bss_cleared:
 .section .text.relocate_to_adr
 #ifdef __PBL__
 ENTRY(relocate_to_adr_full)
-	ldr	r2, =__image_end
+	ldr	r2, =__image_end	/* include piggy data */
 	b	1f
 #endif
 
 ENTRY(relocate_to_adr)
-	ldr	r2, =__bss_start
+	ldr	r2, =__bss_stop		/* skip piggy data */
 	b	1f
 
 1:
diff --git a/arch/arm/cpu/setupc_64.S b/arch/arm/cpu/setupc_64.S
index 8fd7f2f9b60f..d5a6c0c43a7b 100644
--- a/arch/arm/cpu/setupc_64.S
+++ b/arch/arm/cpu/setupc_64.S
@@ -40,12 +40,12 @@ bss_cleared:
 					/* x0: target address */
 #ifdef __PBL__
 ENTRY(relocate_to_adr_full)
-	adr_l	x2, __image_end
+	adr_l	x2, __image_end		/* include piggy data */
 	b	1f
 #endif
 
 ENTRY(relocate_to_adr)
-	adr_l	x2, __bss_start
+	adr_l	x2, __bss_stop		/* skip piggy data */
 	b	1f
 
 1:
-- 
2.47.3




More information about the barebox mailing list