#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
set f [open $src "w"]
puts $f "#include \"../../auto-host.h\""
- puts $f "#if HAVE_GAS_SHF_GNU_RETAIN == 0"
+ puts $f "#if HAVE_GAS_SHF_GNU_RETAIN == 0 || HAVE_INITFINI_ARRAY_SUPPORT == 0"
puts $f "# error Assembler does not support 'R' flag in .section directive."
puts $f "#endif"
close $f
slot = section_htab->find_slot_with_hash (name, htab_hash_string (name),
INSERT);
flags |= SECTION_NAMED;
- if (HAVE_GAS_SHF_GNU_RETAIN
+ if (SUPPORTS_SHF_GNU_RETAIN
&& decl != nullptr
&& DECL_P (decl)
&& DECL_PRESERVE_P (decl))
if (DECL_SECTION_NAME (decl) == NULL
&& targetm_common.have_named_sections
&& (flag_function_or_data_sections
- || (HAVE_GAS_SHF_GNU_RETAIN && DECL_PRESERVE_P (decl))
+ || (SUPPORTS_SHF_GNU_RETAIN && DECL_PRESERVE_P (decl))
|| DECL_COMDAT_GROUP (decl)))
{
targetm.asm_out.unique_section (decl, reloc);
vnode->get_constructor ();
if (DECL_COMMON (decl)
- && !(HAVE_GAS_SHF_GNU_RETAIN && DECL_PRESERVE_P (decl)))
+ && !(SUPPORTS_SHF_GNU_RETAIN && DECL_PRESERVE_P (decl)))
{
/* If the decl has been given an explicit section name, or it resides
in a non-generic address space, then it isn't common, and shouldn't
{
if (in_section == new_section)
{
- if (HAVE_GAS_SHF_GNU_RETAIN
+ if (SUPPORTS_SHF_GNU_RETAIN
&& (new_section->common.flags & SECTION_NAMED)
&& decl != nullptr
&& DECL_P (decl)