Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

authored by

Josh Poimboeuf and committed by
Peter Zijlstra
93863f3f 31863337

+30 -1
+1 -1
include/asm-generic/vmlinux.lds.h
··· 110 110 * .text.startup could be __attribute__((constructor)) code in a *non* 111 111 * ffunction-sections object, which should be placed in .init.text; or it could 112 112 * be an actual function named startup() in an ffunction-sections object, which 113 - * should be placed in .text. Objtool will detect and complain about any such 113 + * should be placed in .text. The build will detect and complain about any such 114 114 * ambiguously named functions. 115 115 */ 116 116 #define TEXT_MAIN \
+4
scripts/Makefile.vmlinux_o
··· 63 63 --start-group $(KBUILD_VMLINUX_LIBS) --end-group \ 64 64 $(cmd_objtool) 65 65 66 + cmd_check_function_names = $(srctree)/scripts/check-function-names.sh $@ 67 + 66 68 define rule_ld_vmlinux.o 67 69 $(call cmd_and_savecmd,ld_vmlinux.o) 68 70 $(call cmd,gen_objtooldep) 71 + $(call cmd,check_function_names) 69 72 endef 73 + 70 74 71 75 vmlinux.o: $(initcalls-lds) vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE 72 76 $(call if_changed_rule,ld_vmlinux.o)
+25
scripts/check-function-names.sh
··· 1 + #!/bin/sh 2 + # SPDX-License-Identifier: GPL-2.0 3 + # 4 + # Certain function names are disallowed due to section name ambiguities 5 + # introduced by -ffunction-sections. 6 + # 7 + # See the comment above TEXT_MAIN in include/asm-generic/vmlinux.lds.h. 8 + 9 + objfile="$1" 10 + 11 + if [ ! -f "$objfile" ]; then 12 + echo "usage: $0 <file.o>" >&2 13 + exit 1 14 + fi 15 + 16 + bad_symbols=$(nm "$objfile" | awk '$2 ~ /^[TtWw]$/ {print $3}' | grep -E '^(startup|exit|split|unlikely|hot|unknown)(\.|$)') 17 + 18 + if [ -n "$bad_symbols" ]; then 19 + echo "$bad_symbols" | while read -r sym; do 20 + echo "$objfile: error: $sym() function name creates ambiguity with -ffunction-sections" >&2 21 + done 22 + exit 1 23 + fi 24 + 25 + exit 0