Skip to content

Commit e7607f7

Browse files
nathanchanceRussell King (Oracle)
authored andcommitted
ARM: 9443/1: Require linker to support KEEP within OVERLAY for DCE
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]>
1 parent 9cac324 commit e7607f7

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

arch/arm/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ config ARM
121121
select HAVE_KERNEL_XZ
122122
select HAVE_KPROBES if !XIP_KERNEL && !CPU_ENDIAN_BE32 && !CPU_V7M
123123
select HAVE_KRETPROBES if HAVE_KPROBES
124-
select HAVE_LD_DEAD_CODE_DATA_ELIMINATION if (LD_VERSION >= 23600 || LD_IS_LLD)
124+
select HAVE_LD_DEAD_CODE_DATA_ELIMINATION if (LD_VERSION >= 23600 || LD_CAN_USE_KEEP_IN_OVERLAY)
125125
select HAVE_MOD_ARCH_SPECIFIC
126126
select HAVE_NMI
127127
select HAVE_OPTPROBES if !THUMB2_KERNEL

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

Lines changed: 6 additions & 0 deletions
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

Lines changed: 5 additions & 0 deletions
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 RUSTC_HAS_COERCE_POINTEE
133138
def_bool RUSTC_VERSION >= 108400
134139

0 commit comments

Comments
 (0)