]> www.ginac.de Git - cln.git/commitdiff
* m4/cc.m4 (CL_AS_NOEXECSTACK): New macro...
authorRichard Kreckel <kreckel@ginac.de>
Mon, 15 Aug 2005 21:19:16 +0000 (21:19 +0000)
committerRichard Kreckel <kreckel@ginac.de>
Mon, 15 Aug 2005 21:19:16 +0000 (21:19 +0000)
* configure.ac: ...used here for setting ASMFLAGS...
* src/Makefile.in: ...which are used here.

ChangeLog
configure.ac
m4/cc.m4
src/Makefile.in

index 299a5421033b77497be2a2f1711b6b176560a836..1d33bd04b0418a8b0f9c706442d3416eff7cc433 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2005-08-15  Richard B. Kreckel  <kreckel@ginac.de>
+
+       * m4/cc.m4 (CL_AS_NOEXECSTACK): New macro...
+       * configure.ac: ...used here for setting ASMFLAGS...
+       * src/Makefile.in: ...which are used here.
+
 2005-08-02  Andreas Jochens  <aj@andaco.de>
 
        * include/cln/config.h.in: Add support for PowerPC 64 CPU.
index bd77b6d41545d164f59bac476ae7f278cabda242..602048562884d3b6f61fb9ba33af8aefde192805 100644 (file)
@@ -51,6 +51,8 @@ AC_PROG_CXXCPP
                       dnl sets variable CXXCPP
 CL_AS_UNDERSCORE
                       dnl sets variable AS_UNDERSCORE, DEFS ASM_UNDERSCORE
+CL_AS_NOEXECSTACK
+                      dnl sets variable ASMFLAGS
 AC_PROG_RANLIB
                       dnl sets variable RANLIB
 AC_PROG_INSTALL
index 9a8326c5cb692254733cb11c30513771f8623e21..ec6c5e8c3471c0ac48c09300710ff80a217744fe 100644 (file)
--- a/m4/cc.m4
+++ b/m4/cc.m4
@@ -40,3 +40,30 @@ if test "$ac_compiler_gnu" = yes; then
   fi
 fi
 ])
+
+
+dnl Checks whether the stack can be marked nonexecutable by passing an option
+dnl to the C-compiler when acting on .s files. Appends that option to ASFLAGS.
+dnl This macro is adapted from one found in GLIBC-2.3.5.
+AC_DEFUN([CL_AS_NOEXECSTACK],[
+AC_REQUIRE([AC_PROG_CC])
+AC_CACHE_CHECK([whether --noexecstack is desirable for .s files], cl_cv_as_noexecstack, [dnl
+  cat > conftest.c <<EOF
+void foo() {}
+EOF
+  if AC_TRY_COMMAND([${CC} $CFLAGS $CPPFLAGS
+                     -S -o conftest.s conftest.c >/dev/null]) \
+     && grep -q .note.GNU-stack conftest.s \
+     && AC_TRY_COMMAND([${CC} $CFLAGS $CPPFLAGS -Wa,--noexecstack
+                       -c -o conftest.o conftest.s >/dev/null])
+  then
+    cl_cv_as_noexecstack=yes
+  else
+    cl_cv_as_noexecstack=no
+  fi
+  rm -f conftest*])
+  if test "$cl_cv_as_noexecstack" = yes; then
+    ASMFLAGS="$ASMFLAGS -Wa,--noexecstack"
+  fi
+  AC_SUBST(ASMFLAGS)
+])
index 885f27ffefe8da68f1777ca91527e4ef35f3e0d2..bb786be0c8ef387586e72aad04692563eb725a12 100644 (file)
@@ -122,7 +122,7 @@ alls : $(FILES_S) $(ASMFILES_S)
 
 allo : $(FILES_LO) $(ASMFILES_LO)
 
-ASMFLAGS :=
+ASMFLAGS := @ASMFLAGS@
 ifeq (@AS_UNDERSCORE@,true)
 ASMFLAGS += -DUNDERSCORE
 endif
@@ -185,7 +185,7 @@ $(ASMFILES_LO) : %.lo : %.s
        || COMPILER_PATH=/bin $(LIBTOOL_COMPILE) $(CC) $(CFLAGS) $(TARGET_ARCH) -c $<
 else
 $(ASMFILES_LO) : %.lo : %.s
-       $(LIBTOOL_COMPILE) $(CC) $(CFLAGS) $(TARGET_ARCH) -c $<
+       $(LIBTOOL_COMPILE) $(CC) $(CFLAGS) $(ASMFLAGS) $(TARGET_ARCH) -c $<
 endif
 
 endif