[PATCH 1/2] ARM: Require linker to support KEEP within OVERLAY for DCE

Rob Landley rob at landley.net
Sat Jul 5 12:53:43 PDT 2025


On 7/4/25 19:24, Nathan Chancellor wrote:
> Hmm, I do see a bug in that change, as it allows DCE to be turned on
> with binutils older than 2.36, which should be avoided with something
> like
> 
> 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
> 
> but it does not seem like your test configuration enables
> CONFIG_LD_DEAD_CODE_DATA_ELIMINATION so I would expect this change to be
> a no-op in that case? Does the above change work for you? I won't be
> free to validate this until after the weekend.

That fixed it, thanks.

   AS      arch/arm/boot/compressed/piggy.o
   LD      arch/arm/boot/compressed/vmlinux
   OBJCOPY arch/arm/boot/zImage
   Kernel: arch/arm/boot/zImage is ready
$ qemu-system-arm -M virt -nographic -no-reboot -kernel $(find . -name 
zImage) -append console=ttyAMA0
Booting Linux on physical CPU 0x0
Linux version 6.15.0-dirty (landley at driftwood) 
(armv7l-linux-musleabihf-gcc (GCC) 11.4.0, GNU ld (GNU Binutils) 2.33.1) 
#1 Sat Jul  5 14:40:16 CDT 2025
CPU: ARMv7 Processor [414fc0f0] revision 0 (ARMv7), cr=30c53c7d
CPU: PIPT / VIPT nonaliasing data cache, PIPT instruction cache
OF: fdt: Machine model: linux,dummy-virt
...

I note it was a host tool segfaulting. It seems unlikely the host was 
running an arm binary, maybe something went off into la-la land trying 
to parse unexpected ELF tables?

Appropriately-tagged-by: Rob Landley <rob at landley.net>

> Cheers,
> Nathan

Thanks,

Rob



More information about the linux-arm-kernel mailing list