diff options
author | Frederic Konrad <konrad@adacore.com> | 2020-11-05 11:34:57 +0100 |
---|---|---|
committer | Olivier Hainque <hainque@adacore.com> | 2021-12-13 18:03:03 +0000 |
commit | 4099d6501e3526ca8d1d01e904f42b83c6824674 (patch) | |
tree | de1958f3de2156933e67882c59efcbc38d2ec928 /gcc | |
parent | 0515c95d5fe0a865f688f3ab89572b917e8f0185 (diff) | |
download | gcc-4099d6501e3526ca8d1d01e904f42b83c6824674.zip gcc-4099d6501e3526ca8d1d01e904f42b83c6824674.tar.gz gcc-4099d6501e3526ca8d1d01e904f42b83c6824674.tar.bz2 |
Tigthen libc_internal and crtstuff for VxWorks shared objects
This change tightens and documents the use of libc_internal, then
strengthens the VxWorks crtstuff objects for the support of shared
libraries. In particular:
- Define __dso_handle, which libstdc++.so requires,
- Provide _init and _fini functions to run through the init/fini arrays
for shared libs in configurations which HAVE_INITFINI_ARRAY_SUPPORT.
The init/fini functions are provided by libc_internal.a for static links
but with slightly different names and we don't want to risk dragging other
libc_internal contents in the closure accidentally so make sure we don't
link with it.
As for the !vxworks crtstuff, the new shared libs specific bits are
conditioned by a CRTSTUFFS_O macro, for which we provide new Makefile
fragment.
The bits to actually use the fragment and the shared objects will
be added by a forthcoming change, as part of a more general configury
update for shared libs.
The change also adds guards the eh table registration code
in vxcrtstuff so the objects can be used for either init/fini
or eh tables independently.
2021-12-07 Fred Konrad <konrad@adacore.com>
Olivier Hainque <hainque@adacore.com>
gcc/
* config/vxworks.h (VXWORKS_BASE_LIBS_RTP): Guard -lc_internal
on !shared+!non-static and document.
(VXWORKS_LIB_SPEC): Remove the bits intended to drag the
init/fini functions from libc_internal in the shared lib case.
(VX_CRTBEGIN_SPEC/VX_CRTEND_SPEC): Use vxcrtstuff objects also in
configurations with shared lib and INITFINI_ARRAY support.
libgcc/
* config/t-vxcrtstuffS: New Makefile fragment.
* config/vxcrtstuff.c: Provide __dso_handle. Provide _init/_fini
functions for INITFINI_ARRAY support in shared libs and guard
the definition of eh table registration functions on conditions
indicating they are needed.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/config/vxworks.h | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/gcc/config/vxworks.h b/gcc/config/vxworks.h index 96076e3..52d6aa1 100644 --- a/gcc/config/vxworks.h +++ b/gcc/config/vxworks.h @@ -101,11 +101,23 @@ along with GCC; see the file COPYING3. If not see 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 @@ -120,7 +132,8 @@ along with GCC; see the file COPYING3. If not see #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 @@ -161,10 +174,9 @@ along with GCC; see the file COPYING3. If not see #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 @@ -196,11 +208,13 @@ along with GCC; see the file COPYING3. If not see #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 "" |