From 49e93875a62fb9e96a4a7483b9bd5d8ae27ea76e Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Thu, 2 Nov 2017 18:11:27 -0600 Subject: arm64: support running at addr other than linked to This is required in the case where U-Boot is typically loaded and run at a particular address, but for some reason the RAM at that location is not available, e.g. due to memory fragmentation loading other boot binaries or firmware, splitting an SMP complex between various different OSs without using e.g. the EL2 second-stage page tables to hide the memory asignments, or due to known ECC failures. Signed-off-by: Stephen Warren --- arch/arm/lib/crt0_64.S | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'arch/arm/lib/crt0_64.S') diff --git a/arch/arm/lib/crt0_64.S b/arch/arm/lib/crt0_64.S index 9c46c93ca4..da7c62cbe0 100644 --- a/arch/arm/lib/crt0_64.S +++ b/arch/arm/lib/crt0_64.S @@ -98,6 +98,14 @@ ENTRY(_main) ldr x18, [x18, #GD_NEW_GD] /* x18 <- gd->new_gd */ adr lr, relocation_return +#if CONFIG_POSITION_INDEPENDENT + /* Add in link-vs-runtime offset */ + adr x0, _start /* x0 <- Runtime value of _start */ + ldr x9, _TEXT_BASE /* x9 <- Linked value of _start */ + sub x9, x9, x0 /* x9 <- Run-vs-link offset */ + add lr, lr, x9 +#endif + /* Add in link-vs-relocation offset */ ldr x9, [x18, #GD_RELOC_OFF] /* x9 <- gd->reloc_off */ add lr, lr, x9 /* new return address after relocation */ ldr x0, [x18, #GD_RELOCADDR] /* x0 <- gd->relocaddr */ -- cgit