aboutsummaryrefslogtreecommitdiff
blob: 4b7b4ae77dee9cffc4407e19a4a9ee2475889d6b (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
2012-02-11	Magnus Granberg	<zorry@gentoo.org>

		PR52194
		* gcc/c-pch.c	(c_common_valid_pch)	check for
		Pax and RANDMMAP.

--- a/gcc/c-pch.c		2011-08-28 22:14:46.000000000 +0200
+++ b/gcc/c-pch.c	2012-02-11 17:10:23.158018580 +0100
@@ -36,6 +36,10 @@ along with GCC; see the file COPYING3.
 #include "opts.h"
 #include "timevar.h"
 
+#define FILE_BUFFER 256
+#define LINE_BUFFER 1024
+#define WORD_BUFFER 1024
+
 /* This is a list of flag variables that must match exactly, and their
    names for the error message.  The possible values for *flag_var must
    fit in a 'signed char'.  */
@@ -240,6 +244,11 @@ c_common_valid_pch (cpp_reader *pfile, c
   char ident[IDENT_LENGTH + 16];
   const char *pch_ident;
   struct c_pch_validity v;
+  FILE *f;
+  char file[FILE_BUFFER];
+  char line[LINE_BUFFER];
+  char word[WORD_BUFFER];
+  char value[WORD_BUFFER];
 
   /* Perform a quick test of whether this is a valid
      precompiled header for the current language.  */
@@ -351,6 +360,29 @@ c_common_valid_pch (cpp_reader *pfile, c
       }
   }
 
+  /* FIXME: On PaX enabled kernel with RANDMMAP enabled we can't use
+     PCH.  #PR52194  */
+
+  f = fopen ("/proc/self/status", "r");
+  if (f != NULL)
+    {
+	memset(file, 0, FILE_BUFFER);
+	while( fgets(line, LINE_BUFFER, f) )
+	  {
+	    sscanf(line, "%s %s", word, value);  
+	    if(!strcmp(word, "PaX:"))
+	      {
+		if(value[3] == 'R')
+		  {
+		    cpp_error (pfile, CPP_DL_WARNING, "%s can't be used \
+				     with PaX enabled kernel with RANDMMAP \
+				     enabled.", name);
+		    return 2;
+		  }
+	      }
+	  }
+    }
+  
   /* Check the preprocessor macros are the same as when the PCH was
      generated.  */