re PR target/77957 (Undefined .LCTOC0 with -fstack-protector-strong -mminimal-toc...
authorJakub Jelinek <jakub@redhat.com>
Thu, 13 Oct 2016 08:29:03 +0000 (10:29 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 13 Oct 2016 08:29:03 +0000 (10:29 +0200)
PR target/77957
* hooks.h (hook_tree_void_null): Declare.
* hooks.c (hook_tree_void_null): New function.
* langhooks.c (lhd_return_null_tree_v): Remove.
* langhooks-def.h (lhd_return_null_tree_v): Remove.
* cfgexpand.c (stack_protect_prologue): If guard_decl is NULL,
set y to const0_rtx.
* function.c (stack_protect_epilogue): Likewise.
* config/tilepro/tilepro.c (TARGET_STACK_PROTECT_GUARD): Redefine
if TARGET_THREAD_SSP_OFFSET is defined.
* config/s390/s390.c (TARGET_STACK_PROTECT_GUARD): Likewise.
* config/sparc/sparc.c (TARGET_STACK_PROTECT_GUARD): Likewise.
* config/tilegx/tilegx.c (TARGET_STACK_PROTECT_GUARD): Likewise.
* config/rs6000/rs6000.c (TARGET_STACK_PROTECT_GUARD): Likewise.
* config/i386/i386.c (TARGET_STACK_PROTECT_GUARD): Likewise.
(ix86_stack_protect_guard): New function.
c/
* c-objc-common.h (LANG_HOOKS_GETDECLS): Use hook_tree_void_null
instead of lhd_return_null_tree_v.
ada/
* gcc-interface/misc.c (LANG_HOOKS_GETDECLS): Use hook_tree_void_null
instead of lhd_return_null_tree_v.

From-SVN: r241087

17 files changed:
gcc/ChangeLog
gcc/ada/ChangeLog
gcc/ada/gcc-interface/misc.c
gcc/c/ChangeLog
gcc/c/c-objc-common.h
gcc/cfgexpand.c
gcc/config/i386/i386.c
gcc/config/rs6000/rs6000.c
gcc/config/s390/s390.c
gcc/config/sparc/sparc.c
gcc/config/tilegx/tilegx.c
gcc/config/tilepro/tilepro.c
gcc/function.c
gcc/hooks.c
gcc/hooks.h
gcc/langhooks-def.h
gcc/langhooks.c

index 4bc6f6c4d01740ebf900fb5c9d2fd284453ccfe8..843d06ad06234de5f3d95674eb9efa08127e8fac 100644 (file)
@@ -1,3 +1,22 @@
+2016-10-13  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/77957
+       * hooks.h (hook_tree_void_null): Declare.
+       * hooks.c (hook_tree_void_null): New function.
+       * langhooks.c (lhd_return_null_tree_v): Remove.
+       * langhooks-def.h (lhd_return_null_tree_v): Remove.
+       * cfgexpand.c (stack_protect_prologue): If guard_decl is NULL,
+       set y to const0_rtx.
+       * function.c (stack_protect_epilogue): Likewise.
+       * config/tilepro/tilepro.c (TARGET_STACK_PROTECT_GUARD): Redefine
+       if TARGET_THREAD_SSP_OFFSET is defined.
+       * config/s390/s390.c (TARGET_STACK_PROTECT_GUARD): Likewise.
+       * config/sparc/sparc.c (TARGET_STACK_PROTECT_GUARD): Likewise.
+       * config/tilegx/tilegx.c (TARGET_STACK_PROTECT_GUARD): Likewise.
+       * config/rs6000/rs6000.c (TARGET_STACK_PROTECT_GUARD): Likewise.
+       * config/i386/i386.c (TARGET_STACK_PROTECT_GUARD): Likewise.
+       (ix86_stack_protect_guard): New function.
+
 2016-10-13  Richard Biener  <rguenther@suse.de>
 
        * dwarf2out.c (tree_add_const_value_attribute): Do not try
index 88090334494b9c93997521fdf9d80e067bad83b6..f088e8be235ba29960a31008d1c8124e0b2324f6 100644 (file)
@@ -1,3 +1,9 @@
+2016-10-13  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/77957
+       * gcc-interface/misc.c (LANG_HOOKS_GETDECLS): Use hook_tree_void_null
+       instead of lhd_return_null_tree_v.
+
 2016-10-12  Yannick Moy  <moy@adacore.com>
 
        * einfo.adb, einfo.ads (Partial_Refinement_Constituents): Take
index 236a083d77b7fa5b7f43ce033d210873d4ce052d..cf2921046513b8d67fc54e5476f03a4d0de1cff4 100644 (file)
@@ -1366,7 +1366,7 @@ get_lang_specific (tree node)
 #undef  LANG_HOOKS_TYPE_HASH_EQ
 #define LANG_HOOKS_TYPE_HASH_EQ                gnat_type_hash_eq
 #undef  LANG_HOOKS_GETDECLS
-#define LANG_HOOKS_GETDECLS            lhd_return_null_tree_v
+#define LANG_HOOKS_GETDECLS            hook_tree_void_null
 #undef  LANG_HOOKS_PUSHDECL
 #define LANG_HOOKS_PUSHDECL            gnat_return_tree
 #undef  LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL
index c5dd848a3e0a006bd08de4204e7edb0e2f81385a..63fba12d818b6cbaf8ae7792bd82d3fe31fb5313 100644 (file)
@@ -1,3 +1,9 @@
+2016-10-13  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/77957
+       * c-objc-common.h (LANG_HOOKS_GETDECLS): Use hook_tree_void_null
+       instead of lhd_return_null_tree_v.
+
 2016-10-07  Bernd Schmidt  <bschmidt@redhat.com>
 
        PR c++/69733
index 14554ace114a916c66f5fadfd7a04df770d2ad98..c86e40ebd6dc7a896470a73cf476ac7d631db352 100644 (file)
@@ -91,7 +91,7 @@ along with GCC; see the file COPYING3.  If not see
    This means it must also provide its own write_globals.  */
 
 #undef LANG_HOOKS_GETDECLS
-#define LANG_HOOKS_GETDECLS lhd_return_null_tree_v
+#define LANG_HOOKS_GETDECLS hook_tree_void_null
 
 /* Hooks for tree gimplification.  */
 #undef LANG_HOOKS_GIMPLIFY_EXPR
index c7a2faa72006908221d1094c4d71f57e084bf147..c62e92046ff5a4f4bd7c19169fccfad8cbf1bdfd 100644 (file)
@@ -6100,7 +6100,10 @@ stack_protect_prologue (void)
   rtx x, y;
 
   x = expand_normal (crtl->stack_protect_guard);
-  y = expand_normal (guard_decl);
+  if (guard_decl)
+    y = expand_normal (guard_decl);
+  else
+    y = const0_rtx;
 
   /* Allow the target to copy from Y to X without leaking Y into a
      register.  */
index f6946112c6b34189fdbec012e00e4df6704b8a48..eef6d7b53dc3c1d6c54864f18b37e129c931d8b7 100644 (file)
@@ -44023,6 +44023,18 @@ ix86_mangle_type (const_tree type)
     }
 }
 
+#ifdef TARGET_THREAD_SSP_OFFSET
+/* If using TLS guards, don't waste time creating and expanding
+   __stack_chk_guard decl and MEM as we are going to ignore it.  */
+static tree
+ix86_stack_protect_guard (void)
+{
+  if (TARGET_SSP_TLS_GUARD)
+    return NULL_TREE;
+  return default_stack_protect_guard ();
+}
+#endif
+
 /* For 32-bit code we can save PIC register setup by using
    __stack_chk_fail_local hidden function instead of calling
    __stack_chk_fail directly.  64-bit code doesn't need to setup any PIC
@@ -50614,6 +50626,11 @@ ix86_addr_space_zero_address_valid (addr_space_t as)
 #undef TARGET_MANGLE_TYPE
 #define TARGET_MANGLE_TYPE ix86_mangle_type
 
+#ifdef TARGET_THREAD_SSP_OFFSET
+#undef TARGET_STACK_PROTECT_GUARD
+#define TARGET_STACK_PROTECT_GUARD ix86_stack_protect_guard
+#endif
+
 #if !TARGET_MACHO
 #undef TARGET_STACK_PROTECT_FAIL
 #define TARGET_STACK_PROTECT_FAIL ix86_stack_protect_fail
index 1110ee260ab8a60c24a2a3eb71348d29c8c68353..c688e8706041523e0c52e10ab09572173c90edad 100644 (file)
@@ -1752,6 +1752,11 @@ 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
+
 #if !TARGET_MACHO
 #undef TARGET_STACK_PROTECT_FAIL
 #define TARGET_STACK_PROTECT_FAIL rs6000_stack_protect_fail
index 3bdb64871af9ed2756360e48543171261fd97496..04d6d44bce352386b8c6dd9e34ddeae4a3a3924a 100644 (file)
@@ -15124,6 +15124,11 @@ s390_invalid_binary_op (int op ATTRIBUTE_UNUSED, const_tree type1, const_tree ty
 #undef TARGET_OPTION_OVERRIDE
 #define TARGET_OPTION_OVERRIDE s390_option_override
 
+#ifdef TARGET_THREAD_SSP_OFFSET
+#undef TARGET_STACK_PROTECT_GUARD
+#define TARGET_STACK_PROTECT_GUARD hook_tree_void_null
+#endif
+
 #undef TARGET_ENCODE_SECTION_INFO
 #define TARGET_ENCODE_SECTION_INFO s390_encode_section_info
 
index f721ec299ab5c71ac3196eb79fbf29409eaf1eb5..ac05d96b97c6da9e05f341f2b86d5e0cad2fc834 100644 (file)
@@ -798,6 +798,11 @@ char sparc_hard_reg_printed[8];
 #undef TARGET_OPTION_OVERRIDE
 #define TARGET_OPTION_OVERRIDE sparc_option_override
 
+#ifdef TARGET_THREAD_SSP_OFFSET
+#undef TARGET_STACK_PROTECT_GUARD
+#define TARGET_STACK_PROTECT_GUARD hook_tree_void_null
+#endif
+
 #if TARGET_GNU_TLS && defined(HAVE_AS_SPARC_UA_PCREL)
 #undef TARGET_ASM_OUTPUT_DWARF_DTPREL
 #define TARGET_ASM_OUTPUT_DWARF_DTPREL sparc_output_dwarf_dtprel
index d743c63bd592c191c9ffc74f27deafb7d950fbbb..0ef7559e88750034eab6570dac85612dc19504be 100644 (file)
@@ -5544,6 +5544,11 @@ tilegx_file_end (void)
 #undef  TARGET_OPTION_OVERRIDE
 #define TARGET_OPTION_OVERRIDE tilegx_option_override
 
+#ifdef TARGET_THREAD_SSP_OFFSET
+#undef TARGET_STACK_PROTECT_GUARD
+#define TARGET_STACK_PROTECT_GUARD hook_tree_void_null
+#endif
+
 #undef  TARGET_SCALAR_MODE_SUPPORTED_P
 #define TARGET_SCALAR_MODE_SUPPORTED_P tilegx_scalar_mode_supported_p
 
index b39eff4b6a80d2aa65ac855b0fc12c257237184c..505c7a4e5827b08b4f43603ed58a4775106a6bfb 100644 (file)
@@ -4948,6 +4948,11 @@ tilepro_file_end (void)
 #undef  TARGET_OPTION_OVERRIDE
 #define TARGET_OPTION_OVERRIDE tilepro_option_override
 
+#ifdef TARGET_THREAD_SSP_OFFSET
+#undef TARGET_STACK_PROTECT_GUARD
+#define TARGET_STACK_PROTECT_GUARD hook_tree_void_null
+#endif
+
 #undef  TARGET_SCALAR_MODE_SUPPORTED_P
 #define TARGET_SCALAR_MODE_SUPPORTED_P tilepro_scalar_mode_supported_p
 
index 5dafb8ce35ba1a59fbc097de00541ad0364365d1..6f906ab0f42a97385bf598bdc112a3b3859df527 100644 (file)
@@ -5058,7 +5058,10 @@ stack_protect_epilogue (void)
   rtx_insn *seq;
 
   x = expand_normal (crtl->stack_protect_guard);
-  y = expand_normal (guard_decl);
+  if (guard_decl)
+    y = expand_normal (guard_decl);
+  else
+    y = const0_rtx;
 
   /* Allow the target to compare Y with X without leaking either into
      a register.  */
index 917bb6eda6b7fdb6d1ea5ba62785d93f071629b9..3995786d7c2a5ac09f1dfdb07f6d4e89f7d9d74d 100644 (file)
@@ -429,6 +429,13 @@ hook_tree_const_tree_null (const_tree)
   return NULL;
 }
 
+/* Generic hook that takes no arguments and returns a NULL_TREE.  */
+tree
+hook_tree_void_null (void)
+{
+  return NULL;
+}
+
 /* Generic hook that takes a rtx_insn * and an int and returns a bool.  */
 
 bool
index 0cdfc81ca42e4aa713c518b556eee18334bdb568..a1d67769c44b779e5962b77c96f982c8e252080f 100644 (file)
@@ -89,6 +89,7 @@ extern int hook_int_rtx_mode_as_bool_0 (rtx, machine_mode, addr_space_t,
                                        bool);
 
 extern tree hook_tree_const_tree_null (const_tree);
+extern tree hook_tree_void_null (void);
 
 extern tree hook_tree_tree_tree_null (tree, tree);
 extern tree hook_tree_tree_tree_tree_null (tree, tree, tree);
index cf5f91da1252873580df2d5dc67a7caad2f56b46..fb6b5055f8ab3dc3633de10b2e0816e88ece3f35 100644 (file)
@@ -41,7 +41,6 @@ extern void lhd_do_nothing_f (struct function *);
 extern tree lhd_pass_through_t (tree);
 extern bool lhd_post_options (const char **);
 extern alias_set_type lhd_get_alias_set (tree);
-extern tree lhd_return_null_tree_v (void);
 extern tree lhd_return_null_tree (tree);
 extern tree lhd_return_null_const_tree (const_tree);
 extern tree lhd_do_nothing_iii_return_null_tree (int, int, int);
index 69cdb944948b466fca9b5f275168de5fcdc1c8c6..792eb4828e8816091b4cd4069dc3cbe6e3fe0018 100644 (file)
@@ -76,14 +76,6 @@ lhd_do_nothing_f (struct function * ARG_UNUSED (f))
 
 /* Do nothing (return NULL_TREE).  */
 
-tree
-lhd_return_null_tree_v (void)
-{
-  return NULL_TREE;
-}
-
-/* Do nothing (return NULL_TREE).  */
-
 tree
 lhd_return_null_tree (tree ARG_UNUSED (t))
 {