From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DBD52143C7D for ; Thu, 8 Aug 2024 08:31:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723105898; cv=none; b=K0hDyWnK1y5+7lud7W5mWXsOM0+kWY4JKtA0Du9vIZLIV6F8yJKHszfdWFXa1KuiF5bb3iYEw3d48v8ZOVlqN8lqAzN3Qrfv7KHjQK9JtJRWi6o8FyHFSmGbvEfBY2J22OHXHQWMR9cTbLSTF5lf++oA4n03L5A5LIrsSRXolZI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723105898; c=relaxed/simple; bh=J6eyOjQh9ePK+M4qnKZgmGARjVwWmTTUklInHlTCE0k=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=D3gqKUfisoK5ro8+nTfv744d8Hy0y/sFh/ej4vhL+h/7i0bPg7AyFLlHFYAECiMIhrq/2vwx3JcpuYKNK5oBzcPAsnZxnXymZ9uz/ofIVUW3QCAUKArIE8mpVSddWAd7nNC1RrG2nUtpx1fWUW7dqHfFMElkNkAnJBM12sBwAQg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4WfgGN5FB6zpT2F; Thu, 8 Aug 2024 16:30:20 +0800 (CST) Received: from kwepemg500010.china.huawei.com (unknown [7.202.181.71]) by mail.maildlp.com (Postfix) with ESMTPS id 371E71401E0; Thu, 8 Aug 2024 16:31:32 +0800 (CST) Received: from [10.67.109.211] (10.67.109.211) by kwepemg500010.china.huawei.com (7.202.181.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 8 Aug 2024 16:31:31 +0800 Message-ID: <3ac296ea-7f9f-4df4-af3b-77d3d3cdcc73@huawei.com> Date: Thu, 8 Aug 2024 16:31:31 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [build fail] v6.11-rc2 from "ARM: 9404/1: arm32: enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION" Content-Language: en-US To: Arnd Bergmann , Harith George , Linus Walleij , Russell King , Ard Biesheuvel , CC: , References: <14e9aefb-88d1-4eee-8288-ef15d4a9b059@gmail.com> <52518ac5-53bb-4c70-ba99-4314593129dc@gmail.com> <2812367a-49ad-4c88-8844-8f8493b15bbd@huawei.com> <2083af75-e2d8-42b9-8fa6-f5b7496671bd@app.fastmail.com> From: "liuyuntao (F)" In-Reply-To: <2083af75-e2d8-42b9-8fa6-f5b7496671bd@app.fastmail.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemg500010.china.huawei.com (7.202.181.71) On 2024/8/7 23:41, Arnd Bergmann wrote: > On Wed, Aug 7, 2024, at 17:36, Harith George wrote: >> On 07-08-2024 20:52, liuyuntao (F) wrote: >>> Thanks, I reproduce the link error with toolchain >>> gcc version 9.3.0 >>> GNU ld (GNU Binutils) 2.33.1 >>> >>> with same gcc version, just upgrading ld version to 2.36.1, it does not >>> segfault and build completes. there should be bugs in low version of ld, >>> and the ".relocĀ  .text, R_ARM_NONE, ." triggers that. >>> >> Thanks for confirming. >> >> I guess we need to add something like >> #if !CONFIG_CC_IS_GCC || CONFIG_LD_VERSION >= 23600 >> around the entry-armv.S changes and maybe select >> HAVE_LD_DEAD_CODE_DATA_ELIMINATION in arch/arm/Kconfig only if the same >> conditions are met ?? > > I think it makes most sense to have a minimum LD > version as a dependency for HAVE_LD_DEAD_CODE_DATA_ELIMINATION. > Are you sure that 2.36 is the first one that works, and it's > not just 2.33 specifically that is broken? > > If so, we could use > > --- a/arch/arm/Kconfig > +++ b/arch/arm/Kconfig > @@ -117,7 +117,7 @@ config ARM > select HAVE_KERNEL_XZ > select HAVE_KPROBES if !XIP_KERNEL && !CPU_ENDIAN_BE32 && !CPU_V7M && !CPU_32v3 > select HAVE_KRETPROBES if HAVE_KPROBES > - select HAVE_LD_DEAD_CODE_DATA_ELIMINATION > + select HAVE_LD_DEAD_CODE_DATA_ELIMINATION if (LD_VERSION >= 23600 || LD_IS_LLD) > select HAVE_MOD_ARCH_SPECIFIC > select HAVE_NMI > select HAVE_OPTPROBES if !THUMB2_KERNEL > > > binutils only takes a few seconds to build from source, so > you could just try all version from 2.25 (the oldest supported) > to 2.36) to see which ones work. After testing, all version of ld with version earlier than 2.36 has a build issue. as Harith mentioned: > The select alone may not be enough. Wont the changes in arch/arm/kernel/entry-armv.S still result in LD Segfaults even if the HAVE_LD_DEAD_CODE_DATA_ELIMINATION flag is not set in .config for older toolchains? I think we could eliminate the impact of ".reloc .text, R_ARM_NONE, ." when CONFIG_LD_DEAD_CODE_DATA_ELIMINATION is not enabled. diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 54b2bb817a7f..173159e93c99 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -117,7 +117,7 @@ config ARM select HAVE_KERNEL_XZ select HAVE_KPROBES if !XIP_KERNEL && !CPU_ENDIAN_BE32 && !CPU_V7M select HAVE_KRETPROBES if HAVE_KPROBES - select HAVE_LD_DEAD_CODE_DATA_ELIMINATION + select HAVE_LD_DEAD_CODE_DATA_ELIMINATION if (LD_VERSION >= 23600 || LD_IS_LLD) select HAVE_MOD_ARCH_SPECIFIC select HAVE_NMI select HAVE_OPTPROBES if !THUMB2_KERNEL diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S index f01d23a220e6..cd443faf8645 100644 --- a/arch/arm/kernel/entry-armv.S +++ b/arch/arm/kernel/entry-armv.S @@ -29,6 +29,12 @@ #include "entry-header.S" #include +#ifdef CONFIG_HAVE_LD_DEAD_CODE_DATA_ELIMINATION +#define RELOC_TEXT_NONE (.reloc .text, R_ARM_NONE, .) +#else +#define RELOC_TEXT_NONE +#endif + /* * Interrupt handling. */ @@ -1065,7 +1071,7 @@ vector_addrexcptn: .globl vector_fiq .section .vectors, "ax", %progbits - .reloc .text, R_ARM_NONE, . + RELOC_TEXT_NONE W(b) vector_rst W(b) vector_und ARM( .reloc ., R_ARM_LDR_PC_G0, .L__vector_swi ) @@ -1079,7 +1085,7 @@ THUMB( .reloc ., R_ARM_THM_PC12, .L__vector_swi ) #ifdef CONFIG_HARDEN_BRANCH_HISTORY .section .vectors.bhb.loop8, "ax", %progbits - .reloc .text, R_ARM_NONE, . + RELOC_TEXT_NONE W(b) vector_rst W(b) vector_bhb_loop8_und ARM( .reloc ., R_ARM_LDR_PC_G0, .L__vector_bhb_loop8_swi ) @@ -1092,7 +1098,7 @@ THUMB( .reloc ., R_ARM_THM_PC12, .L__vector_bhb_loop8_swi ) W(b) vector_bhb_loop8_fiq .section .vectors.bhb.bpiall, "ax", %progbits - .reloc .text, R_ARM_NONE, . + RELOC_TEXT_NONE W(b) vector_rst W(b) vector_bhb_bpiall_und ARM( .reloc ., R_ARM_LDR_PC_G0, .L__vector_bhb_bpiall_swi )