The target OS actually runs all function pointers found in the _ctors
array when the module is loaded. So it is not that hard to make use of
the "modern" .init_array/.fini_array mechanism - it mostly just requires
a linker script adding the _ctors and _dtors symbols and terminating
LONG(0) entries.
Assume that if the user passed --enable-initfini-array when building
gcc, the rest of the toolchain (including the link spec and linker
script) is set up appropriately.
Note that configuring with --enable-initfini-array may prevent the -mrtp
mode from working, due to the (unconditional) use of .init_array.*
sections instead of .ctors.* - however, that is the case regardless of this
patch.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@263691
138bc75d-0d04-0410-961f-
82ee72b054a4
+2018-08-21 Rasmus Villemoes <rv@rasmusvillemoes.dk>
+
+ * config/vxworks.c: Set targetm.have_ctors_dtors
+ if HAVE_INITFINI_ARRAY_SUPPORT.
+ * config/vxworks.h: Set SUPPORTS_INIT_PRIORITY
+ if HAVE_INITFINI_ARRAY_SUPPORT.
+
2018-08-21 Rasmus Villemoes <rv@rasmusvillemoes.dk>
* config/vxworks.h: Add $(WIND_BASE)/target/h/wrn/coreip to
targetm.emutls.debug_form_tls_address = true;
}
- /* We can use .ctors/.dtors sections only in RTP mode. */
- targetm.have_ctors_dtors = TARGET_VXWORKS_RTP;
+ /* We can use .ctors/.dtors sections only in RTP mode. But, if the
+ compiler was built with --enable-initfini-array, assume the
+ toolchain implements the proper glue to make .init_array and
+ .fini_array work. */
+ targetm.have_ctors_dtors = TARGET_VXWORKS_RTP || HAVE_INITFINI_ARRAY_SUPPORT;
/* PIC is only supported for RTPs. */
if (flag_pic && !TARGET_VXWORKS_RTP)
#define VXWORKS_OVERRIDE_OPTIONS vxworks_override_options ()
extern void vxworks_override_options (void);
-/* Only RTPs support prioritized constructors and destructors:
- the implementation relies on numbered .ctors* sections. */
-#define SUPPORTS_INIT_PRIORITY TARGET_VXWORKS_RTP
+/* RTPs support prioritized constructors and destructors: the
+ implementation relies on numbered .ctors* sections. If the compiler
+ was built with --enable-initfini-array, we assume the user uses a
+ linker script that sorts and merges the .init_array.* sections
+ appropriately. */
+#define SUPPORTS_INIT_PRIORITY \
+ (TARGET_VXWORKS_RTP || HAVE_INITFINI_ARRAY_SUPPORT)
/* VxWorks requires special handling of constructors and destructors.
All VxWorks configurations must use these functions. */