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 70F29EB64D9 for ; Tue, 27 Jun 2023 01:25:27 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 51AEB862ED; Tue, 27 Jun 2023 03:25:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=tinylab.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 5847F8469F; Tue, 27 Jun 2023 03:25:21 +0200 (CEST) Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.67.158]) (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 621098469F for ; Tue, 27 Jun 2023 03:25:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=tinylab.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=bmeng@tinylab.org X-QQ-mid: bizesmtp87t1687829109td6cries Received: from pek-vx-bsp2.wrs.com ( [60.247.85.88]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 27 Jun 2023 09:24:56 +0800 (CST) X-QQ-SSF: 01200000000000E0G000000A0000000 X-QQ-FEAT: rl11S5XfjRMAtd35Wdn5MlN9XLw1ST5u4R8FV5xvorx3QE2YYjnF2Kspfw9Qi qDwmz2nSSSEy8y7vYHDyTlCT5pjm1ptN8efDS6FbilbfdLcGU55eUuWdj+8+F6xPYe6jj1S yC26nFluMnKkOl9ahxeNUlMaRWLXBX6LBd90NprPe2Ax/PQ//HWLhMOUUElIGfTN7FVabXW XT1KsiNe12fr1L05/t5HUBwsP3kTrUAVBnSWts9Gzqj8jxDafO3Jgm15cfWRCWah4j0Q57y Y5xhw6hEoxoFAACaw0RZ9TvitXuUgV7ClnUEr9bGUwhuQbG60CMwhz4A1kWn0V9EqKL9gf5 Y2WG7oXeBdo5JPq8XE= X-QQ-GoodBg: 0 X-BIZMAIL-ID: 8027087771106890632 From: Bin Meng To: u-boot@lists.denx.de, Rick Chen , Leo Subject: [PATCH v2] riscv: Fix alignment of RELA sections in the linker scripts Date: Tue, 27 Jun 2023 09:24:56 +0800 Message-Id: <20230627012456.3899052-1-bmeng@tinylab.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz7a-0 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.8 at phobos.denx.de X-Virus-Status: Clean In current linker script both .efi_runtime_rel and .rela.dyn sections are of RELA type whose entry size is either 12 (RV32) or 24 (RV64). These two are arranged as a continuous region on purpose so that the prelink-riscv executable can fix up the PIE addresses in one loop. However there is an 'ALIGN(8)' between these 2 sections which might cause a gap to be inserted between these 2 sections to satisfy the alignment requirement on RV32. This would break the assumption of the prelink process and generate an unbootable image. Fixes: 9a6569a043d3 ("riscv: Update alignment for some sections in linker scripts") Signed-off-by: Bin Meng Reviewed-by: Rick Chen --- Changes in v2: - fix typos in the commit message arch/riscv/cpu/u-boot.lds | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/riscv/cpu/u-boot.lds b/arch/riscv/cpu/u-boot.lds index 15b5cbc585..2ffe6ba3c8 100644 --- a/arch/riscv/cpu/u-boot.lds +++ b/arch/riscv/cpu/u-boot.lds @@ -48,7 +48,7 @@ SECTIONS KEEP(*(SORT(__u_boot_list*))); } - . = ALIGN(4); + . = ALIGN(8); .efi_runtime_rel : { __efi_runtime_rel_start = .; @@ -57,8 +57,6 @@ SECTIONS __efi_runtime_rel_stop = .; } - . = ALIGN(8); - /DISCARD/ : { *(.rela.plt*) } .rela.dyn : { __rel_dyn_start = .; -- 2.25.1