[U-Boot] [PATCH] relocation: Do not relocate NULL pointers.

Joakim Tjernlund Joakim.Tjernlund at transmode.se
Wed Sep 23 13:51:46 CEST 2009


NULL is an absolute value and should not be relocated.
After this correction code like:
 void weak_fun(void) __attribute__((weak));
 printf("weak_fun:%p\n", weak_fun);
will still print null after relocation.

Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund at transmode.se>
---

I have only tested this on 83xx and on a somewhat older u-boot.
The change is exactly the same on all PowerPC platforms though.

 cpu/mpc512x/start.S |    6 ++++--
 cpu/mpc5xx/start.S  |    6 ++++--
 cpu/mpc5xxx/start.S |    6 ++++--
 cpu/mpc8220/start.S |    6 ++++--
 cpu/mpc824x/start.S |    6 ++++--
 cpu/mpc8260/start.S |    6 ++++--
 cpu/mpc83xx/start.S |    6 ++++--
 cpu/mpc85xx/start.S |    6 ++++--
 cpu/mpc86xx/start.S |    6 ++++--
 cpu/mpc8xx/start.S  |    6 ++++--
 10 files changed, 40 insertions(+), 20 deletions(-)

diff --git a/cpu/mpc512x/start.S b/cpu/mpc512x/start.S
index 360682d..a00e045 100644
--- a/cpu/mpc512x/start.S
+++ b/cpu/mpc512x/start.S
@@ -609,15 +609,17 @@ in_ram:
 	sub	r11,r3,r11
 	addi	r3,r3,-4
 1:	lwzu	r0,4(r3)
+	cmpwi	r0,0
+	beq-	2f
 	add	r0,r0,r11
 	stw	r0,0(r3)
-	bdnz	1b
+2:	bdnz	1b
 
 	/*
 	 * Now adjust the fixups and the pointers to the fixups
 	 * in case we need to move ourselves again.
 	 */
-2:	li	r0,__fixup_entries at sectoff@l
+	li	r0,__fixup_entries at sectoff@l
 	lwz	r3,GOT(_FIXUP_TABLE_)
 	cmpwi	r0,0
 	mtctr	r0
diff --git a/cpu/mpc5xx/start.S b/cpu/mpc5xx/start.S
index 106935c..85ea7a8 100644
--- a/cpu/mpc5xx/start.S
+++ b/cpu/mpc5xx/start.S
@@ -458,15 +458,17 @@ in_ram:
 	sub	r11,r3,r11
 	addi	r3,r3,-4
 1:	lwzu	r0,4(r3)
+	cmpwi	r0,0
+	beq-	2f
 	add	r0,r0,r11
 	stw	r0,0(r3)
-	bdnz	1b
+2:	bdnz	1b
 
 	/*
 	 * Now adjust the fixups and the pointers to the fixups
 	 * in case we need to move ourselves again.
 	 */
-2:	li	r0,__fixup_entries at sectoff@l
+	li	r0,__fixup_entries at sectoff@l
 	lwz	r3,GOT(_FIXUP_TABLE_)
 	cmpwi	r0,0
 	mtctr	r0
diff --git a/cpu/mpc5xxx/start.S b/cpu/mpc5xxx/start.S
index 6b1162a..eb42939 100644
--- a/cpu/mpc5xxx/start.S
+++ b/cpu/mpc5xxx/start.S
@@ -684,15 +684,17 @@ in_ram:
 	sub	r11,r3,r11
 	addi	r3,r3,-4
 1:	lwzu	r0,4(r3)
+	cmpwi	r0,0
+	beq-	2f
 	add	r0,r0,r11
 	stw	r0,0(r3)
-	bdnz	1b
+2:	bdnz	1b
 
 	/*
 	 * Now adjust the fixups and the pointers to the fixups
 	 * in case we need to move ourselves again.
 	 */
-2:	li	r0,__fixup_entries at sectoff@l
+	li	r0,__fixup_entries at sectoff@l
 	lwz	r3,GOT(_FIXUP_TABLE_)
 	cmpwi	r0,0
 	mtctr	r0
diff --git a/cpu/mpc8220/start.S b/cpu/mpc8220/start.S
index 3abc619..af9472d 100644
--- a/cpu/mpc8220/start.S
+++ b/cpu/mpc8220/start.S
@@ -649,15 +649,17 @@ in_ram:
 	sub	r11,r3,r11
 	addi	r3,r3,-4
 1:	lwzu	r0,4(r3)
+	cmpwi	r0,0
+	beq-	2f
 	add	r0,r0,r11
 	stw	r0,0(r3)
-	bdnz	1b
+2:	bdnz	1b
 
 	/*
 	 * Now adjust the fixups and the pointers to the fixups
 	 * in case we need to move ourselves again.
 	 */
-2:	li	r0,__fixup_entries at sectoff@l
+	li	r0,__fixup_entries at sectoff@l
 	lwz	r3,GOT(_FIXUP_TABLE_)
 	cmpwi	r0,0
 	mtctr	r0
diff --git a/cpu/mpc824x/start.S b/cpu/mpc824x/start.S
index 39325cd..750457b 100644
--- a/cpu/mpc824x/start.S
+++ b/cpu/mpc824x/start.S
@@ -589,15 +589,17 @@ in_ram:
 	sub	r11,r3,r11
 	addi	r3,r3,-4
 1:	lwzu	r0,4(r3)
+	cmpwi	r0,0
+	beq-	2f
 	add	r0,r0,r11
 	stw	r0,0(r3)
-	bdnz	1b
+2:	bdnz	1b
 
 	/*
 	 * Now adjust the fixups and the pointers to the fixups
 	 * in case we need to move ourselves again.
 	 */
-2:	li	r0,__fixup_entries at sectoff@l
+	li	r0,__fixup_entries at sectoff@l
 	lwz	r3,GOT(_FIXUP_TABLE_)
 	cmpwi	r0,0
 	mtctr	r0
diff --git a/cpu/mpc8260/start.S b/cpu/mpc8260/start.S
index 379f2fb..edb95e6 100644
--- a/cpu/mpc8260/start.S
+++ b/cpu/mpc8260/start.S
@@ -909,15 +909,17 @@ in_ram:
 	sub	r11,r3,r11
 	addi	r3,r3,-4
 1:	lwzu	r0,4(r3)
+	cmpwi	r0,0
+	beq-	2f
 	add	r0,r0,r11
 	stw	r0,0(r3)
-	bdnz	1b
+2:	bdnz	1b
 
 	/*
 	 * Now adjust the fixups and the pointers to the fixups
 	 * in case we need to move ourselves again.
 	 */
-2:	li	r0,__fixup_entries at sectoff@l
+	li	r0,__fixup_entries at sectoff@l
 	lwz	r3,GOT(_FIXUP_TABLE_)
 	cmpwi	r0,0
 	mtctr	r0
diff --git a/cpu/mpc83xx/start.S b/cpu/mpc83xx/start.S
index 26e3106..ee4b862 100644
--- a/cpu/mpc83xx/start.S
+++ b/cpu/mpc83xx/start.S
@@ -957,16 +957,18 @@ in_ram:
 	sub	r11,r3,r11
 	addi	r3,r3,-4
 1:	lwzu	r0,4(r3)
+	cmpwi	r0,0
+	beq-	2f
 	add	r0,r0,r11
 	stw	r0,0(r3)
-	bdnz	1b
+2:	bdnz	1b
 
 #ifndef CONFIG_NAND_SPL
 	/*
 	 * Now adjust the fixups and the pointers to the fixups
 	 * in case we need to move ourselves again.
 	 */
-2:	li	r0,__fixup_entries at sectoff@l
+	li	r0,__fixup_entries at sectoff@l
 	lwz	r3,GOT(_FIXUP_TABLE_)
 	cmpwi	r0,0
 	mtctr	r0
diff --git a/cpu/mpc85xx/start.S b/cpu/mpc85xx/start.S
index 4f7236f..d56003b 100644
--- a/cpu/mpc85xx/start.S
+++ b/cpu/mpc85xx/start.S
@@ -932,15 +932,17 @@ in_ram:
 	sub	r11,r3,r11
 	addi	r3,r3,-4
 1:	lwzu	r0,4(r3)
+	cmpwi	r0,0
+	beq-	2f
 	add	r0,r0,r11
 	stw	r0,0(r3)
-	bdnz	1b
+2:	bdnz	1b
 
 	/*
 	 * Now adjust the fixups and the pointers to the fixups
 	 * in case we need to move ourselves again.
 	 */
-2:	li	r0,__fixup_entries at sectoff@l
+	li	r0,__fixup_entries at sectoff@l
 	lwz	r3,GOT(_FIXUP_TABLE_)
 	cmpwi	r0,0
 	mtctr	r0
diff --git a/cpu/mpc86xx/start.S b/cpu/mpc86xx/start.S
index 63cc8db..e65f1c0 100644
--- a/cpu/mpc86xx/start.S
+++ b/cpu/mpc86xx/start.S
@@ -733,15 +733,17 @@ in_ram:
 	sub	r11,r3,r11
 	addi	r3,r3,-4
 1:	lwzu	r0,4(r3)
+	cmpwi	r0,0
+	beq-	2f
 	add	r0,r0,r11
 	stw	r0,0(r3)
-	bdnz	1b
+2:	bdnz	1b
 
 	/*
 	 * Now adjust the fixups and the pointers to the fixups
 	 * in case we need to move ourselves again.
 	 */
-2:	li	r0,__fixup_entries at sectoff@l
+	li	r0,__fixup_entries at sectoff@l
 	lwz	r3,GOT(_FIXUP_TABLE_)
 	cmpwi	r0,0
 	mtctr	r0
diff --git a/cpu/mpc8xx/start.S b/cpu/mpc8xx/start.S
index 8864c37..e84326e 100644
--- a/cpu/mpc8xx/start.S
+++ b/cpu/mpc8xx/start.S
@@ -589,15 +589,17 @@ in_ram:
 	sub	r11,r3,r11
 	addi	r3,r3,-4
 1:	lwzu	r0,4(r3)
+	cmpwi	r0,0
+	beq-	2f
 	add	r0,r0,r11
 	stw	r0,0(r3)
-	bdnz	1b
+2:	bdnz	1b
 
 	/*
 	 * Now adjust the fixups and the pointers to the fixups
 	 * in case we need to move ourselves again.
 	 */
-2:	li	r0,__fixup_entries at sectoff@l
+	li	r0,__fixup_entries at sectoff@l
 	lwz	r3,GOT(_FIXUP_TABLE_)
 	cmpwi	r0,0
 	mtctr	r0
-- 
1.6.4.4



More information about the U-Boot mailing list