~ubuntu-branches/ubuntu/hardy/gnupg/hardy-updates

« back to all changes in this revision

Viewing changes to m4/noexecstack.m4

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2006-11-03 09:18:26 UTC
  • mto: This revision was merged to the branch mainline in revision 11.
  • Revision ID: james.westby@ubuntu.com-20061103091826-89kwl8tk1xypbmtk
Tags: upstream-1.4.5
ImportĀ upstreamĀ versionĀ 1.4.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# noexecstack.m4
 
2
dnl Copyright (C) 1995-2006 Free Software Foundation, Inc.
 
3
dnl
 
4
dnl This library is free software; you can redistribute it and/or
 
5
dnl modify it under the terms of the GNU Lesser General Public
 
6
dnl License as published by the Free Software Foundation; either
 
7
dnl version 2.1 of the License, or (at your option) any later version.
 
8
dnl
 
9
dnl This library is distributed in the hope that it will be useful,
 
10
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
dnl Lesser General Public License for more details.
 
13
dnl
 
14
dnl You should have received a copy of the GNU Lesser General Public
 
15
dnl License along with this library; if not, write to the Free Software
 
16
dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
 
17
 
 
18
dnl Checks whether the stack can be marked nonexecutable by passing an
 
19
dnl option to the C-compiler when acting on .s files.  Returns that
 
20
dnl option in NOEXECSTACK_FLAGS.
 
21
dnl This macro is adapted from one found in GLIBC-2.3.5.
 
22
AC_DEFUN([CL_AS_NOEXECSTACK],[
 
23
AC_REQUIRE([AC_PROG_CC])
 
24
AC_REQUIRE([AM_PROG_AS])
 
25
 
 
26
AC_MSG_CHECKING([whether non excutable stack support is requested])
 
27
AC_ARG_ENABLE(noexecstack,
 
28
              AC_HELP_STRING([--enable-noexecstack],
 
29
                             [enable non executable stack support (gcc only)]),
 
30
              noexecstack_support=$enableval, noexecstack_support=no)
 
31
AC_MSG_RESULT($noexecstack_support)
 
32
 
 
33
AC_CACHE_CHECK([whether assembler supports --noexecstack option],
 
34
cl_cv_as_noexecstack, [dnl
 
35
  cat > conftest.c <<EOF
 
36
void foo() {}
 
37
EOF
 
38
  if AC_TRY_COMMAND([${CC} $CFLAGS $CPPFLAGS
 
39
                     -S -o conftest.s conftest.c >/dev/null]) \
 
40
     && grep -q .note.GNU-stack conftest.s \
 
41
     && AC_TRY_COMMAND([${CCAS} $CCASFLAGS $CPPFLAGS -Wa,--noexecstack
 
42
                       -c -o conftest.o conftest.s >/dev/null])
 
43
  then
 
44
    cl_cv_as_noexecstack=yes
 
45
  else
 
46
    cl_cv_as_noexecstack=no
 
47
  fi
 
48
  rm -f conftest*])
 
49
  if test "$noexecstack_support" = yes -a "$cl_cv_as_noexecstack" = yes; then
 
50
        NOEXECSTACK_FLAGS="-Wa,--noexecstack"
 
51
  else
 
52
        NOEXECSTACK_FLAGS=
 
53
  fi
 
54
  AC_SUBST(NOEXECSTACK_FLAGS)
 
55
])