mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "liuyuntao (F)" <liuyuntao12@huawei.com>
To: Harith George <mail2hgg@gmail.com>, Arnd Bergmann <arnd@arndb.de>,
	Linus Walleij <linus.walleij@linaro.org>,
	Russell King <rmk+kernel@armlinux.org.uk>,
	Ard Biesheuvel <ardb@kernel.org>, <harith.g@alifsemi.com>
Cc: <linux-kernel@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>
Subject: Re: [build fail] v6.11-rc2 from "ARM: 9404/1: arm32: enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION"
Date: Thu, 8 Aug 2024 16:43:44 +0800	[thread overview]
Message-ID: <dc4ea241-310d-4606-9c01-aae5956f672d@huawei.com> (raw)
In-Reply-To: <44ffc9bc-f14e-4576-94fe-189c1f672444@gmail.com>



On 2024/8/7 23:48, Harith George wrote:
> 
> 
> On 07-08-2024 21:11, 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
>>
> 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?
> 

Yes, that is it.
apply this patch, it should sovle the build issue with older version GUN ld.

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 <asm/probes.h>

+#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	)

> Thanks,
> Warm Regards,
> Harith
>>
>> 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.
>>
>>         Arnd
> 

  reply	other threads:[~2024-08-08  8:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-07  5:12 Harith George
2024-08-07  6:42 ` liuyuntao (F)
2024-08-07  9:49 ` liuyuntao (F)
2024-08-07 11:51   ` Harith George
2024-08-07 15:22     ` liuyuntao (F)
2024-08-07 15:36       ` Harith George
2024-08-07 15:41         ` Arnd Bergmann
2024-08-07 15:47           ` liuyuntao (F)
2024-08-07 15:48           ` Harith George
2024-08-08  8:43             ` liuyuntao (F) [this message]
2024-08-08  8:31           ` liuyuntao (F)
2024-08-07 10:10 ` Arnd Bergmann
2024-08-07 11:21   ` Harith George

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dc4ea241-310d-4606-9c01-aae5956f672d@huawei.com \
    --to=liuyuntao12@huawei.com \
    --cc=ardb@kernel.org \
    --cc=arnd@arndb.de \
    --cc=harith.g@alifsemi.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mail2hgg@gmail.com \
    --cc=rmk+kernel@armlinux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®