rs6000: Fix the new SSP guard configuration code (PR79140)
authorSegher Boessenkool <segher@kernel.crashing.org>
Fri, 20 Jan 2017 01:22:27 +0000 (02:22 +0100)
committerSegher Boessenkool <segher@gcc.gnu.org>
Fri, 20 Jan 2017 01:22:27 +0000 (02:22 +0100)
I foolishly tested this with r241087 reverted.  After that revision
default_stack_protect_guard is no longer called if the compiler defaults
to using the TLS guard, which of course is the wrong thing to do if
there is some other way to enable the global guard.

This fixes it.

PR target/78875
PR target/79140
* config/rs6000/rs6000.c (TARGET_STACK_PROTECT_GUARD): Unconditionally
define to rs6000_init_stack_protect_guard.
(rs6000_init_stack_protect_guard): New function.

From-SVN: r244677

gcc/ChangeLog
gcc/config/rs6000/rs6000.c

index c52f0247556264024f32247d7b2ee12773b0571f..470608638d235b70ba6a36743fc151e622ad356e 100644 (file)
@@ -1,3 +1,11 @@
+2017-01-19  Segher Boessenkool  <segher@kernel.crashing.org>
+
+       PR target/78875
+       PR target/79140
+       * config/rs6000/rs6000.c (TARGET_STACK_PROTECT_GUARD): Unconditionally
+       define to rs6000_init_stack_protect_guard.
+       (rs6000_init_stack_protect_guard): New function.
+
 2017-01-19  Matthew Fortune  <matthew.fortune@imgtec.com>
            Yunqiang Su  <yunqiang.su@imgtec.com>
 
index 4c6badaaa2b1358c85c770e3e4a8c274af2f3779..be7e94770b5117053c030b75dc74cbef57b21422 100644 (file)
@@ -1758,10 +1758,8 @@ static const struct attribute_spec rs6000_attribute_table[] =
 #define TARGET_VECTORIZE_BUILTIN_MD_VECTORIZED_FUNCTION \
   rs6000_builtin_md_vectorized_function
 
-#ifdef TARGET_THREAD_SSP_OFFSET
 #undef TARGET_STACK_PROTECT_GUARD
-#define TARGET_STACK_PROTECT_GUARD hook_tree_void_null
-#endif
+#define TARGET_STACK_PROTECT_GUARD rs6000_init_stack_protect_guard
 
 #if !TARGET_MACHO
 #undef TARGET_STACK_PROTECT_FAIL
@@ -9479,6 +9477,17 @@ rs6000_legitimize_tls_address (rtx addr, enum tls_model model)
   return dest;
 }
 
+/* Only create the global variable for the stack protect guard if we are using
+   the global flavor of that guard.  */
+static tree
+rs6000_init_stack_protect_guard (void)
+{
+  if (rs6000_stack_protector_guard == SSP_GLOBAL)
+    return default_stack_protect_guard ();
+
+  return NULL_TREE;
+}
+
 /* Implement TARGET_CANNOT_FORCE_CONST_MEM.  */
 
 static bool