All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arm64: Add support for bigger u-boot when CONFIG_POSITION_INDEPENDENT=y
@ 2020-09-02 11:15 Michal Simek
  2020-09-02 14:43 ` André Przywara
  2020-09-02 16:34 ` Stephen Warren
  0 siblings, 2 replies; 18+ messages in thread
From: Michal Simek @ 2020-09-02 11:15 UTC (permalink / raw)
  To: u-boot

From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>

When U-Boot binary exceeds 1MB with CONFIG_POSITION_INDEPENDENT=y
compilation error is shown:
/mnt/disk/u-boot/arch/arm/cpu/armv8/start.S:71:(.text+0x3c): relocation
truncated to fit: R_AARCH64_ADR_PREL_LO21 against symbol `__rel_dyn_end'
defined in .bss_start section in u-boot.

It is caused by adr instruction which permits the calculation of any byte
address within +- 1MB of the current PC.
Because U-Boot is bigger then 1MB calculation is failing.

The patch is using adrp/add instructions where adrp shifts a signed, 21-bit
immediate left by 12 bits (4k page), adds it to the value of the program
counter with the bottom 12 bits cleared to zero. Then add instruction
provides the lower 12 bits which is offset within 4k page.
These two instructions together compose full 32bit offset which should be
more then enough to cover the whole u-boot size.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 arch/arm/cpu/armv8/start.S | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/cpu/armv8/start.S b/arch/arm/cpu/armv8/start.S
index 002698b501c3..52cf1230c205 100644
--- a/arch/arm/cpu/armv8/start.S
+++ b/arch/arm/cpu/armv8/start.S
@@ -67,8 +67,10 @@ pie_fixup:
 	adr	x0, _start		/* x0 <- Runtime value of _start */
 	ldr	x1, _TEXT_BASE		/* x1 <- Linked value of _start */
 	sub	x9, x0, x1		/* x9 <- Run-vs-link offset */
-	adr	x2, __rel_dyn_start	/* x2 <- Runtime &__rel_dyn_start */
-	adr	x3, __rel_dyn_end	/* x3 <- Runtime &__rel_dyn_end */
+	adrp    x2, __rel_dyn_start     /* x2 <- Runtime &__rel_dyn_start */
+	add     x2, x2, #:lo12:__rel_dyn_start
+	adrp    x3, __rel_dyn_end       /* x3 <- Runtime &__rel_dyn_end */
+	add     x3, x3, #:lo12:__rel_dyn_end
 pie_fix_loop:
 	ldp	x0, x1, [x2], #16	/* (x0, x1) <- (Link location, fixup) */
 	ldr	x4, [x2], #8		/* x4 <- addend */
-- 
2.28.0

^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2020-09-03 19:12 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-02 11:15 [PATCH] arm64: Add support for bigger u-boot when CONFIG_POSITION_INDEPENDENT=y Michal Simek
2020-09-02 14:43 ` André Przywara
2020-09-02 14:51   ` Michal Simek
2020-09-02 14:53   ` Edgar E. Iglesias
2020-09-02 15:18     ` André Przywara
2020-09-02 15:25       ` Edgar E. Iglesias
2020-09-02 18:59         ` André Przywara
2020-09-03 13:41           ` Michal Simek
2020-09-03 13:52             ` André Przywara
2020-09-03 13:59               ` Edgar E. Iglesias
2020-09-03 14:03                 ` Michal Simek
2020-09-02 16:34 ` Stephen Warren
2020-09-03 13:35   ` Michal Simek
2020-09-03 13:40     ` André Przywara
2020-09-03 15:45       ` Stephen Warren
2020-09-03 19:07         ` Edgar E. Iglesias
2020-09-03 19:10           ` Stephen Warren
2020-09-03 19:12             ` Edgar E. Iglesias

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.