check-function-names.sh 645 B

12345678910111213141516171819202122232425
  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. objfile="$1"
  9. if [ ! -f "$objfile" ]; then
  10. echo "usage: $0 <file.o>" >&2
  11. exit 1
  12. fi
  13. bad_symbols=$(${NM:-nm} "$objfile" | awk '$2 ~ /^[TtWw]$/ {print $3}' | grep -E '^(startup|exit|split|unlikely|hot|unknown)(\.|$)')
  14. if [ -n "$bad_symbols" ]; then
  15. echo "$bad_symbols" | while read -r sym; do
  16. echo "$objfile: error: $sym() function name creates ambiguity with -ffunction-sections" >&2
  17. done
  18. exit 1
  19. fi
  20. exit 0