Skip to contentSkip to conversation

Fix ppc4xx clear_bss() code

PATCH New Anatolij Gustschin 3 participants 3 messages Dec 5, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix ppc4xx clear_bss() code

ppc4xx clear_bss() fails if BSS segment size is not divisible by 4 without remainder. This patch provides fix for this problem.

---
 cpu/ppc4xx/start.S |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)
cpu/ppc4xx/start.S +13 -4
index 9626b65..9175e31 100644
@@ -1566,16 +1566,25 @@ clear_bss:
 	lwz	r4,GOT(_end)
 
 	cmplw	0, r3, r4
-	beq	6f
+	beq	7f
 
 	li	r0, 0
-5:
+
+	andi.	r5, r4, 3
+	beq	6f
+	sub	r4, r4, r5
+	mtctr	r5
+	mr	r5, r4
+5:	stb	r0, 0(r5)
+	addi	r5, r5, 1
+	bdnz	5b
+6:
 	stw	r0, 0(r3)
 	addi	r3, r3, 4
 	cmplw	0, r3, r4
-	bne	5b
-6:
+	bne	6b
 
+7:
 	mr	r3, r9		/* Init Data pointer		*/
 	mr	r4, r10		/* Destination Address		*/
 	bl	board_init_r
Signature · 1 line
1.5.3.3
#1 lore raw

PATCH 1/1 Fix ppc4xx clear_bss() code

Quoted 3 lines · On Wed, 5 Dec 2007 17:43:20 +0100 agustschin at t-online.de (Anatolij…

ppc4xx clear_bss() fails if BSS segment size is not divisible by 4 without remainder. This patch provides fix for this problem.

Isn't it better to fix the linker script so that the size _is_ divisible by 4?

Haavard

#2 lore raw

PATCH 1/1 Fix ppc4xx clear_bss() code

Quoted 7 lines · In message <20071205194258.79f67211@siona> you wrote:
Quoted 4 lines

ppc4xx clear_bss() fails if BSS segment size is not divisible by 4 without remainder. This patch provides fix for this problem.

Isn't it better to fix the linker script so that the size _is_ divisible by 4?

From the robustness point of view Anatolij's patch is needed - it is a desirable feature of software to show correct behaviour even with (slightly) wrong input.

ACKED.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
One essential to success is that you desire be an all-obsessing  one,
your thoughts and aims be co-ordinated, and your energy be concentra-
ted and applied without letup.