Skip to content

Commit 59fc423

Browse files
nathanchancegregkh
authored andcommitted
ARM: 9443/1: Require linker to support KEEP within OVERLAY for DCE
commit e7607f7 upstream. ld.lld prior to 21.0.0 does not support using the KEEP keyword within an overlay description, which may be needed to avoid discarding necessary sections within an overlay with '--gc-sections', which can be enabled for the kernel via CONFIG_LD_DEAD_CODE_DATA_ELIMINATION. Disallow CONFIG_LD_DEAD_CODE_DATA_ELIMINATION without support for KEEP within OVERLAY and introduce a macro, OVERLAY_KEEP, that can be used to conditionally add KEEP when it is properly supported to avoid breaking old versions of ld.lld. Cc: [email protected] Link: llvm/llvm-project@381599f Reviewed-by: Linus Walleij <[email protected]> Signed-off-by: Nathan Chancellor <[email protected]> Signed-off-by: Russell King (Oracle) <[email protected]> [nathan: Fix conflict in init/Kconfig due to lack of RUSTC symbols] Signed-off-by: Nathan Chancellor <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent c6f2a81 commit 59fc423

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

arch/arm/Kconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ config ARM
118118
select HAVE_KERNEL_XZ
119119
select HAVE_KPROBES if !XIP_KERNEL && !CPU_ENDIAN_BE32 && !CPU_V7M
120120
select HAVE_KRETPROBES if HAVE_KPROBES
121-
select HAVE_LD_DEAD_CODE_DATA_ELIMINATION if (LD_VERSION >= 23600 || LD_IS_LLD)
121+
select HAVE_LD_DEAD_CODE_DATA_ELIMINATION if (LD_VERSION >= 23600 || LD_CAN_USE_KEEP_IN_OVERLAY)
122122
select HAVE_MOD_ARCH_SPECIFIC
123123
select HAVE_NMI
124124
select HAVE_OPTPROBES if !THUMB2_KERNEL

arch/arm/include/asm/vmlinux.lds.h

+6
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@
3434
#define NOCROSSREFS
3535
#endif
3636

37+
#ifdef CONFIG_LD_CAN_USE_KEEP_IN_OVERLAY
38+
#define OVERLAY_KEEP(x) KEEP(x)
39+
#else
40+
#define OVERLAY_KEEP(x) x
41+
#endif
42+
3743
/* Set start/end symbol names to the LMA for the section */
3844
#define ARM_LMA(sym, section) \
3945
sym##_start = LOADADDR(section); \

init/Kconfig

+5
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ config CC_HAS_COUNTED_BY
129129
# https://github.com./llvm/llvm-project/pull/112636
130130
depends on !(CC_IS_CLANG && CLANG_VERSION < 190103)
131131

132+
config LD_CAN_USE_KEEP_IN_OVERLAY
133+
# ld.lld prior to 21.0.0 did not support KEEP within an overlay description
134+
# https://github.com./llvm/llvm-project/pull/130661
135+
def_bool LD_IS_BFD || LLD_VERSION >= 210000
136+
132137
config PAHOLE_VERSION
133138
int
134139
default $(shell,$(srctree)/scripts/pahole-version.sh $(PAHOLE))

0 commit comments

Comments
 (0)