xref: /linux/scripts/check-function-names.sh (revision 62085877ae6592be830c2267e35dc469cb706308)
193863f3fSJosh Poimboeuf#!/bin/sh
293863f3fSJosh Poimboeuf# SPDX-License-Identifier: GPL-2.0
393863f3fSJosh Poimboeuf#
493863f3fSJosh Poimboeuf# Certain function names are disallowed due to section name ambiguities
593863f3fSJosh Poimboeuf# introduced by -ffunction-sections.
693863f3fSJosh Poimboeuf#
793863f3fSJosh Poimboeuf# See the comment above TEXT_MAIN in include/asm-generic/vmlinux.lds.h.
893863f3fSJosh Poimboeuf
993863f3fSJosh Poimboeufobjfile="$1"
1093863f3fSJosh Poimboeuf
1193863f3fSJosh Poimboeufif [ ! -f "$objfile" ]; then
1293863f3fSJosh Poimboeuf	echo "usage: $0 <file.o>" >&2
1393863f3fSJosh Poimboeuf	exit 1
1493863f3fSJosh Poimboeuffi
1593863f3fSJosh Poimboeuf
16*946d4623SCarlos Llamasbad_symbols=$(${NM:-nm} "$objfile" | awk '$2 ~ /^[TtWw]$/ {print $3}' | grep -E '^(startup|exit|split|unlikely|hot|unknown)(\.|$)')
1793863f3fSJosh Poimboeuf
1893863f3fSJosh Poimboeufif [ -n "$bad_symbols" ]; then
1993863f3fSJosh Poimboeuf	echo "$bad_symbols" | while read -r sym; do
2093863f3fSJosh Poimboeuf		echo "$objfile: error: $sym() function name creates ambiguity with -ffunction-sections" >&2
2193863f3fSJosh Poimboeuf	done
2293863f3fSJosh Poimboeuf	exit 1
2393863f3fSJosh Poimboeuffi
2493863f3fSJosh Poimboeuf
2593863f3fSJosh Poimboeufexit 0
26