aboutsummaryrefslogtreecommitdiff
path: root/gcc/defaults.h
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2020-12-14 20:10:13 -0800
committerH.J. Lu <hjl.tools@gmail.com>2020-12-16 05:42:08 -0800
commit151d1347c99acfcf0f5bcd8caac36dcc7353816d (patch)
tree34f662e0f712743b0d1c70f1378193d3b0930573 /gcc/defaults.h
parent2a976020603589e897fcfa3276590ef50b489d34 (diff)
downloadgcc-151d1347c99acfcf0f5bcd8caac36dcc7353816d.zip
gcc-151d1347c99acfcf0f5bcd8caac36dcc7353816d.tar.gz
gcc-151d1347c99acfcf0f5bcd8caac36dcc7353816d.tar.bz2
Require .init_array/.fini_array support for SHF_GNU_RETAIN
Since SHF_GNU_RETAIN support doesn't work for crtstuff.c which switches the output section directly with asm statement: --- static void __attribute__((used)) __do_global_dtors_aux (void) { static _Bool completed; if (__builtin_expect (completed, 0)) return; completed = 1; } static void __attribute__((__used__)) call___do_global_dtors_aux (void) { asm ("\t.section\t.fini"); __do_global_dtors_aux (); asm ("\t.section\t.text"); } --- use SHF_GNU_RETAIN only if .init_array/.fini_array section is supported. gcc/ PR target/98146 * defaults.h (SUPPORTS_SHF_GNU_RETAIN): New. * varasm.c (get_section): Replace HAVE_GAS_SHF_GNU_RETAIN with SUPPORTS_SHF_GNU_RETAIN. (resolve_unique_section): Likewise. (get_variable_section): Likewise. (switch_to_section): Likewise. gcc/testsuite/ PR target/98146 * lib/target-supports.exp (check_effective_target_R_flag_in_section): Also check HAVE_INITFINI_ARRAY_SUPPORT != 0.
Diffstat (limited to 'gcc/defaults.h')
-rw-r--r--gcc/defaults.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/gcc/defaults.h b/gcc/defaults.h
index f1a3862..80a84dd 100644
--- a/gcc/defaults.h
+++ b/gcc/defaults.h
@@ -286,6 +286,17 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#endif
#endif
+/* This determines whether or not we support marking sections with
+ SHF_GNU_RETAIN flag. Also require .init_array/.fini_array section
+ for constructors and destructors. */
+#ifndef SUPPORTS_SHF_GNU_RETAIN
+#if HAVE_GAS_SHF_GNU_RETAIN && HAVE_INITFINI_ARRAY_SUPPORT
+#define SUPPORTS_SHF_GNU_RETAIN 1
+#else
+#define SUPPORTS_SHF_GNU_RETAIN 0
+#endif
+#endif
+
/* This determines whether or not we support link-once semantics. */
#ifndef SUPPORTS_ONE_ONLY
#ifdef MAKE_DECL_ONE_ONLY