From 04bb5e95bed2ffd9e788a76b9f6ae52de58bc6b4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pali=20Roh=C3=A1r?= Date: Sun, 20 Nov 2022 17:56:26 +0100 Subject: [PATCH] arm32: Fix relocation of env_addr if POSITION_INDEPENDENT=y MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Apply commit 534f0fbd6520 ("arm64: Fix relocation of env_addr if POSITION_INDEPENDENT=y") also for 32-bit ARM. This change fixes crashing of U-Boot on ARMv7 (Omap3 / Cortex-A8) Nokia N900 phone (real HW). Note that qemu emulator of this board with same u-boot.bin binary has not triggered this crash. Crash happened after U-Boot printed following debug lines to serial console: initcall: 0001ea8c (relocated to 8fe0aa8c) Loading Environment from ... Using default environment Destroy Hash Table: 8fe25a98 table = 00000000 Create Hash Table: N=387 Signed-off-by: Pali Rohár --- arch/arm/lib/crt0.S | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/arm/lib/crt0.S b/arch/arm/lib/crt0.S index 6d566dc..a031143 100644 --- a/arch/arm/lib/crt0.S +++ b/arch/arm/lib/crt0.S @@ -147,6 +147,11 @@ ENTRY(_main) ldr r1, =CONFIG_TEXT_BASE sub r1, r0 add lr, r1 +#if defined(CONFIG_SYS_RELOC_GD_ENV_ADDR) + ldr r0, [r9, #GD_ENV_ADDR] /* r0 = gd->env_addr */ + add r0, r0, r1 + str r0, [r9, #GD_ENV_ADDR] +#endif #endif ldr r0, [r9, #GD_RELOC_OFF] /* r0 = gd->reloc_off */ add lr, lr, r0 -- 2.7.4