prom_init_check.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/bin/sh
  2. #
  3. # Copyright © 2008 IBM Corporation
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU General Public License
  7. # as published by the Free Software Foundation; either version
  8. # 2 of the License, or (at your option) any later version.
  9. # This script checks prom_init.o to see what external symbols it
  10. # is using, if it finds symbols not in the whitelist it returns
  11. # an error. The point of this is to discourage people from
  12. # intentionally or accidentally adding new code to prom_init.c
  13. # which has side effects on other parts of the kernel.
  14. # If you really need to reference something from prom_init.o add
  15. # it to the list below:
  16. WHITELIST="add_reloc_offset __bss_start __bss_stop copy_and_flush
  17. _end enter_prom memcpy memset reloc_offset __secondary_hold
  18. __secondary_hold_acknowledge __secondary_hold_spinloop __start
  19. strcmp strcpy strlcpy strlen strncmp strstr logo_linux_clut224
  20. reloc_got2 kernstart_addr memstart_addr linux_banner _stext
  21. __prom_init_toc_start __prom_init_toc_end btext_setup_display TOC."
  22. NM="$1"
  23. OBJ="$2"
  24. ERROR=0
  25. for UNDEF in $($NM -u $OBJ | awk '{print $2}')
  26. do
  27. # On 64-bit nm gives us the function descriptors, which have
  28. # a leading . on the name, so strip it off here.
  29. UNDEF="${UNDEF#.}"
  30. if [ $KBUILD_VERBOSE ]; then
  31. if [ $KBUILD_VERBOSE -ne 0 ]; then
  32. echo "Checking prom_init.o symbol '$UNDEF'"
  33. fi
  34. fi
  35. OK=0
  36. for WHITE in $WHITELIST
  37. do
  38. if [ "$UNDEF" = "$WHITE" ]; then
  39. OK=1
  40. break
  41. fi
  42. done
  43. # ignore register save/restore funcitons
  44. case $UNDEF in
  45. _restgpr_*|_restgpr0_*|_rest32gpr_*)
  46. OK=1
  47. ;;
  48. _savegpr_*|_savegpr0_*|_save32gpr_*)
  49. OK=1
  50. ;;
  51. esac
  52. if [ $OK -eq 0 ]; then
  53. ERROR=1
  54. echo "Error: External symbol '$UNDEF' referenced" \
  55. "from prom_init.c" >&2
  56. fi
  57. done
  58. exit $ERROR