You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.5 KiB

  1. dnl Checks whether the stack can be marked nonexecutable by passing an option
  2. dnl to the C-compiler when acting on .s files. Appends that option to ASFLAGS.
  3. dnl This macro is adapted from one found in GLIBC-2.3.5.
  4. AC_DEFUN([CL_AS_NOEXECSTACK],[
  5. AC_REQUIRE([AC_PROG_CC])
  6. AC_CACHE_CHECK([whether --noexecstack is desirable for .s files], cl_cv_as_noexecstack, [dnl
  7. cat > conftest.c <<EOF
  8. void foo() {}
  9. EOF
  10. if AC_TRY_COMMAND([${CC} $CFLAGS $CPPFLAGS
  11. -S -o conftest.s conftest.c >/dev/null]) \
  12. && grep -q .note.GNU-stack conftest.s \
  13. && AC_TRY_COMMAND([${CC} $CFLAGS $CPPFLAGS -Wa,--noexecstack
  14. -c -o conftest.o conftest.s >/dev/null])
  15. then
  16. cl_cv_as_noexecstack=yes
  17. else
  18. cl_cv_as_noexecstack=no
  19. fi
  20. rm -f conftest*])
  21. if test "$cl_cv_as_noexecstack" = yes; then
  22. ASMFLAGS="$ASMFLAGS -Wa,--noexecstack"
  23. fi
  24. AC_SUBST(ASMFLAGS)
  25. ])
  26. dnl Checks whether the compiler supports __attribute__((flatten)).
  27. AC_DEFUN([CL_ATTRIBUTE_FLATTEN],[
  28. AC_REQUIRE([AC_PROG_CXX])
  29. AC_CACHE_CHECK([whether the compiler supports __attribute__((flatten))], cl_cv_have_attr_flatten, [dnl
  30. cat > conftest.cc <<EOF
  31. void f() __attribute__((flatten));
  32. EOF
  33. if AC_TRY_COMMAND(${CXX-g++} $CXXFLAGS -c conftest.cc >/dev/null 2>conftest.stderr)
  34. then
  35. if grep -i "warning" conftest.stderr > /dev/null; then
  36. cl_cv_have_attr_flatten=no
  37. else
  38. cl_cv_have_attr_flatten=yes
  39. fi
  40. else
  41. cl_cv_have_attr_flatten=no
  42. fi
  43. rm -f conftest*
  44. ])
  45. if test $cl_cv_have_attr_flatten = yes; then
  46. AC_DEFINE(CL_HAVE_ATTRIBUTE_FLATTEN)
  47. fi
  48. ])