From 1202f33e5e1e4236fec7a3c1d14c16b5f13c2aaa Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 13 Oct 2016 10:29:03 +0200 Subject: [PATCH] re PR target/77957 (Undefined .LCTOC0 with -fstack-protector-strong -mminimal-toc -O0 on ppc64) 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 --- gcc/ChangeLog | 19 +++++++++++++++++++ gcc/ada/ChangeLog | 6 ++++++ gcc/ada/gcc-interface/misc.c | 2 +- gcc/c/ChangeLog | 6 ++++++ gcc/c/c-objc-common.h | 2 +- gcc/cfgexpand.c | 5 ++++- gcc/config/i386/i386.c | 17 +++++++++++++++++ gcc/config/rs6000/rs6000.c | 5 +++++ gcc/config/s390/s390.c | 5 +++++ gcc/config/sparc/sparc.c | 5 +++++ gcc/config/tilegx/tilegx.c | 5 +++++ gcc/config/tilepro/tilepro.c | 5 +++++ gcc/function.c | 5 ++++- gcc/hooks.c | 7 +++++++ gcc/hooks.h | 1 + gcc/langhooks-def.h | 1 - gcc/langhooks.c | 8 -------- 17 files changed, 91 insertions(+), 13 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4bc6f6c4d01..843d06ad062 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,22 @@ +2016-10-13 Jakub Jelinek + + 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 * dwarf2out.c (tree_add_const_value_attribute): Do not try diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 88090334494..f088e8be235 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2016-10-13 Jakub Jelinek + + 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 * einfo.adb, einfo.ads (Partial_Refinement_Constituents): Take diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c index 236a083d77b..cf292104651 100644 --- a/gcc/ada/gcc-interface/misc.c +++ b/gcc/ada/gcc-interface/misc.c @@ -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 diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index c5dd848a3e0..63fba12d818 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2016-10-13 Jakub Jelinek + + 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 PR c++/69733 diff --git a/gcc/c/c-objc-common.h b/gcc/c/c-objc-common.h index 14554ace114..c86e40ebd6d 100644 --- a/gcc/c/c-objc-common.h +++ b/gcc/c/c-objc-common.h @@ -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 diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index c7a2faa7200..c62e92046ff 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -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. */ diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index f6946112c6b..eef6d7b53dc 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -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 diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 1110ee260ab..c688e870604 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -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 diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c index 3bdb64871af..04d6d44bce3 100644 --- a/gcc/config/s390/s390.c +++ b/gcc/config/s390/s390.c @@ -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 diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c index f721ec299ab..ac05d96b97c 100644 --- a/gcc/config/sparc/sparc.c +++ b/gcc/config/sparc/sparc.c @@ -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 diff --git a/gcc/config/tilegx/tilegx.c b/gcc/config/tilegx/tilegx.c index d743c63bd59..0ef7559e887 100644 --- a/gcc/config/tilegx/tilegx.c +++ b/gcc/config/tilegx/tilegx.c @@ -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 diff --git a/gcc/config/tilepro/tilepro.c b/gcc/config/tilepro/tilepro.c index b39eff4b6a8..505c7a4e582 100644 --- a/gcc/config/tilepro/tilepro.c +++ b/gcc/config/tilepro/tilepro.c @@ -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 diff --git a/gcc/function.c b/gcc/function.c index 5dafb8ce35b..6f906ab0f42 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -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. */ diff --git a/gcc/hooks.c b/gcc/hooks.c index 917bb6eda6b..3995786d7c2 100644 --- a/gcc/hooks.c +++ b/gcc/hooks.c @@ -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 diff --git a/gcc/hooks.h b/gcc/hooks.h index 0cdfc81ca42..a1d67769c44 100644 --- a/gcc/hooks.h +++ b/gcc/hooks.h @@ -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); diff --git a/gcc/langhooks-def.h b/gcc/langhooks-def.h index cf5f91da125..fb6b5055f8a 100644 --- a/gcc/langhooks-def.h +++ b/gcc/langhooks-def.h @@ -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); diff --git a/gcc/langhooks.c b/gcc/langhooks.c index 69cdb944948..792eb4828e8 100644 --- a/gcc/langhooks.c +++ b/gcc/langhooks.c @@ -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)) { -- 2.30.2