2012-02-11 Magnus Granberg 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. */