diff options
| author | Josh Poimboeuf <jpoimboe@kernel.org> | 2025-11-20 12:14:20 -0800 |
|---|---|---|
| committer | Peter Zijlstra <peterz@infradead.org> | 2025-11-21 10:04:10 +0100 |
| commit | 93863f3f859a626347ce2ec18947b11357b4ca14 (patch) | |
| tree | 9fe324f0bd90059b763d4bb51353896520c79fb8 /scripts/check-function-names.sh | |
| parent | 31863337138a0482d614f1090727dac87c936959 (diff) | |
| download | linux-93863f3f859a626347ce2ec18947b11357b4ca14.tar.gz | |
kbuild: Check for functions with ambiguous -ffunction-sections section names
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 <jpoimboe@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://patch.msgid.link/a6a49644a34964f7e02f3a8ce43af03e72817180.1763669451.git.jpoimboe@kernel.org
Diffstat (limited to 'scripts/check-function-names.sh')
| -rwxr-xr-x | scripts/check-function-names.sh | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/scripts/check-function-names.sh b/scripts/check-function-names.sh new file mode 100755 index 00000000000000..410042591cfc40 --- /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="$1" + +if [ ! -f "$objfile" ]; then + echo "usage: $0 <file.o>" >&2 + exit 1 +fi + +bad_symbols=$(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 -ffunction-sections" >&2 + done + exit 1 +fi + +exit 0 |
