This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC PATCH 5/6] powerpc/vxworks: add {START,END}FILE_SPEC for HAVE_INITFINI_ARRAY_SUPPORT


VxWorks is a cross-compile target only, so if
HAVE_INITFINI_ARRAY_SUPPORT is defined, it is because gcc was explicitly
configured with --enable-initfini-array. So it is reasonable to expect
the user to use a linker script that implements the linker part of
this (namely, provide _ctors and _dtors symbols before the .init_array.*
and .init_array sections, and put a NULL terminator at the end).

I don't know anything about RTP (I'm targeting VxWorks 5, which doesn't
have those), so I'm avoiding touching the specs for that case.

There's nothing really ppc specific about this, but that happens to be
the target I have and can thus test on. Any other architecture should be
able to just copy the .S file and provide a similar crti.o, and then
this could be lifted to the target-agnostic vxworks.h header.

2018-06-01  Rasmus Villemoes  <rasmus.villemoes@prevas.dk>

gcc/

	* config/rs6000/vxworks.h: When --enable-initfini-array is used,
          add crtbegin.o and vxworks-crti.o to STARTFILE_SPEC and
          crtend.o to ENDFILE_SPEC.
---
 gcc/config/rs6000/vxworks.h | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/gcc/config/rs6000/vxworks.h b/gcc/config/rs6000/vxworks.h
index b10955f071d..7f0ac826e3c 100644
--- a/gcc/config/rs6000/vxworks.h
+++ b/gcc/config/rs6000/vxworks.h
@@ -90,10 +90,19 @@ VXWORKS_ADDITIONAL_CPP_SPEC
 #define LIB_SPEC VXWORKS_LIB_SPEC
 #undef  LINK_SPEC
 #define LINK_SPEC VXWORKS_LINK_SPEC
+
+#if HAVE_INITFINI_ARRAY_SUPPORT
+#define INIT_STARTFILE_SPEC "%{!mrtp:vxworks-crti.o%s crtbegin.o%s}"
+#define FINI_ENDFILE_SPEC "%{!mrtp:crtend.o%s}"
+#else
+#define INIT_STARTFILE_SPEC ""
+#define FINI_ENDFILE_SPEC ""
+#endif
+
 #undef  STARTFILE_SPEC
-#define STARTFILE_SPEC VXWORKS_STARTFILE_SPEC
+#define STARTFILE_SPEC VXWORKS_STARTFILE_SPEC INIT_STARTFILE_SPEC
 #undef  ENDFILE_SPEC
-#define ENDFILE_SPEC VXWORKS_ENDFILE_SPEC
+#define ENDFILE_SPEC VXWORKS_ENDFILE_SPEC FINI_ENDFILE_SPEC
 
 /* There is no default multilib.  */
 #undef MULTILIB_DEFAULTS
-- 
2.15.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]