check-fpatchable-function-entry.sh 917 B

12345678910111213141516171819202122232425
  1. #!/bin/bash
  2. # SPDX-License-Identifier: GPL-2.0
  3. set -e
  4. # To debug, uncomment the following line
  5. # set -x
  6. # Output from -fpatchable-function-entry can only vary on ppc64 elfv2, so this
  7. # should not be invoked for other targets. Therefore we can pass in -m64 and
  8. # -mabi explicitly, to take care of toolchains defaulting to other targets.
  9. # Test whether the compile option -fpatchable-function-entry exists and
  10. # generates appropriate code
  11. echo "int func() { return 0; }" | \
  12. $* -m64 -mabi=elfv2 -S -x c -O2 -fpatchable-function-entry=2 - -o - 2> /dev/null | \
  13. grep -q "__patchable_function_entries"
  14. # Test whether nops are generated after the local entry point
  15. echo "int x; int func() { return x; }" | \
  16. $* -m64 -mabi=elfv2 -S -x c -O2 -fpatchable-function-entry=2 - -o - 2> /dev/null | \
  17. awk 'BEGIN { RS = ";" } /\.localentry.*nop.*\n[[:space:]]*nop/ { print $0 }' | \
  18. grep -q "func:"
  19. exit 0