gcc-check-fpatchable-function-entry.sh 933 B

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