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.6 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_REQUIRE([AM_PROG_AS])
  7. AC_CACHE_CHECK([whether --noexecstack is desirable for .s files], cl_cv_as_noexecstack, [dnl
  8. cat > conftest.c <<EOF
  9. void foo() {}
  10. EOF
  11. if AC_TRY_COMMAND([${CCAS} $CFLAGS $CPPFLAGS
  12. -S -o conftest.s conftest.c >/dev/null]) \
  13. && grep -q .note.GNU-stack conftest.s \
  14. && AC_TRY_COMMAND([${CCAS} $CFLAGS $CPPFLAGS -Wa,--noexecstack
  15. -c -o conftest.o conftest.s >/dev/null])
  16. then
  17. cl_cv_as_noexecstack=yes
  18. else
  19. cl_cv_as_noexecstack=no
  20. fi
  21. rm -f conftest*])
  22. if test "$cl_cv_as_noexecstack" = yes; then
  23. CCASFLAGS="$CCASFLAGS -Wa,--noexecstack"
  24. fi
  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, ,[Define if compiler supports __attribute__((flatten))])
  47. fi
  48. ])