1.1 --- a/lib/start.S Thu Oct 25 21:19:01 2018 +0200
1.2 +++ b/lib/start.S Fri Oct 26 18:22:04 2018 +0200
1.3 @@ -44,6 +44,10 @@
1.4 .section .boot, "a"
1.5
1.6 .globl _start
1.7 +.extern relocate_data
1.8 +.extern _data_original
1.9 +.extern _data
1.10 +.extern _data_size
1.11 .extern main
1.12
1.13 _start:
1.14 @@ -72,11 +76,29 @@
1.15 ori $gp, $gp, %lo(_GLOBAL_OFFSET_TABLE_)
1.16
1.17 /*
1.18 - Jump to the main program. Since the boot code is separate from the
1.19 - other code, the address cannot be obtained via the GOT.
1.20 - ("relocation truncated to fit: R_MIPS_PC16 against `main'")
1.21 + Relocate mutable data and then jump to the main program.
1.22 +
1.23 + Since the boot code is separate from the other code, addresses cannot be
1.24 + obtained via the GOT:
1.25 +
1.26 + "relocation truncated to fit: R_MIPS_PC16 against `main'"
1.27 */
1.28
1.29 + lui $a0, %hi(_data_original)
1.30 + ori $a0, $a0, %lo(_data_original)
1.31 +
1.32 + lui $a1, %hi(_data)
1.33 + ori $a1, $a1, %lo(_data)
1.34 +
1.35 + lui $a2, %hi(_data_size)
1.36 + ori $a2, $a2, %lo(_data_size)
1.37 + lw $a2, 0($a2)
1.38 +
1.39 + lui $t9, %hi(relocate_data)
1.40 + ori $t9, $t9, %lo(relocate_data)
1.41 + jal $t9
1.42 + nop
1.43 +
1.44 lui $t9, %hi(main)
1.45 ori $t9, $t9, %lo(main)
1.46 jr $t9