Skip to content

Orphan section warnings with LLD 10.0.1 #1187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nivedita76 opened this issue Oct 25, 2020 · 16 comments
Closed

Orphan section warnings with LLD 10.0.1 #1187

nivedita76 opened this issue Oct 25, 2020 · 16 comments
Assignees
Labels
[BUG] linux A bug that should be fixed in the mainline kernel. [FIXED][LINUX] 5.10 This bug was fixed in Linux 5.10 Orphan section An linker orphan section warning [TOOL] lld The issue is relevant to LLD linker

Comments

@nivedita76
Copy link

errors.log

LLD 10.0.1 generates tons of warnings when used to build linux (sample from mainline x86_64 defconfig attached -- most of the .rela section warnings snipped out).

This is unfortunate as 10.0.1 is supposed to be the minimum supported version.

Which is the first version that fixes these warnings -- and should --orphan-handling=warn be made conditional on it?

@kees
Copy link

kees commented Oct 28, 2020

Okay, this is easily reproduced with an LLVM=1 build of mainline Linux.

Building with Clang 10.0.1 and ld.bfd is clean.
Building with Clang 10.0.1 and modern ld.lld is clean.

I guess the question is whether the expectation for mainline Linux is just Clang 10.0.1 or rather Clang and LLD 10.0.1. I think the reasons for using LLD tend to be more on the experimental side (e.g. LTO, etc), and those certainly require very very new LLD. Nick, what do you think for this?

@nathanchance
Copy link
Member

Everything says Clang/LLVM in the documentation so that gives the impression that everything should generally work fine, including LLD. We might need to update the documentation to say that clang should be solid at this point but the other LLVM utilities are still in flux (i.e., CC=clang should be fine but LLVM=1 is a bit more experimental).

This is the unfortunate downside about the LLVM release model and what I worried about when we did this: there is no way to get fixes into older stable releases and seeded out to people. It is either "don't do this thing" or "upgrade your toolchain", which is not necessarily a bad thing but people do not want to build a toolchain themselves, they just want to use whatever is available through their distribution.

Short term solution is disable --orphan-handling=warn for LLD < 11.0.0 (via Kconfig maybe?) then decide if we want to say LLD 11.0.0+ should be used or still stick with the generic claim that LLVM 10.0.1 is still good to go.

Longer term dream is to get a version of LLVM built that can be seeded out to other people so we can avoid stuff like this (sort of like the GCC toolchains available on kernel.org).

@nickdesaulniers
Copy link
Member

Short term solution is disable --orphan-handling=warn for LLD < 11.0.0 (via Kconfig maybe?)

Yep.

then decide if we want to say LLD 11.0.0+ should be used

If it's easy to disable orphan section warn for LLVM < 11, let's do it. Otherwise clang-11 and friends are generally available.

@nickdesaulniers nickdesaulniers added the [TOOL] lld The issue is relevant to LLD linker label Oct 28, 2020
@nathanchance
Copy link
Member

From 5bde5ef7b46bce15a159fc5af517238e590b406a Mon Sep 17 00:00:00 2001
From: Nathan Chancellor <[email protected]>
Date: Thu, 12 Nov 2020 12:15:51 -0700
Subject: [PATCH 1/2] kbuild: Add lld-version.sh

We will need a way to get ld.lld's version from the '--version' output
and the ld-version.sh script is ld.bfd specific. Add lld-version.sh,
which will extract and print the version like clang-version.sh does.

Signed-off-by: Nathan Chancellor <[email protected]>
---
 init/Kconfig           |  4 ++++
 scripts/lld-version.sh | 20 ++++++++++++++++++++
 2 files changed, 24 insertions(+)
 create mode 100755 scripts/lld-version.sh

diff --git a/init/Kconfig b/init/Kconfig
index c9446911cf41..4dd759539864 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -47,6 +47,10 @@ config CLANG_VERSION
 	int
 	default $(shell,$(srctree)/scripts/clang-version.sh $(CC))
 
+config LLD_VERSION
+	int
+	default $(shell,$(srctree)/scripts/lld-version.sh $(LD))
+
 config CC_CAN_LINK
 	bool
 	default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(CLANG_FLAGS) $(m64-flag)) if 64BIT
diff --git a/scripts/lld-version.sh b/scripts/lld-version.sh
new file mode 100755
index 000000000000..4e22a251287f
--- /dev/null
+++ b/scripts/lld-version.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+#
+# lld-version lld-command
+#
+# Print the linker version of `ld.lld-command' in a 5 or 6-digit form
+# such as `100001' for ld.lld-10.0.1 etc.
+
+linker="$*"
+
+if ! ( $linker --version | grep -q LLD ); then
+	echo 0
+	exit 1
+fi
+
+VERSION=$($linker --version | cut -d ' ' -f 2)
+MAJOR=$(echo $VERSION | cut -d . -f 1)
+MINOR=$(echo $VERSION | cut -d . -f 2)
+PATCHLEVEL=$(echo $VERSION | cut -d . -f 3)
+printf "%d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL
-- 
2.25.1


From cc613cb75cbc5c825301331bba9778ced3f753b6 Mon Sep 17 00:00:00 2001
From: Nathan Chancellor <[email protected]>
Date: Thu, 12 Nov 2020 12:38:15 -0700
Subject: [PATCH 2/2] kbuild: Add CONFIG_LD_CAN_ORPHAN_WARN

ld.lld 10.0.1 spews a bunch of various warnings about .rela sections,
along with a few others. Newer versions of ld.lld do not have these
warnings. As a result, do not add '--orphan-handling=warn' to
LDFLAGS_vmlinux if ld.lld's version is not new enough.

Additionally, because we are adding a Kconfig symbol, hoist the
ld-option call into the Kconfig choice so that we save ourselves the
call later on.

Reported-by: Arvind Sankar <[email protected]>
Reported-by: kernelci.org bot <[email protected]>
Reported-by: Mark Brown <[email protected]>
Link: https://github.com/ClangBuiltLinux/linux/issues/1187
Link: https://github.com/ClangBuiltLinux/linux/issues/1193
Signed-off-by: Nathan Chancellor <[email protected]>
---
 arch/arm/Makefile                 | 4 +++-
 arch/arm/boot/compressed/Makefile | 4 +++-
 arch/arm64/Makefile               | 4 +++-
 arch/powerpc/Makefile             | 2 +-
 arch/x86/Makefile                 | 4 +++-
 arch/x86/boot/compressed/Makefile | 4 +++-
 init/Kconfig                      | 3 +++
 7 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 4d76eab2b22d..d0cf45dceeca 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -18,7 +18,9 @@ endif
 
 # We never want expected sections to be placed heuristically by the
 # linker. All sections should be explicitly named in the linker script.
-LDFLAGS_vmlinux += $(call ld-option, --orphan-handling=warn)
+ifeq ($(CONFIG_LD_CAN_ORPHAN_WARN),y)
+LDFLAGS_vmlinux += --orphan-handling=warn
+endif
 
 GZFLAGS		:=-9
 #KBUILD_CFLAGS	+=-pipe
diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
index 47f001ca5499..26b3b1bfa1f9 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -129,7 +129,9 @@ LDFLAGS_vmlinux += --no-undefined
 # Delete all temporary local symbols
 LDFLAGS_vmlinux += -X
 # Report orphan sections
-LDFLAGS_vmlinux += $(call ld-option, --orphan-handling=warn)
+ifeq ($(CONFIG_LD_CAN_ORPHAN_WARN),y)
+LDFLAGS_vmlinux += --orphan-handling=warn
+endif
 # Next argument is a linker script
 LDFLAGS_vmlinux += -T
 
diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index 5789c2d18d43..88c54752f3d4 100644
--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -30,7 +30,9 @@ endif
 
 # We never want expected sections to be placed heuristically by the
 # linker. All sections should be explicitly named in the linker script.
-LDFLAGS_vmlinux += $(call ld-option, --orphan-handling=warn)
+ifeq ($(CONFIG_LD_CAN_ORPHAN_WARN),y)
+LDFLAGS_vmlinux += --orphan-handling=warn
+endif
 
 ifeq ($(CONFIG_ARM64_USE_LSE_ATOMICS), y)
   ifneq ($(CONFIG_ARM64_LSE_ATOMICS), y)
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index a4d56f0a41d9..9d80869d8598 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -122,8 +122,8 @@ endif
 
 LDFLAGS_vmlinux-y := -Bstatic
 LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) := -pie
+LDFLAGS_vmlinux-$(CONFIG_LD_CAN_ORPHAN_WARN) += --orphan-handling=warn
 LDFLAGS_vmlinux	:= $(LDFLAGS_vmlinux-y)
-LDFLAGS_vmlinux += $(call ld-option,--orphan-handling=warn)
 
 ifdef CONFIG_PPC64
 ifeq ($(call cc-option-yn,-mcmodel=medium),y)
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 154259f18b8b..e8699ab3467e 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -211,7 +211,9 @@ endif
 
 # We never want expected sections to be placed heuristically by the
 # linker. All sections should be explicitly named in the linker script.
-LDFLAGS_vmlinux += $(call ld-option, --orphan-handling=warn)
+ifeq ($(CONFIG_LD_CAN_ORPHAN_WARN),y)
+LDFLAGS_vmlinux += --orphan-handling=warn
+endif
 
 archscripts: scripts_basic
 	$(Q)$(MAKE) $(build)=arch/x86/tools relocs
diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
index ee249088cbfe..e3c1824cbac4 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -61,7 +61,9 @@ KBUILD_LDFLAGS += $(call ld-option,--no-ld-generated-unwind-info)
 # Compressed kernel should be built as PIE since it may be loaded at any
 # address by the bootloader.
 LDFLAGS_vmlinux := -pie $(call ld-option, --no-dynamic-linker)
-LDFLAGS_vmlinux += $(call ld-option, --orphan-handling=warn)
+ifeq ($(CONFIG_LD_CAN_ORPHAN_WARN),y)
+LDFLAGS_vmlinux += --orphan-handling=warn
+endif
 LDFLAGS_vmlinux += -T
 
 hostprogs	:= mkpiggy
diff --git a/init/Kconfig b/init/Kconfig
index 4dd759539864..6cbeb43c0038 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -74,6 +74,9 @@ config TOOLS_SUPPORT_RELR
 config CC_HAS_ASM_INLINE
 	def_bool $(success,echo 'void foo(void) { asm inline (""); }' | $(CC) -x c - -c -o /dev/null)
 
+config LD_CAN_ORPHAN_WARN
+	def_bool $(ld-option,--orphan-handling=warn) && (!LD_IS_LLD || LLD_VERSION >= 110000)
+
 config CONSTRUCTORS
 	bool
 	depends on !UML
-- 
2.25.1

This works for me. I know the lld-version.sh is pretty terrible but it at least gets the job done.

@nickdesaulniers
Copy link
Member

I really like the idea of moving the Kbuild check to Kconfig; that's one less child process for incremental builds. Regardless of the LLD version stuff, I would accept that as a standalone patch. (we might even be able to hoist the Makefile changes into the top level Makefile, though enabling it for all arches may be aggressive, we'd probably also be doing them a favor in the long run).

We probably will need LLD_VERSION at some point, though another part of me asks "when are we going to upgrade to clang-11 as the minimum version?" This issue would be moot then.

@nathanchance
Copy link
Member

Are you imagining something along the lines of this?

diff --git a/Makefile b/Makefile
index 008aba5f1a20..c443afd61886 100644
--- a/Makefile
+++ b/Makefile
@@ -984,6 +984,12 @@ ifeq ($(CONFIG_RELR),y)
 LDFLAGS_vmlinux	+= --pack-dyn-relocs=relr
 endif
 
+# We never want expected sections to be placed heuristically by the
+# linker. All sections should be explicitly named in the linker script.
+ifeq ($(CONFIG_LD_ORPHAN_WARN),y)
+LDFLAGS_vmlinux += --orphan-handling=warn
+endif
+
 # Align the bit size of userspace programs with the kernel
 KBUILD_USERCFLAGS  += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS))
 KBUILD_USERLDFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS))
diff --git a/arch/Kconfig b/arch/Kconfig
index 56b6ccc0e32d..4f7e6532289f 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -1028,6 +1028,9 @@ config HAVE_STATIC_CALL_INLINE
 	bool
 	depends on HAVE_STATIC_CALL
 
+config ARCH_WANT_LD_ORPHAN_WARN
+	bool
+
 source "kernel/gcov/Kconfig"
 
 source "scripts/gcc-plugins/Kconfig"
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index fe2f17eb2b50..002e0cf025f5 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -35,6 +35,7 @@ config ARM
 	select ARCH_USE_CMPXCHG_LOCKREF
 	select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT if MMU
 	select ARCH_WANT_IPC_PARSE_VERSION
+	select ARCH_WANT_LD_ORPHAN_WARN
 	select BINFMT_FLAT_ARGVP_ENVP_ON_STACK
 	select BUILDTIME_TABLE_SORT if MMU
 	select CLONE_BACKWARDS
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 4d76eab2b22d..e15f76ca2887 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -16,10 +16,6 @@ LDFLAGS_vmlinux	+= --be8
 KBUILD_LDFLAGS_MODULE	+= --be8
 endif
 
-# We never want expected sections to be placed heuristically by the
-# linker. All sections should be explicitly named in the linker script.
-LDFLAGS_vmlinux += $(call ld-option, --orphan-handling=warn)
-
 GZFLAGS		:=-9
 #KBUILD_CFLAGS	+=-pipe
 
diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
index 47f001ca5499..c6f9f3b61c5f 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -129,7 +129,9 @@ LDFLAGS_vmlinux += --no-undefined
 # Delete all temporary local symbols
 LDFLAGS_vmlinux += -X
 # Report orphan sections
-LDFLAGS_vmlinux += $(call ld-option, --orphan-handling=warn)
+ifeq ($(CONFIG_LD_ORPHAN_WARN),y)
+LDFLAGS_vmlinux += --orphan-handling=warn
+endif
 # Next argument is a linker script
 LDFLAGS_vmlinux += -T
 
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 1515f6f153a0..a6b5b7ef40ae 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -81,6 +81,7 @@ config ARM64
 	select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT
 	select ARCH_WANT_FRAME_POINTERS
 	select ARCH_WANT_HUGE_PMD_SHARE if ARM64_4K_PAGES || (ARM64_16K_PAGES && !ARM64_VA_BITS_36)
+	select ARCH_WANT_LD_ORPHAN_WARN
 	select ARCH_HAS_UBSAN_SANITIZE_ALL
 	select ARM_AMBA
 	select ARM_ARCH_TIMER
diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index 5789c2d18d43..6a87d592bd00 100644
--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -28,10 +28,6 @@ LDFLAGS_vmlinux	+= --fix-cortex-a53-843419
   endif
 endif
 
-# We never want expected sections to be placed heuristically by the
-# linker. All sections should be explicitly named in the linker script.
-LDFLAGS_vmlinux += $(call ld-option, --orphan-handling=warn)
-
 ifeq ($(CONFIG_ARM64_USE_LSE_ATOMICS), y)
   ifneq ($(CONFIG_ARM64_LSE_ATOMICS), y)
 $(warning LSE atomics not supported by binutils)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index e9f13fe08492..5181872f9452 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -152,6 +152,7 @@ config PPC
 	select ARCH_USE_QUEUED_SPINLOCKS	if PPC_QUEUED_SPINLOCKS
 	select ARCH_WANT_IPC_PARSE_VERSION
 	select ARCH_WANT_IRQS_OFF_ACTIVATE_MM
+	select ARCH_WANT_LD_ORPHAN_WARN
 	select ARCH_WEAK_RELEASE_ACQUIRE
 	select BINFMT_ELF
 	select BUILDTIME_TABLE_SORT
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index a4d56f0a41d9..d9eb0da845e1 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -123,7 +123,6 @@ endif
 LDFLAGS_vmlinux-y := -Bstatic
 LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) := -pie
 LDFLAGS_vmlinux	:= $(LDFLAGS_vmlinux-y)
-LDFLAGS_vmlinux += $(call ld-option,--orphan-handling=warn)
 
 ifdef CONFIG_PPC64
 ifeq ($(call cc-option-yn,-mcmodel=medium),y)
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index f6946b81f74a..fbf26e0f7a6a 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -100,6 +100,7 @@ config X86
 	select ARCH_WANT_DEFAULT_BPF_JIT	if X86_64
 	select ARCH_WANTS_DYNAMIC_TASK_STRUCT
 	select ARCH_WANT_HUGE_PMD_SHARE
+	select ARCH_WANT_LD_ORPHAN_WARN
 	select ARCH_WANTS_THP_SWAP		if X86_64
 	select BUILDTIME_TABLE_SORT
 	select CLKEVT_I8253
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 154259f18b8b..1bf21746f4ce 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -209,9 +209,6 @@ ifdef CONFIG_X86_64
 LDFLAGS_vmlinux += -z max-page-size=0x200000
 endif
 
-# We never want expected sections to be placed heuristically by the
-# linker. All sections should be explicitly named in the linker script.
-LDFLAGS_vmlinux += $(call ld-option, --orphan-handling=warn)
 
 archscripts: scripts_basic
 	$(Q)$(MAKE) $(build)=arch/x86/tools relocs
diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
index ee249088cbfe..fa1c9f83436c 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -61,7 +61,9 @@ KBUILD_LDFLAGS += $(call ld-option,--no-ld-generated-unwind-info)
 # Compressed kernel should be built as PIE since it may be loaded at any
 # address by the bootloader.
 LDFLAGS_vmlinux := -pie $(call ld-option, --no-dynamic-linker)
-LDFLAGS_vmlinux += $(call ld-option, --orphan-handling=warn)
+ifeq ($(CONFIG_LD_ORPHAN_WARN),y)
+LDFLAGS_vmlinux += --orphan-handling=warn
+endif
 LDFLAGS_vmlinux += -T
 
 hostprogs	:= mkpiggy
diff --git a/init/Kconfig b/init/Kconfig
index c9446911cf41..569c3d493030 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1348,6 +1348,11 @@ config LD_DEAD_CODE_DATA_ELIMINATION
 	  present. This option is not well tested yet, so use at your
 	  own risk.
 
+config LD_ORPHAN_WARN
+	bool "Enable linker orphan section warnings"
+	default y
+	depends on $(ld-option,--orphan-handling=warn) && ARCH_WANT_LD_ORPHAN_WARN
+
 config SYSCTL
 	bool
 

@nathanchance
Copy link
Member

another part of me asks "when are we going to upgrade to clang-11 as the minimum version?"

Unless it is this release, we need to handle this issue because --orphan-handling=warn is shipping this release.

@nickdesaulniers
Copy link
Member

Are you imagining something along the lines of this?

Yeah, I think that's nice. Then we can incrementally add on top a depends on LLD_VERSION > X to LD_ORPHAN_WARN. @kees thoughts?

Unless it is this release, we need to handle this issue because --orphan-handling=warn is shipping this release.

SGTM; if we do bump, then it should wait until 5.11.

@nickdesaulniers
Copy link
Member

also, should ARCH_WANT_LD_ORPHAN_WARN have some help text?

@nathanchance
Copy link
Member

Yeah, I think that's nice. Then we can incrementally add on top a depends on LLD_VERSION > X to LD_ORPHAN_WARN.

Cool, I will send that along first thing tomorrow morning, unless @kees has comments before then.

also, should ARCH_WANT_LD_ORPHAN_WARN have some help text?

Yes, I was being lazy :) and I have to find the right wording.

@kees
Copy link

kees commented Nov 13, 2020

I like the ARCH_WANT_LD_ORPHAN_WARN stuff, yes! I don't like having LD_ORPHAN_WARN be user-visible, though. Suggestion for help text, and collapsing into arch/Kconfig instead of init/Kconfig:

config ARCH_WANT_LD_ORPHAN_WARN
	bool
	help
	  An arch should select this symbol once all linker sections are explicitly included, size-asserted,
	  or discarded in the linker scripts. This is important because we never want expected sections
	  to be placed heuristically by the linker, since the locations of such sections can change between
	  linker versions.

config LD_ORPHAN_WARN
	def_bool_y
	depends on ARCH_WANT_LD_ORPHAN_WARN && $(ld-option,--orphan-handling=warn)

@nathanchance
Copy link
Member

Sure! I will send this series along shortly, thank you both for the input!

@nathanchance
Copy link
Member

Patches sent: https://lore.kernel.org/r/[email protected]

@nathanchance nathanchance added [BUG] linux A bug that should be fixed in the mainline kernel. [PATCH] Submitted A patch has been submitted for review labels Nov 13, 2020
@nathanchance nathanchance self-assigned this Nov 13, 2020
ruscur pushed a commit to ruscur/linux that referenced this issue Nov 13, 2020
Currently, '--orphan-handling=warn' is spread out across four different
architectures in their respective Makefiles, which makes it a little
unruly to deal with in case it needs to be disabled for a specific
linker version (in this case, ld.lld 10.0.1).

To make it easier to control this, hoist this warning into Kconfig and
the main Makefile so that disabling it is simpler, as the warning will
only be enabled in a couple places (main Makefile and a couple of
compressed boot folders that blow away LDFLAGS_vmlinx) and making it
conditional is easier due to Kconfig syntax. One small additional
benefit of this is saving a call to ld-option on incremental builds
because we will have already evaluated it for CONFIG_LD_ORPHAN_WARN.

To keep the list of supported architectures the same, introduce
CONFIG_ARCH_WANT_LD_ORPHAN_WARN, which an architecture can select to
gain this automatically after all of the sections are specified and size
asserted. A special thanks to Kees Cook for the help text on this
config.

Link: ClangBuiltLinux#1187
Signed-off-by: Nathan Chancellor <[email protected]>
ruscur pushed a commit to ruscur/linux that referenced this issue Nov 13, 2020
Currently, '--orphan-handling=warn' is spread out across four different
architectures in their respective Makefiles, which makes it a little
unruly to deal with in case it needs to be disabled for a specific
linker version (in this case, ld.lld 10.0.1).

To make it easier to control this, hoist this warning into Kconfig and
the main Makefile so that disabling it is simpler, as the warning will
only be enabled in a couple places (main Makefile and a couple of
compressed boot folders that blow away LDFLAGS_vmlinx) and making it
conditional is easier due to Kconfig syntax. One small additional
benefit of this is saving a call to ld-option on incremental builds
because we will have already evaluated it for CONFIG_LD_ORPHAN_WARN.

To keep the list of supported architectures the same, introduce
CONFIG_ARCH_WANT_LD_ORPHAN_WARN, which an architecture can select to
gain this automatically after all of the sections are specified and size
asserted. A special thanks to Kees Cook for the help text on this
config.

Link: ClangBuiltLinux#1187
Signed-off-by: Nathan Chancellor <[email protected]>
ruscur pushed a commit to ruscur/linux that referenced this issue Nov 13, 2020
ld.lld 10.0.1 spews a bunch of various warnings about .rela sections,
along with a few others. Newer versions of ld.lld do not have these
warnings. As a result, do not add '--orphan-handling=warn' to
LDFLAGS_vmlinux if ld.lld's version is not new enough.

Reported-by: Arvind Sankar <[email protected]>
Reported-by: kernelci.org bot <[email protected]>
Reported-by: Mark Brown <[email protected]>
Link: ClangBuiltLinux#1187
Link: ClangBuiltLinux#1193
Signed-off-by: Nathan Chancellor <[email protected]>
fengguang pushed a commit to 0day-ci/linux that referenced this issue Nov 13, 2020
Currently, '--orphan-handling=warn' is spread out across four different
architectures in their respective Makefiles, which makes it a little
unruly to deal with in case it needs to be disabled for a specific
linker version (in this case, ld.lld 10.0.1).

To make it easier to control this, hoist this warning into Kconfig and
the main Makefile so that disabling it is simpler, as the warning will
only be enabled in a couple places (main Makefile and a couple of
compressed boot folders that blow away LDFLAGS_vmlinx) and making it
conditional is easier due to Kconfig syntax. One small additional
benefit of this is saving a call to ld-option on incremental builds
because we will have already evaluated it for CONFIG_LD_ORPHAN_WARN.

To keep the list of supported architectures the same, introduce
CONFIG_ARCH_WANT_LD_ORPHAN_WARN, which an architecture can select to
gain this automatically after all of the sections are specified and size
asserted. A special thanks to Kees Cook for the help text on this
config.

Link: ClangBuiltLinux#1187
Signed-off-by: Nathan Chancellor <[email protected]>
fengguang pushed a commit to 0day-ci/linux that referenced this issue Nov 13, 2020
ld.lld 10.0.1 spews a bunch of various warnings about .rela sections,
along with a few others. Newer versions of ld.lld do not have these
warnings. As a result, do not add '--orphan-handling=warn' to
LDFLAGS_vmlinux if ld.lld's version is not new enough.

Reported-by: Arvind Sankar <[email protected]>
Reported-by: kernelci.org bot <[email protected]>
Reported-by: Mark Brown <[email protected]>
Link: ClangBuiltLinux#1187
Link: ClangBuiltLinux#1193
Signed-off-by: Nathan Chancellor <[email protected]>
@nathanchance
Copy link
Member

ruscur pushed a commit to ruscur/linux that referenced this issue Nov 25, 2020
Currently, '--orphan-handling=warn' is spread out across four different
architectures in their respective Makefiles, which makes it a little
unruly to deal with in case it needs to be disabled for a specific
linker version (in this case, ld.lld 10.0.1).

To make it easier to control this, hoist this warning into Kconfig and
the main Makefile so that disabling it is simpler, as the warning will
only be enabled in a couple places (main Makefile and a couple of
compressed boot folders that blow away LDFLAGS_vmlinx) and making it
conditional is easier due to Kconfig syntax. One small additional
benefit of this is saving a call to ld-option on incremental builds
because we will have already evaluated it for CONFIG_LD_ORPHAN_WARN.

To keep the list of supported architectures the same, introduce
CONFIG_ARCH_WANT_LD_ORPHAN_WARN, which an architecture can select to
gain this automatically after all of the sections are specified and size
asserted. A special thanks to Kees Cook for the help text on this
config.

Link: ClangBuiltLinux#1187
Acked-by: Kees Cook <[email protected]>
Acked-by: Michael Ellerman <[email protected]> (powerpc)
Reviewed-by: Nick Desaulniers <[email protected]>
Tested-by: Nick Desaulniers <[email protected]>
Signed-off-by: Nathan Chancellor <[email protected]>
Signed-off-by: Kees Cook <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
ruscur pushed a commit to ruscur/linux that referenced this issue Nov 25, 2020
ld.lld 10.0.1 spews a bunch of various warnings about .rela sections,
along with a few others. Newer versions of ld.lld do not have these
warnings. As a result, do not add '--orphan-handling=warn' to
LDFLAGS_vmlinux if ld.lld's version is not new enough.

Link: ClangBuiltLinux#1187
Link: ClangBuiltLinux#1193
Reported-by: Arvind Sankar <[email protected]>
Reported-by: kernelci.org bot <[email protected]>
Reported-by: Mark Brown <[email protected]>
Reviewed-by: Kees Cook <[email protected]>
Signed-off-by: Nathan Chancellor <[email protected]>
Reviewed-by: Nick Desaulniers <[email protected]>
Signed-off-by: Kees Cook <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
@nickdesaulniers nickdesaulniers added [PATCH] Accepted A submitted patch has been accepted upstream and removed [PATCH] Submitted A patch has been submitted for review labels Dec 1, 2020
ruscur pushed a commit to ruscur/linux that referenced this issue Dec 3, 2020
Currently, '--orphan-handling=warn' is spread out across four different
architectures in their respective Makefiles, which makes it a little
unruly to deal with in case it needs to be disabled for a specific
linker version (in this case, ld.lld 10.0.1).

To make it easier to control this, hoist this warning into Kconfig and
the main Makefile so that disabling it is simpler, as the warning will
only be enabled in a couple places (main Makefile and a couple of
compressed boot folders that blow away LDFLAGS_vmlinx) and making it
conditional is easier due to Kconfig syntax. One small additional
benefit of this is saving a call to ld-option on incremental builds
because we will have already evaluated it for CONFIG_LD_ORPHAN_WARN.

To keep the list of supported architectures the same, introduce
CONFIG_ARCH_WANT_LD_ORPHAN_WARN, which an architecture can select to
gain this automatically after all of the sections are specified and size
asserted. A special thanks to Kees Cook for the help text on this
config.

Link: ClangBuiltLinux#1187
Acked-by: Kees Cook <[email protected]>
Acked-by: Michael Ellerman <[email protected]> (powerpc)
Reviewed-by: Nick Desaulniers <[email protected]>
Tested-by: Nick Desaulniers <[email protected]>
Signed-off-by: Nathan Chancellor <[email protected]>
Signed-off-by: Masahiro Yamada <[email protected]>
ruscur pushed a commit to ruscur/linux that referenced this issue Dec 3, 2020
ld.lld 10.0.1 spews a bunch of various warnings about .rela sections,
along with a few others. Newer versions of ld.lld do not have these
warnings. As a result, do not add '--orphan-handling=warn' to
LDFLAGS_vmlinux if ld.lld's version is not new enough.

Link: ClangBuiltLinux#1187
Link: ClangBuiltLinux#1193
Reported-by: Arvind Sankar <[email protected]>
Reported-by: kernelci.org bot <[email protected]>
Reported-by: Mark Brown <[email protected]>
Reviewed-by: Kees Cook <[email protected]>
Signed-off-by: Nathan Chancellor <[email protected]>
Reviewed-by: Nick Desaulniers <[email protected]>
Signed-off-by: Masahiro Yamada <[email protected]>
@nickdesaulniers nickdesaulniers added [FIXED][LINUX] 5.10 This bug was fixed in Linux 5.10 and removed [PATCH] Accepted A submitted patch has been accepted upstream labels Dec 8, 2020
@nathanchance nathanchance added the Orphan section An linker orphan section warning label May 6, 2021
Kendrenogen pushed a commit to Kendrenogen/android_kernel_lge_sm8150 that referenced this issue Mar 26, 2024
Currently, '--orphan-handling=warn' is spread out across four different
architectures in their respective Makefiles, which makes it a little
unruly to deal with in case it needs to be disabled for a specific
linker version (in this case, ld.lld 10.0.1).

To make it easier to control this, hoist this warning into Kconfig and
the main Makefile so that disabling it is simpler, as the warning will
only be enabled in a couple places (main Makefile and a couple of
compressed boot folders that blow away LDFLAGS_vmlinx) and making it
conditional is easier due to Kconfig syntax. One small additional
benefit of this is saving a call to ld-option on incremental builds
because we will have already evaluated it for CONFIG_LD_ORPHAN_WARN.

To keep the list of supported architectures the same, introduce
CONFIG_ARCH_WANT_LD_ORPHAN_WARN, which an architecture can select to
gain this automatically after all of the sections are specified and size
asserted. A special thanks to Kees Cook for the help text on this
config.

Link: ClangBuiltLinux/linux#1187
Acked-by: Kees Cook <[email protected]>
Acked-by: Michael Ellerman <[email protected]> (powerpc)
Reviewed-by: Nick Desaulniers <[email protected]>
Tested-by: Nick Desaulniers <[email protected]>
Signed-off-by: Nathan Chancellor <[email protected]>
Signed-off-by: Masahiro Yamada <[email protected]>
Kendrenogen pushed a commit to Kendrenogen/android_kernel_lge_sm8150 that referenced this issue Mar 26, 2024
ld.lld 10.0.1 spews a bunch of various warnings about .rela sections,
along with a few others. Newer versions of ld.lld do not have these
warnings. As a result, do not add '--orphan-handling=warn' to
LDFLAGS_vmlinux if ld.lld's version is not new enough.

Link: ClangBuiltLinux/linux#1187
Link: ClangBuiltLinux/linux#1193
Reported-by: Arvind Sankar <[email protected]>
Reported-by: kernelci.org bot <[email protected]>
Reported-by: Mark Brown <[email protected]>
Reviewed-by: Kees Cook <[email protected]>
Signed-off-by: Nathan Chancellor <[email protected]>
Reviewed-by: Nick Desaulniers <[email protected]>
Signed-off-by: Masahiro Yamada <[email protected]>
Kendrenogen pushed a commit to Kendrenogen/android_kernel_lge_sm8150 that referenced this issue May 7, 2024
Currently, '--orphan-handling=warn' is spread out across four different
architectures in their respective Makefiles, which makes it a little
unruly to deal with in case it needs to be disabled for a specific
linker version (in this case, ld.lld 10.0.1).

To make it easier to control this, hoist this warning into Kconfig and
the main Makefile so that disabling it is simpler, as the warning will
only be enabled in a couple places (main Makefile and a couple of
compressed boot folders that blow away LDFLAGS_vmlinx) and making it
conditional is easier due to Kconfig syntax. One small additional
benefit of this is saving a call to ld-option on incremental builds
because we will have already evaluated it for CONFIG_LD_ORPHAN_WARN.

To keep the list of supported architectures the same, introduce
CONFIG_ARCH_WANT_LD_ORPHAN_WARN, which an architecture can select to
gain this automatically after all of the sections are specified and size
asserted. A special thanks to Kees Cook for the help text on this
config.

Link: ClangBuiltLinux/linux#1187
Acked-by: Kees Cook <[email protected]>
Acked-by: Michael Ellerman <[email protected]> (powerpc)
Reviewed-by: Nick Desaulniers <[email protected]>
Tested-by: Nick Desaulniers <[email protected]>
Signed-off-by: Nathan Chancellor <[email protected]>
Signed-off-by: Masahiro Yamada <[email protected]>
Kendrenogen pushed a commit to Kendrenogen/android_kernel_lge_sm8150 that referenced this issue May 7, 2024
ld.lld 10.0.1 spews a bunch of various warnings about .rela sections,
along with a few others. Newer versions of ld.lld do not have these
warnings. As a result, do not add '--orphan-handling=warn' to
LDFLAGS_vmlinux if ld.lld's version is not new enough.

Link: ClangBuiltLinux/linux#1187
Link: ClangBuiltLinux/linux#1193
Reported-by: Arvind Sankar <[email protected]>
Reported-by: kernelci.org bot <[email protected]>
Reported-by: Mark Brown <[email protected]>
Reviewed-by: Kees Cook <[email protected]>
Signed-off-by: Nathan Chancellor <[email protected]>
Reviewed-by: Nick Desaulniers <[email protected]>
Signed-off-by: Masahiro Yamada <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[BUG] linux A bug that should be fixed in the mainline kernel. [FIXED][LINUX] 5.10 This bug was fixed in Linux 5.10 Orphan section An linker orphan section warning [TOOL] lld The issue is relevant to LLD linker
Projects
None yet
Development

No branches or pull requests

4 participants