From nobody Tue Dec 2 02:05:18 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0FC75347BB4 for ; Thu, 20 Nov 2025 20:15:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763669705; cv=none; b=MfSbN6RdABWTMgtSSdIkF3gIXhP1ww040Xo9+3xEjvpMWTDI/q4+92fp9ZOadjBOfbswrCra3Blme70bQpeNAxP8iE35Z1WMZvPQk1uDstsrekAE8N5WGhnIi987ES4tprFHSXaXhSxRPf7YaTjr8stesTL97q36y61gHIWkOYc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763669705; c=relaxed/simple; bh=JB04Mjmoj1HHH7/cbsaMD0Jj5HOZq/GZTvrZ/wMeAEw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DDmCs9ybeX74+lzcs+rzFVoxWjPOUTsFoQmmZZ3KzH1DNKBPPH+rRI8LiHFXWq28PHbvpI5Xf9nl7GUaGA64B0aEOMlQgBJ8Lt52MlbARdxLb2P02rxv0ouEk90C5hwipoOuYNBz05oE9Nd3KociyOAKQ3YKnC18dTZCwYhUD7k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=h6nF6RuP; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="h6nF6RuP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95B9BC4CEF1; Thu, 20 Nov 2025 20:15:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763669704; bh=JB04Mjmoj1HHH7/cbsaMD0Jj5HOZq/GZTvrZ/wMeAEw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h6nF6RuP+ObzteGFIfTCYc53l8rgY5Qk1YRU9K79TisC+tTDsZey2hSvVpspl8Cwe kTzkoE+0E41tyFGc9bVjbboq+I/iE8jVKAzH/8pbAQpqAc89P46oRekFhBGFNO204E 2K8vakiOXE8WxspwV87RaJ3ZeLfPyqG1EmU5vAdfc/sA9E3/tmO5PbxxmrwlqvH6u1 1GyAem1LwobThJDEoJwyGFXUj+kfjN1PrsjwxK3A6pJvFeHjT48m8KFS6pAEuWyya/ Vk1sx/wZXy4L1di1m3OeIR68Jqu52z8/iOp25cx38uSCcid2l5/ojtTgA/zqYHXKgc HK2nY75+Wj1+Q== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Greg Kroah-Hartman , Jiri Slaby , Mauro Carvalho Chehab , Hans de Goede Subject: [PATCH 5/6] kbuild: Check for functions with ambiguous -ffunction-sections section names Date: Thu, 20 Nov 2025 12:14:20 -0800 Message-ID: X-Mailer: git-send-email 2.51.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Commit 9c7dc1dd897a ("objtool: Warn on functions with ambiguous -ffunction-sections section names") only works for drivers which are compiled on architectures supported by objtool. Make a script to perform the same check for all architectures. Signed-off-by: Josh Poimboeuf --- include/asm-generic/vmlinux.lds.h | 2 +- scripts/Makefile.vmlinux_o | 4 ++++ scripts/check-function-names.sh | 25 +++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100755 scripts/check-function-names.sh diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinu= x.lds.h index 5efe1de2209b..0cdae6f809b5 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -110,7 +110,7 @@ * .text.startup could be __attribute__((constructor)) code in a *non* * ffunction-sections object, which should be placed in .init.text; or it = could * be an actual function named startup() in an ffunction-sections object, = which - * should be placed in .text. Objtool will detect and complain about any = such + * should be placed in .text. The build will detect and complain about an= y such * ambiguously named functions. */ #define TEXT_MAIN \ diff --git a/scripts/Makefile.vmlinux_o b/scripts/Makefile.vmlinux_o index 20533cc0b1ee..527352c222ff 100644 --- a/scripts/Makefile.vmlinux_o +++ b/scripts/Makefile.vmlinux_o @@ -63,11 +63,15 @@ quiet_cmd_ld_vmlinux.o =3D LD $@ --start-group $(KBUILD_VMLINUX_LIBS) --end-group \ $(cmd_objtool) =20 +cmd_check_function_names =3D $(srctree)/scripts/check-function-names.sh $@ + define rule_ld_vmlinux.o $(call cmd_and_savecmd,ld_vmlinux.o) $(call cmd,gen_objtooldep) + $(call cmd,check_function_names) endef =20 + vmlinux.o: $(initcalls-lds) vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE $(call if_changed_rule,ld_vmlinux.o) =20 diff --git a/scripts/check-function-names.sh b/scripts/check-function-names= .sh new file mode 100755 index 000000000000..410042591cfc --- /dev/null +++ b/scripts/check-function-names.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# +# Certain function names are disallowed due to section name ambiguities +# introduced by -ffunction-sections. +# +# See the comment above TEXT_MAIN in include/asm-generic/vmlinux.lds.h. + +objfile=3D"$1" + +if [ ! -f "$objfile" ]; then + echo "usage: $0 " >&2 + exit 1 +fi + +bad_symbols=3D$(nm "$objfile" | awk '$2 ~ /^[TtWw]$/ {print $3}' | grep -E= '^(startup|exit|split|unlikely|hot|unknown)(\.|$)') + +if [ -n "$bad_symbols" ]; then + echo "$bad_symbols" | while read -r sym; do + echo "$objfile: error: $sym() function name creates ambiguity with -ffun= ction-sections" >&2 + done + exit 1 +fi + +exit 0 --=20 2.51.1