]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
objtool: Warn on functions with ambiguous -ffunction-sections section names
authorJosh Poimboeuf <jpoimboe@kernel.org>
Wed, 12 Nov 2025 23:47:51 +0000 (15:47 -0800)
committerIngo Molnar <mingo@kernel.org>
Thu, 13 Nov 2025 07:03:10 +0000 (08:03 +0100)
commit9c7dc1dd897a1cdcade9566ea4664b03fbabf4a4
treed3c5ac9ee2f13b761589c5b368550b7a4aee8d7b
parent0330b7fbbf313b35470306a492b9e7a703b5af56
objtool: Warn on functions with ambiguous -ffunction-sections section names

When compiled with -ffunction-sections, a function named startup() will
be placed in .text.startup.  However, .text.startup is also used by the
compiler for functions with __attribute__((constructor)).

That creates an ambiguity for the vmlinux linker script, which needs to
differentiate those two cases.

Similar naming conflicts exist for functions named exit(), split(),
unlikely(), hot() and unknown().

One potential solution would be to use '#ifdef CC_USING_FUNCTION_SECTIONS'
to create two distinct implementations of the TEXT_MAIN macro.  However,
-ffunction-sections can be (and is) enabled or disabled on a per-object
basis (for example via ccflags-y or AUTOFDO_PROFILE).

So the recently unified TEXT_MAIN macro (commit 1ba9f8979426
("vmlinux.lds: Unify TEXT_MAIN, DATA_MAIN, and related macros")) is
necessary.  This means there's no way for the linker script to
disambiguate things.

Instead, use objtool to warn on any function names whose resulting
section names might create ambiguity when the kernel is compiled (in
whole or in part) with -ffunction-sections.

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: live-patching@vger.kernel.org
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://patch.msgid.link/65fedea974fe14be487c8867a0b8d0e4a294ce1e.1762991150.git.jpoimboe@kernel.org
include/asm-generic/vmlinux.lds.h
tools/objtool/Documentation/objtool.txt
tools/objtool/check.c