[PATCH] ARM: Fix allowing linker DCE with binutils < 2.36

Nathan Chancellor posted 1 patch 3 months ago
arch/arm/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] ARM: Fix allowing linker DCE with binutils < 2.36
Posted by Nathan Chancellor 3 months ago
Commit e7607f7d6d81 ("ARM: 9443/1: Require linker to support KEEP within
OVERLAY for DCE") accidentally broke the binutils version restriction
that was added in commit 0d437918fb64 ("ARM: 9414/1: Fix build issue
with LD_DEAD_CODE_DATA_ELIMINATION"), reintroducing the segmentation
fault addressed by that workaround.

Restore the binutils version dependency by using
CONFIG_LD_CAN_USE_KEEP_IN_OVERLAY as an additional condition to ensure
that CONFIG_HAVE_LD_DEAD_CODE_DATA_ELIMINATION is only enabled with
binutils >= 2.36 and ld.lld >= 21.0.0.

Cc: stable@vger.kernel.org
Fixes: e7607f7d6d81 ("ARM: 9443/1: Require linker to support KEEP within OVERLAY for DCE")
Reported-by: Rob Landley <rob@landley.net>
Closes: https://lore.kernel.org/6739da7d-e555-407a-b5cb-e5681da71056@landley.net/
Tested-by: Rob Landley <rob@landley.net>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 arch/arm/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 3072731fe09c..962451e54fdd 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -121,7 +121,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 if (LD_VERSION >= 23600 || LD_CAN_USE_KEEP_IN_OVERLAY)
+	select HAVE_LD_DEAD_CODE_DATA_ELIMINATION if (LD_VERSION >= 23600 || LD_IS_LLD) && LD_CAN_USE_KEEP_IN_OVERLAY
 	select HAVE_MOD_ARCH_SPECIFIC
 	select HAVE_NMI
 	select HAVE_OPTPROBES if !THUMB2_KERNEL

---
base-commit: d7b8f8e20813f0179d8ef519541a3527e7661d3a
change-id: 20250707-arm-fix-dce-older-binutils-87a5a4b829d9

Best regards,
--  
Nathan Chancellor <nathan@kernel.org>
Re: [PATCH] ARM: Fix allowing linker DCE with binutils < 2.36
Posted by Nathan Chancellor 2 months, 3 weeks ago
On Mon, Jul 07, 2025 at 12:39:26PM -0700, Nathan Chancellor wrote:
> Commit e7607f7d6d81 ("ARM: 9443/1: Require linker to support KEEP within
> OVERLAY for DCE") accidentally broke the binutils version restriction
> that was added in commit 0d437918fb64 ("ARM: 9414/1: Fix build issue
> with LD_DEAD_CODE_DATA_ELIMINATION"), reintroducing the segmentation
> fault addressed by that workaround.
> 
> Restore the binutils version dependency by using
> CONFIG_LD_CAN_USE_KEEP_IN_OVERLAY as an additional condition to ensure
> that CONFIG_HAVE_LD_DEAD_CODE_DATA_ELIMINATION is only enabled with
> binutils >= 2.36 and ld.lld >= 21.0.0.
> 
> Cc: stable@vger.kernel.org
> Fixes: e7607f7d6d81 ("ARM: 9443/1: Require linker to support KEEP within OVERLAY for DCE")
> Reported-by: Rob Landley <rob@landley.net>
> Closes: https://lore.kernel.org/6739da7d-e555-407a-b5cb-e5681da71056@landley.net/
> Tested-by: Rob Landley <rob@landley.net>
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
>  arch/arm/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index 3072731fe09c..962451e54fdd 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -121,7 +121,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 if (LD_VERSION >= 23600 || LD_CAN_USE_KEEP_IN_OVERLAY)
> +	select HAVE_LD_DEAD_CODE_DATA_ELIMINATION if (LD_VERSION >= 23600 || LD_IS_LLD) && LD_CAN_USE_KEEP_IN_OVERLAY
>  	select HAVE_MOD_ARCH_SPECIFIC
>  	select HAVE_NMI
>  	select HAVE_OPTPROBES if !THUMB2_KERNEL
> 

I have dropped this in the patch tracker with an updated set of tags
since Martin reported the same issue after I sent this to the list.

https://www.armlinux.org.uk/developer/patches/viewpatch.php?id=9450/1

Cheers,
Nathan