summaryrefslogtreecommitdiffstats
path: root/recipes/gmp/gmp-4.2.2/02_noexec-stack.diff
blob: 613589e34782fbc676f242ab2f547b42bb2b3d7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
Index: acinclude.m4
===================================================================
RCS file: /cvsroot/pkg-gmp/gmp/acinclude.m4,v
retrieving revision 1.3
diff -u -b -B -r1.3 acinclude.m4
--- gmp-4.2.2.orig/acinclude.m4	14 Apr 2006 22:48:55 -0000	1.3
+++ gmp-4.2.2/acinclude.m4	15 Apr 2006 06:11:48 -0000
@@ -1613,6 +1613,34 @@
 ])
 
 
+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],[
+dnl AC_REQUIRE([AC_PROG_CC]) GMP uses something else
+AC_CACHE_CHECK([whether assembler supports --noexecstack option],
+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)
+])
+
+
 dnl  GMP_ASM_LABEL_SUFFIX
 dnl  --------------------
 dnl  : - is usual.
Index: configure.in
===================================================================
RCS file: /cvsroot/pkg-gmp/gmp/configure.in,v
retrieving revision 1.3
diff -u -b -B -r1.3 configure.in
--- gmp-4.2.2.orig/configure.in	14 Apr 2006 22:48:55 -0000	1.3
+++ gmp-4.2.2/configure.in	15 Apr 2006 06:11:49 -0000
@@ -2024,6 +2024,8 @@
 # Automake ansi2knr support.
 AM_C_PROTOTYPES
 
+CL_AS_NOEXECSTACK
+
 GMP_PROG_AR
 GMP_PROG_NM
 
Index: mpn/Makeasm.am
===================================================================
RCS file: /cvsroot/pkg-gmp/gmp/mpn/Makeasm.am,v
retrieving revision 1.5
diff -u -b -B -r1.5 Makeasm.am
--- gmp-4.2.2.orig/mpn/Makeasm.am	14 Apr 2006 22:48:59 -0000	1.5
+++ gmp-4.2.2/mpn/Makeasm.am		15 Apr 2006 06:11:49 -0000
@@ -24,7 +24,7 @@
 # COMPILE minus CC.
 #
 COMPILE_FLAGS = $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
-	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(ASMFLAGS)
 
 # Flags used for preprocessing (in ansi2knr rules).
 #