2 * relocate - common relocation function for AArch64 U-Boot
8 * SPDX-License-Identifier: GPL-2.0+
11 #include <asm-offsets.h>
13 #include <linux/linkage.h>
16 * void relocate_code (addr_moni)
18 * This function relocates the monitor code.
19 * x0 holds the destination address.
23 * Copy u-boot from flash to RAM
25 ldr x1, =__image_copy_start /* x1 <- SRC &__image_copy_start */
26 subs x9, x0, x1 /* x9 <- relocation offset */
27 b.eq relocate_done /* skip relocation */
28 ldr x2, =__image_copy_end /* x2 <- SRC &__image_copy_end */
31 ldp x10, x11, [x1], #16 /* copy from source address [x1] */
32 stp x10, x11, [x0], #16 /* copy to target address [x0] */
33 cmp x1, x2 /* until source end address [x2] */
37 * Fix .rela.dyn relocations
39 ldr x2, =__rel_dyn_start /* x2 <- SRC &__rel_dyn_start */
40 ldr x3, =__rel_dyn_end /* x3 <- SRC &__rel_dyn_end */
42 ldp x0, x1, [x2], #16 /* (x0,x1) <- (SRC location, fixup) */
43 ldr x4, [x2], #8 /* x4 <- addend */
44 and x1, x1, #0xffffffff
45 cmp x1, #1027 /* relative fixup? */
48 /* relative fix: store addend plus offset at dest location */
58 ENDPROC(relocate_code)