[U-Boot] [PATCH 2/4] ppc: Use r12 instead of r14 as GOT pointer.

Joakim Tjernlund Joakim.Tjernlund at transmode.se
Tue Jan 19 14:41:56 CET 2010


r14 is not supposed to be clobbered by functions. Switch
to r12 and call GET_GOT when needed. This will allow u-boot
to loose the -ffixed-r14 gcc option.

Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund at transmode.se>
---
 cpu/74xx_7xx/start.S |   11 ++++++-----
 cpu/mpc512x/start.S  |   11 ++++++-----
 cpu/mpc5xx/start.S   |   11 ++++++-----
 cpu/mpc5xxx/start.S  |   11 ++++++-----
 cpu/mpc8220/start.S  |   11 ++++++-----
 cpu/mpc824x/start.S  |   11 ++++++-----
 cpu/mpc8260/start.S  |   15 +++++++++------
 cpu/mpc83xx/start.S  |   11 ++++++-----
 cpu/mpc85xx/start.S  |   11 ++++++-----
 cpu/mpc86xx/start.S  |   11 ++++++-----
 cpu/mpc8xx/start.S   |   11 ++++++-----
 cpu/ppc4xx/start.S   |   11 ++++++-----
 include/ppc_asm.tmpl |    8 ++++----
 13 files changed, 79 insertions(+), 65 deletions(-)

diff --git a/cpu/74xx_7xx/start.S b/cpu/74xx_7xx/start.S
index efcd95f..88fdf88 100644
--- a/cpu/74xx_7xx/start.S
+++ b/cpu/74xx_7xx/start.S
@@ -63,7 +63,7 @@
 /*
  * Set up GOT: Global Offset Table
  *
- * Use r14 to access the GOT
+ * Use r12 to access the GOT
  */
 	START_GOT
 	GOT_ENTRY(_GOT2_TABLE_)
@@ -599,6 +599,7 @@ relocate_code:
 	mr	r9,  r4		/* Save copy of Global Data pointer	*/
 	mr	r10, r5		/* Save copy of Destination Address	*/
 
+	GET_GOT
 	mr	r3,  r5				/* Destination Address	*/
 	lis	r4, CONFIG_SYS_MONITOR_BASE at h		/* Source      Address	*/
 	ori	r4, r4, CONFIG_SYS_MONITOR_BASE at l
@@ -616,7 +617,7 @@ relocate_code:
 	sub	r15, r10, r4
 
 	/* First our own GOT */
-	add	r14, r14, r15
+	add	r12, r12, r15
 	/* then the one used by the C code */
 	add	r30, r30, r15
 
@@ -691,7 +692,7 @@ in_ram:
 	bl	board_init_ecc
 #endif
 	/*
-	 * Relocation Function, r14 point to got2+0x8000
+	 * Relocation Function, r12 point to got2+0x8000
 	 *
 	 * Adjust got2 pointers, no need to check for 0, this code
 	 * already puts a few entries in the table.
@@ -765,6 +766,8 @@ in_ram:
 	 */
 	.globl	trap_init
 trap_init:
+	mflr	r4			/* save link register		*/
+	GET_GOT
 	lwz	r7, GOT(_start)
 	lwz	r8, GOT(_end_of_vectors)
 
@@ -772,8 +775,6 @@ trap_init:
 
 	cmplw	0, r7, r8
 	bgelr				/* return if r7>=r8 - just in case */
-
-	mflr	r4			/* save link register		*/
 1:
 	lwz	r0, 0(r7)
 	stw	r0, 0(r9)
diff --git a/cpu/mpc512x/start.S b/cpu/mpc512x/start.S
index 46c5efa..d26b617 100644
--- a/cpu/mpc512x/start.S
+++ b/cpu/mpc512x/start.S
@@ -65,7 +65,7 @@
 /*
  * Set up GOT: Global Offset Table
  *
- * Use r14 to access the GOT
+ * Use r12 to access the GOT
  */
 	START_GOT
 	GOT_ENTRY(_GOT2_TABLE_)
@@ -486,6 +486,7 @@ relocate_code:
 	mr	r9,  r4		/* Save copy of Global Data pointer */
 	mr	r10, r5		/* Save copy of Destination Address */
 
+	GET_GOT
 	mr	r3,  r5				/* Destination Address */
 	lis	r4, CONFIG_SYS_MONITOR_BASE at h		/* Source      Address */
 	ori	r4, r4, CONFIG_SYS_MONITOR_BASE at l
@@ -504,7 +505,7 @@ relocate_code:
 	sub	r15, r10, r4
 
 	/* First our own GOT */
-	add	r14, r14, r15
+	add	r12, r12, r15
 	/* then the one used by the C code */
 	add	r30, r30, r15
 
@@ -584,7 +585,7 @@ relocate_code:
 
 in_ram:
 	/*
-	 * Relocation Function, r14 point to got2+0x8000
+	 * Relocation Function, r12 point to got2+0x8000
 	 *
 	 * Adjust got2 pointers, no need to check for 0, this code
 	 * already puts a few entries in the table.
@@ -648,6 +649,8 @@ clear_bss:
 	 */
 	.globl	trap_init
 trap_init:
+	mflr	r4		/* save link register */
+	GET_GOT
 	lwz	r7, GOT(_start)
 	lwz	r8, GOT(_end_of_vectors)
 
@@ -655,8 +658,6 @@ trap_init:
 
 	cmplw	0, r7, r8
 	bgelr			/* return if r7>=r8 - just in case */
-
-	mflr	r4		/* save link register */
 1:
 	lwz	r0, 0(r7)
 	stw	r0, 0(r9)
diff --git a/cpu/mpc5xx/start.S b/cpu/mpc5xx/start.S
index be980a1..0af879e 100644
--- a/cpu/mpc5xx/start.S
+++ b/cpu/mpc5xx/start.S
@@ -56,7 +56,7 @@
 /*
  * Set up GOT: Global Offset Table
  *
- * Use r14 to access the GOT
+ * Use r12 to access the GOT
  */
 	START_GOT
 	GOT_ENTRY(_GOT2_TABLE_)
@@ -372,6 +372,7 @@ relocate_code:
 	mr	r9,  r4		/* Save copy of global data pointer in SRAM */
 	mr	r10, r5		/* Save copy of monitor destination Address in SRAM */
 
+	GET_GOT
 	mr	r3,  r5				/* Destination Address	*/
 	lis	r4, CONFIG_SYS_MONITOR_BASE at h		/* Source      Address	*/
 	ori	r4, r4, CONFIG_SYS_MONITOR_BASE at l
@@ -388,7 +389,7 @@ relocate_code:
 	sub	r15, r10, r4
 
 	/* First our own GOT */
-	add	r14, r14, r15
+	add	r12, r12, r15
 	/* the the one used by the C code */
 	add	r30, r30, r15
 
@@ -433,7 +434,7 @@ relocate_code:
 in_ram:
 
 	/*
-	 * Relocation Function, r14 point to got2+0x8000
+	 * Relocation Function, r12 point to got2+0x8000
 	 *
 	 * Adjust got2 pointers, no need to check for 0, this code
 	 * already puts a few entries in the table.
@@ -497,6 +498,8 @@ clear_bss:
 	 */
 	.globl	trap_init
 trap_init:
+	mflr	r4			/* save link register		*/
+	GET_GOT
 	lwz	r7, GOT(_start)
 	lwz	r8, GOT(_end_of_vectors)
 
@@ -504,8 +507,6 @@ trap_init:
 
 	cmplw	0, r7, r8
 	bgelr				/* return if r7>=r8 - just in case */
-
-	mflr	r4			/* save link register		*/
 1:
 	lwz	r0, 0(r7)
 	stw	r0, 0(r9)
diff --git a/cpu/mpc5xxx/start.S b/cpu/mpc5xxx/start.S
index 075a7dd..d499da5 100644
--- a/cpu/mpc5xxx/start.S
+++ b/cpu/mpc5xxx/start.S
@@ -56,7 +56,7 @@
 /*
  * Set up GOT: Global Offset Table
  *
- * Use r14 to access the GOT
+ * Use r12 to access the GOT
  */
 	START_GOT
 	GOT_ENTRY(_GOT2_TABLE_)
@@ -567,6 +567,7 @@ relocate_code:
 	mr	r9,  r4		/* Save copy of Global Data pointer	*/
 	mr	r10, r5		/* Save copy of Destination Address	*/
 
+	GET_GOT
 	mr	r3,  r5				/* Destination Address	*/
 	lis	r4, CONFIG_SYS_MONITOR_BASE at h		/* Source      Address	*/
 	ori	r4, r4, CONFIG_SYS_MONITOR_BASE at l
@@ -584,7 +585,7 @@ relocate_code:
 	sub	r15, r10, r4
 
 	/* First our own GOT */
-	add	r14, r14, r15
+	add	r12, r12, r15
 	/* then the one used by the C code */
 	add	r30, r30, r15
 
@@ -657,7 +658,7 @@ relocate_code:
 in_ram:
 
 	/*
-	 * Relocation Function, r14 point to got2+0x8000
+	 * Relocation Function, r12 point to got2+0x8000
 	 *
 	 * Adjust got2 pointers, no need to check for 0, this code
 	 * already puts a few entries in the table.
@@ -722,6 +723,8 @@ clear_bss:
 	 */
 	.globl	trap_init
 trap_init:
+	mflr	r4			/* save link register		*/
+	GET_GOT
 	lwz	r7, GOT(_start)
 	lwz	r8, GOT(_end_of_vectors)
 
@@ -729,8 +732,6 @@ trap_init:
 
 	cmplw	0, r7, r8
 	bgelr				/* return if r7>=r8 - just in case */
-
-	mflr	r4			/* save link register		*/
 1:
 	lwz	r0, 0(r7)
 	stw	r0, 0(r9)
diff --git a/cpu/mpc8220/start.S b/cpu/mpc8220/start.S
index 5218c85..e28999d 100644
--- a/cpu/mpc8220/start.S
+++ b/cpu/mpc8220/start.S
@@ -55,7 +55,7 @@
 /*
  * Set up GOT: Global Offset Table
  *
- * Use r14 to access the GOT
+ * Use r12 to access the GOT
  */
 	START_GOT
 	GOT_ENTRY(_GOT2_TABLE_)
@@ -532,6 +532,7 @@ relocate_code:
 	mr	r9,  r4	    /* Save copy of Global Data pointer */
 	mr	r10, r5	    /* Save copy of Destination Address */
 
+	GET_GOT
 	mr	r3,  r5	    /* Destination Address		*/
 	lis	r4, CONFIG_SYS_MONITOR_BASE at h	/* Source Address	*/
 	ori	r4, r4, CONFIG_SYS_MONITOR_BASE at l
@@ -549,7 +550,7 @@ relocate_code:
 	sub	r15, r10, r4
 
 	/* First our own GOT */
-	add	r14, r14, r15
+	add	r12, r12, r15
 	/* then the one used by the C code */
 	add	r30, r30, r15
 
@@ -622,7 +623,7 @@ relocate_code:
 in_ram:
 
 	/*
-	 * Relocation Function, r14 point to got2+0x8000
+	 * Relocation Function, r12 point to got2+0x8000
 	 *
 	 * Adjust got2 pointers, no need to check for 0, this code
 	 * already puts a few entries in the table.
@@ -687,6 +688,8 @@ clear_bss:
 	 */
 	.globl	trap_init
 trap_init:
+	mflr	r4	    /* save link register		*/
+	GET_GOT
 	lwz	r7, GOT(_start)
 	lwz	r8, GOT(_end_of_vectors)
 
@@ -694,8 +697,6 @@ trap_init:
 
 	cmplw	0, r7, r8
 	bgelr		    /* return if r7>=r8 - just in case	*/
-
-	mflr	r4	    /* save link register		*/
 1:
 	lwz	r0, 0(r7)
 	stw	r0, 0(r9)
diff --git a/cpu/mpc824x/start.S b/cpu/mpc824x/start.S
index 7f40648..f3f595a 100644
--- a/cpu/mpc824x/start.S
+++ b/cpu/mpc824x/start.S
@@ -63,7 +63,7 @@
 /*
  * Set up GOT: Global Offset Table
  *
- * Use r14 to access the GOT
+ * Use r12 to access the GOT
  */
 	START_GOT
 	GOT_ENTRY(_GOT2_TABLE_)
@@ -462,6 +462,7 @@ relocate_code:
 	mr	r9,  r4		/* Save copy of Global Data pointer	*/
 	mr	r10, r5		/* Save copy of Destination Address	*/
 
+	GET_GOT
 	mr	r3,  r5				/* Destination Address	*/
 #ifdef CONFIG_SYS_RAMBOOT
 	lis	r4, CONFIG_SYS_SDRAM_BASE at h		/* Source      Address	*/
@@ -484,7 +485,7 @@ relocate_code:
 	sub	r15, r10, r4
 
 	/* First our own GOT */
-	add	r14, r14, r15
+	add	r12, r12, r15
 	/* the the one used by the C code */
 	add	r30, r30, r15
 
@@ -564,7 +565,7 @@ relocate_code:
 in_ram:
 
 	/*
-	 * Relocation Function, r14 point to got2+0x8000
+	 * Relocation Function, r12 point to got2+0x8000
 	 *
 	 * Adjust got2 pointers, no need to check for 0, this code
 	 * already puts a few entries in the table.
@@ -629,6 +630,8 @@ clear_bss:
 	 */
 	.globl	trap_init
 trap_init:
+	mflr	r4			/* save link register		*/
+	GET_GOT
 	lwz	r7, GOT(_start)
 	lwz	r8, GOT(_end_of_vectors)
 
@@ -636,8 +639,6 @@ trap_init:
 
 	cmplw	0, r7, r8
 	bgelr				/* return if r7>=r8 - just in case */
-
-	mflr	r4			/* save link register		*/
 1:
 	lwz	r0, 0(r7)
 	stw	r0, 0(r9)
diff --git a/cpu/mpc8260/start.S b/cpu/mpc8260/start.S
index 7d80af5..1fc70bc 100644
--- a/cpu/mpc8260/start.S
+++ b/cpu/mpc8260/start.S
@@ -56,7 +56,7 @@
 /*
  * Set up GOT: Global Offset Table
  *
- * Use r14 to access the GOT
+ * Use r12 to access the GOT
  */
 	START_GOT
 	GOT_ENTRY(_GOT2_TABLE_)
@@ -650,7 +650,9 @@ init_debug:
 	/* RAM should now be operational */
 
 #define VEC_WRD_CNT	((_end_of_vectors - _start + EXC_OFF_SYS_RESET) / 4)
-
+	mflr	r3
+	GET_GOT
+	mtlr	r3
 	lwz	r3, GOT(_end_of_vectors)
 	rlwinm	r4, r3, 0, 18, 31	/* _end_of_vectors & 0x3FFF	*/
 	lis	r5, VEC_WRD_CNT at h
@@ -792,6 +794,7 @@ relocate_code:
 	mr	r9,  r4		/* Save copy of Global Data pointer	*/
 	mr	r10, r5		/* Save copy of Destination Address	*/
 
+	GET_GOT
 	mr	r3,  r5				/* Destination Address	*/
 	lis	r4, CONFIG_SYS_MONITOR_BASE at h		/* Source      Address	*/
 	ori	r4, r4, CONFIG_SYS_MONITOR_BASE at l
@@ -809,7 +812,7 @@ relocate_code:
 	sub	r15, r10, r4
 
 	/* First our own GOT */
-	add	r14, r14, r15
+	add	r12, r12, r15
 	/* then the one used by the C code */
 	add	r30, r30, r15
 
@@ -882,7 +885,7 @@ relocate_code:
 in_ram:
 
 	/*
-	 * Relocation Function, r14 point to got2+0x8000
+	 * Relocation Function, r12 point to got2+0x8000
 	 *
 	 * Adjust got2 pointers, no need to check for 0, this code
 	 * already puts a few entries in the table.
@@ -958,6 +961,8 @@ clear_bss:
 	 */
 	.globl	trap_init
 trap_init:
+	mflr	r4			/* save link register		*/
+	GET_GOT
 	lwz	r7, GOT(_start)
 	lwz	r8, GOT(_end_of_vectors)
 
@@ -965,8 +970,6 @@ trap_init:
 
 	cmplw	0, r7, r8
 	bgelr				/* return if r7>=r8 - just in case */
-
-	mflr	r4			/* save link register		*/
 1:
 	lwz	r0, 0(r7)
 	stw	r0, 0(r9)
diff --git a/cpu/mpc83xx/start.S b/cpu/mpc83xx/start.S
index 5a50b09..68bb620 100644
--- a/cpu/mpc83xx/start.S
+++ b/cpu/mpc83xx/start.S
@@ -65,7 +65,7 @@
 /*
  * Set up GOT: Global Offset Table
  *
- * Use r14 to access the GOT
+ * Use r12 to access the GOT
  */
 	START_GOT
 	GOT_ENTRY(_GOT2_TABLE_)
@@ -830,6 +830,7 @@ relocate_code:
 	mr	r9,  r4		/* Save copy of Global Data pointer */
 	mr	r10, r5		/* Save copy of Destination Address */
 
+	GET_GOT
 	mr	r3,  r5				/* Destination Address */
 	lis	r4, CONFIG_SYS_MONITOR_BASE at h		/* Source      Address */
 	ori	r4, r4, CONFIG_SYS_MONITOR_BASE at l
@@ -848,7 +849,7 @@ relocate_code:
 	sub	r15, r10, r4
 
 	/* First our own GOT */
-	add	r14, r14, r15
+	add	r12, r12, r15
 	/* then the one used by the C code */
 	add	r30, r30, r15
 
@@ -930,7 +931,7 @@ relocate_code:
 in_ram:
 
 	/*
-	 * Relocation Function, r14 point to got2+0x8000
+	 * Relocation Function, r12 point to got2+0x8000
 	 *
 	 * Adjust got2 pointers, no need to check for 0, this code
 	 * already puts a few entries in the table.
@@ -1010,6 +1011,8 @@ clear_bss:
 	 */
 	.globl	trap_init
 trap_init:
+	mflr	r4		/* save link register */
+	GET_GOT
 	lwz	r7, GOT(_start)
 	lwz	r8, GOT(_end_of_vectors)
 
@@ -1017,8 +1020,6 @@ trap_init:
 
 	cmplw	0, r7, r8
 	bgelr			/* return if r7>=r8 - just in case */
-
-	mflr	r4		/* save link register */
 1:
 	lwz	r0, 0(r7)
 	stw	r0, 0(r9)
diff --git a/cpu/mpc85xx/start.S b/cpu/mpc85xx/start.S
index d73c5c2..386fa81 100644
--- a/cpu/mpc85xx/start.S
+++ b/cpu/mpc85xx/start.S
@@ -51,7 +51,7 @@
 /*
  * Set up GOT: Global Offset Table
  *
- * Use r14 to access the GOT
+ * Use r12 to access the GOT
  */
 	START_GOT
 	GOT_ENTRY(_GOT2_TABLE_)
@@ -871,6 +871,7 @@ relocate_code:
 	mr	r9,r4		/* Save copy of Init Data pointer	*/
 	mr	r10,r5		/* Save copy of Destination Address	*/
 
+	GET_GOT
 	mr	r3,r5				/* Destination Address	*/
 	lis	r4,CONFIG_SYS_MONITOR_BASE at h		/* Source      Address	*/
 	ori	r4,r4,CONFIG_SYS_MONITOR_BASE at l
@@ -888,7 +889,7 @@ relocate_code:
 	sub	r15,r10,r4
 
 	/* First our own GOT */
-	add	r14,r14,r15
+	add	r12,r12,r15
 	/* the the one used by the C code */
 	add	r30,r30,r15
 
@@ -958,7 +959,7 @@ relocate_code:
 in_ram:
 
 	/*
-	 * Relocation Function, r14 point to got2+0x8000
+	 * Relocation Function, r12 point to got2+0x8000
 	 *
 	 * Adjust got2 pointers, no need to check for 0, this code
 	 * already puts a few entries in the table.
@@ -1024,6 +1025,8 @@ clear_bss:
 	 */
 	.globl	trap_init
 trap_init:
+	mflr	r4			/* save link register		*/
+	GET_GOT
 	lwz	r7,GOT(_start_of_vectors)
 	lwz	r8,GOT(_end_of_vectors)
 
@@ -1031,8 +1034,6 @@ trap_init:
 
 	cmplw	0,r7,r8
 	bgelr				/* return if r7>=r8 - just in case */
-
-	mflr	r4			/* save link register		*/
 1:
 	lwz	r0,0(r7)
 	stw	r0,0(r9)
diff --git a/cpu/mpc86xx/start.S b/cpu/mpc86xx/start.S
index eaa2657..ed1e4ca 100644
--- a/cpu/mpc86xx/start.S
+++ b/cpu/mpc86xx/start.S
@@ -52,7 +52,7 @@
 /*
  * Set up GOT: Global Offset Table
  *
- * Use r14 to access the GOT
+ * Use r12 to access the GOT
  */
 	START_GOT
 	GOT_ENTRY(_GOT2_TABLE_)
@@ -630,6 +630,7 @@ relocate_code:
 	mr	r9,  r4		/* Save copy of Global Data pointer	*/
 	mr	r10, r5		/* Save copy of Destination Address	*/
 
+	GET_GOT
 	mr	r3,  r5				/* Destination Address	*/
 	lis	r4, CONFIG_SYS_MONITOR_BASE at h		/* Source      Address	*/
 	ori	r4, r4, CONFIG_SYS_MONITOR_BASE at l
@@ -647,7 +648,7 @@ relocate_code:
 	sub	r15, r10, r4
 
 	/* First our own GOT */
-	add	r14, r14, r15
+	add	r12, r12, r15
 	/* then the one used by the C code */
 	add	r30, r30, r15
 
@@ -708,7 +709,7 @@ relocate_code:
 
 in_ram:
 	/*
-	 * Relocation Function, r14 point to got2+0x8000
+	 * Relocation Function, r12 point to got2+0x8000
 	 *
 	 * Adjust got2 pointers, no need to check for 0, this code
 	 * already puts a few entries in the table.
@@ -775,6 +776,8 @@ in_ram:
 	 */
 	.globl	trap_init
 trap_init:
+	mflr	r4			/* save link register		*/
+	GET_GOT
 	lwz	r7, GOT(_start)
 	lwz	r8, GOT(_end_of_vectors)
 
@@ -782,8 +785,6 @@ trap_init:
 
 	cmplw	0, r7, r8
 	bgelr				/* return if r7>=r8 - just in case */
-
-	mflr	r4			/* save link register		*/
 1:
 	lwz	r0, 0(r7)
 	stw	r0, 0(r9)
diff --git a/cpu/mpc8xx/start.S b/cpu/mpc8xx/start.S
index 24e9053..7cf602f 100644
--- a/cpu/mpc8xx/start.S
+++ b/cpu/mpc8xx/start.S
@@ -63,7 +63,7 @@
 /*
  * Set up GOT: Global Offset Table
  *
- * Use r14 to access the GOT
+ * Use r12 to access the GOT
  */
 	START_GOT
 	GOT_ENTRY(_GOT2_TABLE_)
@@ -482,6 +482,7 @@ relocate_code:
 	mr	r9,  r4		/* Save copy of Global Data pointer	*/
 	mr	r10, r5		/* Save copy of Destination Address	*/
 
+	GET_GOT
 	mr	r3,  r5				/* Destination Address	*/
 	lis	r4, CONFIG_SYS_MONITOR_BASE at h		/* Source      Address	*/
 	ori	r4, r4, CONFIG_SYS_MONITOR_BASE at l
@@ -499,7 +500,7 @@ relocate_code:
 	sub	r15, r10, r4
 
 	/* First our own GOT */
-	add	r14, r14, r15
+	add	r12, r12, r15
 	/* then the one used by the C code */
 	add	r30, r30, r15
 
@@ -564,7 +565,7 @@ relocate_code:
 in_ram:
 
 	/*
-	 * Relocation Function, r14 point to got2+0x8000
+	 * Relocation Function, r12 point to got2+0x8000
 	 *
 	 * Adjust got2 pointers, no need to check for 0, this code
 	 * already puts a few entries in the table.
@@ -629,6 +630,8 @@ clear_bss:
 	 */
 	.globl	trap_init
 trap_init:
+	mflr	r4			/* save link register		*/
+	GET_GOT
 	lwz	r7, GOT(_start)
 	lwz	r8, GOT(_end_of_vectors)
 
@@ -636,8 +639,6 @@ trap_init:
 
 	cmplw	0, r7, r8
 	bgelr				/* return if r7>=r8 - just in case */
-
-	mflr	r4			/* save link register		*/
 1:
 	lwz	r0, 0(r7)
 	stw	r0, 0(r9)
diff --git a/cpu/ppc4xx/start.S b/cpu/ppc4xx/start.S
index 2eb21fa..927c88c 100644
--- a/cpu/ppc4xx/start.S
+++ b/cpu/ppc4xx/start.S
@@ -228,7 +228,7 @@
 /*
  * Set up GOT: Global Offset Table
  *
- * Use r14 to access the GOT
+ * Use r12 to access the GOT
  */
 #if !defined(CONFIG_NAND_SPL)
 	START_GOT
@@ -1489,6 +1489,7 @@ relocate_code:
 	mr	r9,  r4		/* Save copy of Init Data pointer	*/
 	mr	r10, r5		/* Save copy of Destination Address	*/
 
+	GET_GOT
 	mr	r3,  r5				/* Destination Address	*/
 	lis	r4, CONFIG_SYS_MONITOR_BASE at h		/* Source      Address	*/
 	ori	r4, r4, CONFIG_SYS_MONITOR_BASE at l
@@ -1506,7 +1507,7 @@ relocate_code:
 	sub	r15, r10, r4
 
 	/* First our own GOT */
-	add	r14, r14, r15
+	add	r12, r12, r15
 	/* then the one used by the C code */
 	add	r30, r30, r15
 
@@ -1571,7 +1572,7 @@ relocate_code:
 in_ram:
 
 	/*
-	 * Relocation Function, r14 point to got2+0x8000
+	 * Relocation Function, r12 point to got2+0x8000
 	 *
 	 * Adjust got2 pointers, no need to check for 0, this code
 	 * already puts a few entries in the table.
@@ -1645,6 +1646,8 @@ clear_bss:
 	 */
 	.globl	trap_init
 trap_init:
+	mflr	r4			/* save link register		*/
+	GET_GOT
 	lwz	r7, GOT(_start_of_vectors)
 	lwz	r8, GOT(_end_of_vectors)
 
@@ -1652,8 +1655,6 @@ trap_init:
 
 	cmplw	0, r7, r8
 	bgelr				/* return if r7>=r8 - just in case */
-
-	mflr	r4			/* save link register		*/
 1:
 	lwz	r0, 0(r7)
 	stw	r0, 0(r9)
diff --git a/include/ppc_asm.tmpl b/include/ppc_asm.tmpl
index fa5c5f6..84de146 100644
--- a/include/ppc_asm.tmpl
+++ b/include/ppc_asm.tmpl
@@ -50,13 +50,13 @@
 	.text	2		;	\
 0:	.long	.LCTOC1-1f	;	\
 	.text			;	\
-1:	mflr	r14		;	\
-	lwz	r0,0b-1b(r14)	;	\
-	add	r14,r0,r14	;
+1:	mflr	r12		;	\
+	lwz	r0,0b-1b(r12)	;	\
+	add	r12,r0,r12	;
 
 #define GOT_ENTRY(NAME)		.L_ ## NAME = . - .LCTOC1 ; .long NAME
 
-#define GOT(NAME)		.L_ ## NAME (r14)
+#define GOT(NAME)		.L_ ## NAME (r12)
 
 
 /***************************************************************************
-- 
1.6.4.4



More information about the U-Boot mailing list