.globl _TEXT_BASE
_TEXT_BASE:
- .word CONFIG_SYS_TEXT_BASE
+ .word _start
/*
* These are defined in the board-specific linker script.
mov r6, r2 /* save addr of destination */
adr r0, _start
- cmp r0, r6
- moveq r9, #0 /* no relocation. relocation offset(r9) = 0 */
+ subs r9, r6, r0
beq relocate_done /* skip relocation */
mov r1, r6 /* r1 <- scratch for copy_loop */
ldr r3, _image_copy_end_ofs
/*
* fix .rel.dyn relocations
*/
- ldr r0, _TEXT_BASE /* r0 <- Text base */
+ adr r0, _start /* r0 <- beginning of code */
sub r9, r6, r0 /* r9 <- relocation offset */
ldr r10, _dynsym_start_ofs /* r10 <- sym table ofs */
add r10, r10, r0 /* r10 <- sym table in FLASH */
add r2, r2, r0 /* r2 <- rel dyn start in FLASH */
ldr r3, _rel_dyn_end_ofs /* r3 <- rel dyn end ofs */
add r3, r3, r0 /* r3 <- rel dyn end in FLASH */
+ mov r4, r0
fixloop:
ldr r0, [r2] /* r0 <- location to fix up, IN FLASH! */
+ cmp r0, r4
+ blo skipfix
add r0, r0, r9 /* r0 <- location to fix up in RAM */
ldr r1, [r2, #4]
and r7, r1, #0xff
add r1, r1, r9
fixnext:
str r1, [r0]
+skipfix:
add r2, r2, #8 /* each rel.dyn entry is 8 bytes */
cmp r2, r3
blo fixloop