ppc: Use r12 instead of r14 as GOT pointer.
authorJoakim Tjernlund <Joakim.Tjernlund@transmode.se>
Tue, 19 Jan 2010 13:41:56 +0000 (14:41 +0100)
committerWolfgang Denk <wd@denx.de>
Tue, 26 Jan 2010 18:30:13 +0000 (19:30 +0100)
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@transmode.se>
13 files changed:
cpu/74xx_7xx/start.S
cpu/mpc512x/start.S
cpu/mpc5xx/start.S
cpu/mpc5xxx/start.S
cpu/mpc8220/start.S
cpu/mpc824x/start.S
cpu/mpc8260/start.S
cpu/mpc83xx/start.S
cpu/mpc85xx/start.S
cpu/mpc86xx/start.S
cpu/mpc8xx/start.S
cpu/ppc4xx/start.S
include/ppc_asm.tmpl

index efcd95f..88fdf88 100644 (file)
@@ -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@h           /* Source      Address  */
        ori     r4, r4, CONFIG_SYS_MONITOR_BASE@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)
index 46c5efa..d26b617 100644 (file)
@@ -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@h           /* Source      Address */
        ori     r4, r4, CONFIG_SYS_MONITOR_BASE@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)
index be980a1..0af879e 100644 (file)
@@ -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@h           /* Source      Address  */
        ori     r4, r4, CONFIG_SYS_MONITOR_BASE@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)
index 075a7dd..d499da5 100644 (file)
@@ -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@h           /* Source      Address  */
        ori     r4, r4, CONFIG_SYS_MONITOR_BASE@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)
index 5218c85..e28999d 100644 (file)
@@ -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@h   /* Source Address       */
        ori     r4, r4, CONFIG_SYS_MONITOR_BASE@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)
index 7f40648..f3f595a 100644 (file)
@@ -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@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)
index 7d80af5..1fc70bc 100644 (file)
@@ -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@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@h           /* Source      Address  */
        ori     r4, r4, CONFIG_SYS_MONITOR_BASE@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)
index 5a50b09..68bb620 100644 (file)
@@ -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@h           /* Source      Address */
        ori     r4, r4, CONFIG_SYS_MONITOR_BASE@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)
index d73c5c2..386fa81 100644 (file)
@@ -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@h            /* Source      Address  */
        ori     r4,r4,CONFIG_SYS_MONITOR_BASE@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)
index eaa2657..ed1e4ca 100644 (file)
@@ -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@h           /* Source      Address  */
        ori     r4, r4, CONFIG_SYS_MONITOR_BASE@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)
index 24e9053..7cf602f 100644 (file)
@@ -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@h           /* Source      Address  */
        ori     r4, r4, CONFIG_SYS_MONITOR_BASE@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)
index 2eb21fa..927c88c 100644 (file)
 /*
  * 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@h           /* Source      Address  */
        ori     r4, r4, CONFIG_SYS_MONITOR_BASE@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)
index fa5c5f6..84de146 100644 (file)
        .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)
 
 
 /***************************************************************************