From 126552d49e6cba09ef5a504ee3fcdfec00d8743b Mon Sep 17 00:00:00 2001 From: Richard Kreckel Date: Mon, 15 Aug 2005 21:19:16 +0000 Subject: [PATCH] * m4/cc.m4 (CL_AS_NOEXECSTACK): New macro... * configure.ac: ...used here for setting ASMFLAGS... * src/Makefile.in: ...which are used here. --- ChangeLog | 6 ++++++ configure.ac | 2 ++ m4/cc.m4 | 27 +++++++++++++++++++++++++++ src/Makefile.in | 4 ++-- 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 299a542..1d33bd0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-08-15 Richard B. Kreckel + + * 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 * include/cln/config.h.in: Add support for PowerPC 64 CPU. diff --git a/configure.ac b/configure.ac index bd77b6d..6020485 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/m4/cc.m4 b/m4/cc.m4 index 9a8326c..ec6c5e8 100644 --- 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 </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) +]) diff --git a/src/Makefile.in b/src/Makefile.in index 885f27f..bb786be 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -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