the default CPP spec for C++ as well. */
#undef CPLUSPLUS_CPP_SPEC
-/* For VxWorks static rtps, the system provides libc_internal.a, a superset of
- libgcc.a that we need to use e.g. to satisfy references to __init and
- __fini. We still want our libgcc to prevail for symbols it would provide
- (e.g. register save entry points), so re-place it here between libraries
- that might reference it and libc_internal.
+/* For VxWorks static rtps, the system provides libc_internal.a for a variety
+ of purposes. Care is needed to include it appropriately.
+
+ - In some configurations, libc_internal fills in possible references from
+ the static libc that we don't wouldn't satisfy ourselves, say, with
+ libgcc. An example is the __aeabi_memcpy family of functions on arm,
+ which have very specific ABI allowances.
+
+ - OTOH, in some configurations the library provides typical libgcc
+ services, for example register save/restore entry points on powerpc. We
+ want our libgcc to prevail for symbols it would provide, so place
+ -lc_internal after -lc -lgcc.
+
+ - libc_internal also contains __init/__fini functions for
+ USE_INITFINI_ARRAY support. However, the system expects these in
+ every shared lib as well, with slightly different names, and it is
+ simpler for us to provide our own versions through vxcrtstuff.
In addition, some versions of VxWorks rely on explicit extra libraries for
system calls and the set of base network libraries of common use varies
#define VXWORKS_NET_LIBS_RTP "-lnet -ldsi"
#endif
-#define VXWORKS_BASE_LIBS_RTP "-lc -lgcc -lc_internal"
+#define VXWORKS_BASE_LIBS_RTP \
+ "-lc -lgcc %{!shared:%{!non-static:-lc_internal}}"
#define VXWORKS_EXTRA_LIBS_RTP
#endif
#undef VXWORKS_LIB_SPEC
-#define VXWORKS_LIB_SPEC \
-"%{mrtp:%{shared:-u " USER_LABEL_PREFIX "__init -u " USER_LABEL_PREFIX "__fini} \
- %{!shared:%{non-static:-u " USER_LABEL_PREFIX "_STI__6__rtld -ldl} \
- " TLS_SYM " \
+#define VXWORKS_LIB_SPEC \
+"%{mrtp:%{!shared:%{non-static:-u " USER_LABEL_PREFIX "_STI__6__rtld -ldl} \
+ " TLS_SYM " \
--start-group " VXWORKS_LIBS_RTP " --end-group}}"
/* The no-op spec for "-shared" below is present because otherwise GCC
#define VXWORKS_LIBGCC_SPEC "-lgcc"
#endif
-/* Setup the crtstuff begin/end we might need for dwarf EH registration. */
+/* Setup the crtstuff begin/end we might need for dwarf EH registration
+ and/or INITFINI_ARRAY support for shared libs. */
-#if !defined(CONFIG_SJLJ_EXCEPTIONS) && DWARF2_UNWIND_INFO
-#define VX_CRTBEGIN_SPEC "vx_crtbegin.o%s"
-#define VX_CRTEND_SPEC "-l:vx_crtend.o"
+#if (HAVE_INITFINI_ARRAY_SUPPORT && defined(ENABLE_SHARED_LIBGCC)) \
+ || (DWARF2_UNWIND_INFO && !defined(CONFIG_SJLJ_EXCEPTIONS))
+#define VX_CRTBEGIN_SPEC "%{!shared:vx_crtbegin.o%s;:vx_crtbeginS.o%s}"
+#define VX_CRTEND_SPEC "%{!shared:vx_crtend.o%s;:vx_crtendS.o%s}"
#else
#define VX_CRTBEGIN_SPEC ""
#define VX_CRTEND_SPEC ""
#define USE_CDTORS_SECTIONS
#endif
+#if DWARF2_UNWIND_INFO && !defined(__USING_SJLJ_EXCEPTIONS__)
+#define USE_EH_FRAME_REGISTRY
+#endif
+
/* ------------------------------ crtbegin ------------------------------- */
#ifdef CRT_BEGIN
-/* Stick a label at the beginning of the frame unwind info so we can register
- and deregister it with the exception handling library code. */
-static const char __EH_FRAME_BEGIN__[]
-__attribute__((section(__LIBGCC_EH_FRAME_SECTION_NAME__), aligned(4)))
- = { };
+#if DEFAULT_USE_CXA_ATEXIT && defined(__RTP__)
+/* This mimics the crtstuff.c behavior. dso_handle should be NULL for the
+ main program (in vx_crtbegin.o) and a unique value for the shared libraries
+ (in vx_crtbeginS.o). */
+extern void *__dso_handle __attribute__ ((__visibility__ ("hidden")));
+#ifdef CRTSTUFFS_O
+void *__dso_handle = &__dso_handle;
+#else
+void *__dso_handle = 0;
+#endif
+#endif /* DEFAULT_USE_CXA_ATEXIT */
/* Determine what names to use for the constructor/destructor functions. */
#define EH_CTOR_ATTRIBUTE __attribute__((constructor (101)))
#define EH_DTOR_ATTRIBUTE __attribute__((destructor (101)))
+/* Provide the init/fini array support functions for shared libraries,
+ where we don't want to drag libc_internal contents blindly and which
+ provides functions with a slightly different name anyway. */
+
+#if HAVE_INITFINI_ARRAY_SUPPORT && defined(CRTSTUFFS_O)
+
+/* Run through the .init_array, .fini_array sections. The linker script
+ *must* provide __init_array_start, __init_array_end, __fini_array_start,
+ __fini_array_end symbols. */
+
+typedef void (*initfini_ptr) (void);
+extern initfini_ptr __init_array_start[];
+extern initfini_ptr __init_array_end[];
+extern initfini_ptr __fini_array_start[];
+extern initfini_ptr __fini_array_end[];
+
+/* Provide the actual code through static functions, which don't need
+ to be exposed in the shared lib interface. */
+
+static void __exec_init_array(void)
+{
+ initfini_ptr *fn;
+ for (fn = __init_array_start; fn < __init_array_end; ++fn)
+ (*fn)();
+}
+
+static void __exec_fini_array(void)
+{
+ initfini_ptr *fn;
+ for (fn = __fini_array_end - 1; fn >= __fini_array_start; --fn)
+ (*fn)();
+}
+
+/* Reference the two above functions as the init / fini function. */
+
+void __attribute__ ((__section__ (".init"))) _init()
+{
+ __exec_init_array();
+}
+
+void __attribute__ ((__section__ (".fini"))) _fini()
+{
+ __exec_fini_array();
+}
+
+#endif /* __CRTSTUFFS_O__ */
+
#else /* !USE_INITFINI_ARRAY */
/* Note: Even in case of .ctors/.dtors sections, we can't use the attribute
#endif /* USE_INITFINI_ARRAY */
+#ifdef USE_EH_FRAME_REGISTRY
+/* Stick a label at the beginning of the frame unwind info so we can register
+ and deregister it with the exception handling library code. */
+static const char __EH_FRAME_BEGIN__[]
+__attribute__((section(__LIBGCC_EH_FRAME_SECTION_NAME__), aligned(4)))
+ = { };
+
EH_LINKAGE EH_CTOR_ATTRIBUTE void EH_CTOR_NAME (void)
{
static struct object object;
{
__deregister_frame_info (__EH_FRAME_BEGIN__);
}
+#endif /* USE_EH_FRAME_REGISTRY */
#ifdef USE_CDTORS_SECTIONS
/* As explained above, we need to manually build the sections here as the
#elif defined (CRT_END) /* ! CRT_BEGIN */
+#ifdef USE_EH_FRAME_REGISTRY
/* Terminate the frame unwind info section with a 4byte 0 as a sentinel;
this would be the 'length' field in a real FDE. */
__attribute__ ((used, section(__LIBGCC_EH_FRAME_SECTION_NAME__),
aligned(4)))
= { 0, 0, 0, 0 };
+#endif /* USE_EH_FRAME_REGISTRY */
#else /* ! CRT_BEGIN & ! CRT_END */