From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E684EC4332F for ; Sun, 20 Nov 2022 16:57:13 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 70B63854B8; Sun, 20 Nov 2022 17:56:46 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="DtTpoWV7"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BE65385443; Sun, 20 Nov 2022 17:56:42 +0100 (CET) Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A0E6C85369 for ; Sun, 20 Nov 2022 17:56:40 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id C8B24CE0689; Sun, 20 Nov 2022 16:56:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5F01C433C1; Sun, 20 Nov 2022 16:56:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668963395; bh=GxuluV3t+5lmXw/xGjk8XKKoyFWEe2tKjQlq3H+H3kg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DtTpoWV7vDBn85OWWnPpXkPKyquzUYGz1e78Fl5CkvnJ8arbN3bvROpN+nMa43WPP h844ynSaFr3j4bCZXGDxHG3dqMQ1nXpBmxnm+qbRosuxRTszMJw9D7rYUcLhXSiTFC mic/k2uQAGhf1fTpJiqBjNB4lUwLyvUeZXfneelbkLPS4AHT4gmlrQrZkrmG0D7Oex eGJx2Y6n7f4FMwQWq4Nj54dWwCQCgiV6Mz1Dh7fqq0wiidoqwLRTNuUwgrV9Q7CsgG BrgSgsUkTstbL6ia4K0w8Y647e2GmlLt1bDEq7FbNovTMSO5MsJ6Uvr8wftg1vMCaC GYPaZxyP/VnHA== Received: by pali.im (Postfix) id 6D4BF87E; Sun, 20 Nov 2022 17:56:33 +0100 (CET) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Tom Rini Cc: u-boot@lists.denx.de, maemo-leste@lists.dyne.org Subject: [PATCH 1/3] arm32: Fix relocation of env_addr if POSITION_INDEPENDENT=y Date: Sun, 20 Nov 2022 17:56:26 +0100 Message-Id: <20221120165628.14661-2-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20221120165628.14661-1-pali@kernel.org> References: <20221120165628.14661-1-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean 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 6d566dca5c81..a0311438b458 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.20.1