]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - arch/mips/cpu/xburst/start.S
Merge branch 'next' of git://git.denx.de/u-boot-mips
[karo-tx-uboot.git] / arch / mips / cpu / xburst / start.S
index 50b7fb102172f6c32ea50b2f8b65ebf6485f9a1f..d2c064b0175b0c5368e5a7d183c9192bc6340b8e 100644 (file)
@@ -67,7 +67,7 @@ relocate_code:
        sub     t6, a2, t0              # t6 <-- relocation offset
 
        la      t3, in_ram
-       lw      t2, -12(t3)             # t2 <-- uboot_end_data
+       lw      t2, -12(t3)             # t2 <-- __image_copy_end
        move    t1, a2
 
        add     gp, t6                  # adjust gp
@@ -116,9 +116,10 @@ relocate_code:
        jr      t0
         nop
 
+       .word   __rel_dyn_end
+       .word   __rel_dyn_start
+       .word   __image_copy_end
        .word   _GLOBAL_OFFSET_TABLE_
-       .word   uboot_end_data
-       .word   uboot_end
        .word   num_got_entries
 
 in_ram:
@@ -129,7 +130,7 @@ in_ram:
         * generated by GNU ld. Skip these reserved entries from relocation.
         */
        lw      t3, -4(t0)              # t3 <-- num_got_entries
-       lw      t4, -16(t0)             # t4 <-- _GLOBAL_OFFSET_TABLE_
+       lw      t4, -8(t0)              # t4 <-- _GLOBAL_OFFSET_TABLE_
        add     t4, t6                  # t4 now holds relocated _G_O_T_
        addi    t4, t4, 8               # skipping first two entries
        li      t2, 2
@@ -143,16 +144,45 @@ in_ram:
        blt     t2, t3, 1b
         addi   t4, 4
 
-       /* Clear BSS */
-       lw      t1, -12(t0)             # t1 <-- uboot_end_data
-       lw      t2, -8(t0)              # t2 <-- uboot_end
-       add     t1, t6                  # adjust pointers
-       add     t2, t6
+       /* Update dynamic relocations */
+       lw      t1, -16(t0)             # t1 <-- __rel_dyn_start
+       lw      t2, -20(t0)             # t2 <-- __rel_dyn_end
 
-       sub     t1, 4
-1:     addi    t1, 4
-       bltl    t1, t2, 1b
-        sw     zero, 0(t1)
+       b       2f                      # skip first reserved entry
+        addi   t1, 8
+
+1:
+       lw      t3, -4(t1)              # t3 <-- relocation info
+
+       sub     t3, 3
+       bnez    t3, 2f                  # skip non R_MIPS_REL32 entries
+        nop
+
+       lw      t3, -8(t1)              # t3 <-- location to fix up in FLASH
+
+       lw      t4, 0(t3)               # t4 <-- original pointer
+       add     t4, t6                  # t4 <-- adjusted pointer
+
+       add     t3, t6                  # t3 <-- location to fix up in RAM
+       sw      t4, 0(t3)
+
+2:
+       blt     t1, t2, 1b
+        addi   t1, 8                   # each rel.dyn entry is 8 bytes
+
+       /*
+        * Clear BSS
+        *
+        * GOT is now relocated. Thus __bss_start and __bss_end can be
+        * accessed directly via $gp.
+        */
+       la      t1, __bss_start         # t1 <-- __bss_start
+       la      t2, __bss_end           # t2 <-- __bss_end
+
+1:
+       sw      zero, 0(t1)
+       blt     t1, t2, 1b
+        addi   t1, 4
 
        move    a0, a1                  # a0 <-- gd
        la      t9, board_init_r