]> gcc.gnu.org Git - gcc.git/commitdiff
Introduce vxworks specific crtstuff support
authorJerome Lambourg <lambourg@adacore.com>
Thu, 14 Nov 2019 15:53:23 +0000 (15:53 +0000)
committerOlivier Hainque <hainque@gcc.gnu.org>
Thu, 14 Nov 2019 15:53:23 +0000 (15:53 +0000)
2019-11-06  Jerome Lambourg  <lambourg@adacore.com>
            Olivier Hainque  <hainque@adacore.com>

libgcc/
* config/vxcrtstuff.c: New file.
* config/t-vxcrtstuff: New Makefile fragment.
* config.host: Append t-vxcrtstuff to the tmake_file list
on all VxWorks ports using dwarf for table based EH.

gcc/
* config/vx-common.h (USE_TM_CLONE_REGISTRY): Remove
definition, pointless with a VxWorks specific version
of crtstuff.
(DWARF2_UNWIND_INFO): Conditionalize on !ARM_UNWIND_INFO.
* config/vxworks.h (VX_CRTBEGIN_SPEC, VX_CRTEND_SPEC):
New local macros, controlling the addition of vxworks specific
crtstuff objects depending on the EH mechanism and kind of
module being linked.
(VXWORKS_STARTFILE_SPEC, VXWORKS_ENDFILE_SPEC): Use them.

Co-Authored-By: Olivier Hainque <hainque@adacore.com>
From-SVN: r278248

gcc/ChangeLog
gcc/config/vx-common.h
gcc/config/vxworks.h
libgcc/ChangeLog
libgcc/config.host
libgcc/config/t-vxcrtstuff [new file with mode: 0644]
libgcc/config/vxcrtstuff.c [new file with mode: 0644]

index 0deaff18f214bad96afae23b0186e4348376fc6b..e24af4944ec123bc0b6211d5803df90eae4b0e88 100644 (file)
@@ -1,3 +1,16 @@
+2019-11-06  Jerome Lambourg  <lambourg@adacore.com>
+           Olivier Hainque  <hainque@adacore.com>
+
+       * config/vx-common.h (USE_TM_CLONE_REGISTRY): Remove
+       definition, pointless with a VxWorks specific version
+       of crtstuff.
+       (DWARF2_UNWIND_INFO): Conditionalize on !ARM_UNWIND_INFO.
+       * config/vxworks.h (VX_CRTBEGIN_SPEC, VX_CRTEND_SPEC):
+       New local macros, controlling the addition of vxworks specific
+       crtstuff objects depending on the EH mechanism and kind of
+       module being linked.
+       (VXWORKS_STARTFILE_SPEC, VXWORKS_ENDFILE_SPEC): Use them.
+
 2019-11-06  Pat Bernardi  <bernardi@adacore.com>
             Jerome Lambourg  <lambourg@adacore.com>
             Olivier Hainque  <hainque@adacore.com>
index 2cbec744ca4cd18e2a5a0dddfadcbb447003c476..c76dccf2c9965c37ea27ac7aa10cd3b63eaa9b30 100644 (file)
@@ -58,9 +58,21 @@ along with GCC; see the file COPYING3.  If not see
 #undef WINT_TYPE_SIZE
 #define WINT_TYPE_SIZE 16
 
-/* Dwarf2 unwind info is supported.  */
+/* Dwarf2 unwind info is supported, unless overriden by a request for a target
+   specific format.
+
+   Taking care of this here allows using DWARF2_UNWIND_INFO in #if conditions
+   from the common config/vxworks.h files, included before the cpu
+   specializations.  Unlike with conditions used in C expressions, where the
+   definitions which matter are those at the expression expansion point, use
+   in #if constructs requires an accurate definition of the operands at the
+   #if point.  Since <cpu>/vxworks.h. is typically included after
+   config/vxworks.h, #if expressions in the latter can't rely on possible
+   redefinitions in the former.  */
+#if !ARM_UNWIND_INFO
 #undef DWARF2_UNWIND_INFO
 #define DWARF2_UNWIND_INFO 1
+#endif
 
 /* VxWorks uses DWARF2 debugging info.  */
 #define DWARF2_DEBUGGING_INFO 1
@@ -87,10 +99,3 @@ along with GCC; see the file COPYING3.  If not see
 /* We occasionally need to distinguish between the VxWorks variants.  */
 #define VXWORKS_KIND_NORMAL  1
 #define VXWORKS_KIND_AE      2
-
-/*
- * libitm is not supported on VxWorks. Rather than providing stub
- * no-op _ITM_registerTMCloneTable/_ITM_deregisterTMCloneTable
- * functions, simply prevent crtstuff from even referring to those.
- */
-#define USE_TM_CLONE_REGISTRY 0
index 8c93a3067762da72c3a74187d0a54caa671addbb..d7083b33aba4b160faabb33bd3b31f54791efacf 100644 (file)
@@ -143,9 +143,23 @@ along with GCC; see the file COPYING3.  If not see
 #undef VXWORKS_LIBGCC_SPEC
 #define VXWORKS_LIBGCC_SPEC "-lgcc"
 
+/* Setup the crtstuff begin/end we might need for dwarf EH registration.  */
+
+#if !defined(CONFIG_SJLJ_EXCEPTIONS) && DWARF2_UNWIND_INFO
+#define VX_CRTBEGIN_SPEC \
+ "%{!mrtp:vx_crtbegin-kernel.o%s} %{mrtp:vx_crtbegin-rtp.o%s}"
+#define VX_CRTEND_SPEC "-l:vx_crtend.o"
+#else
+#define VX_CRTBEGIN_SPEC ""
+#define VX_CRTEND_SPEC ""
+#endif
+
 #undef VXWORKS_STARTFILE_SPEC
-#define        VXWORKS_STARTFILE_SPEC "%{mrtp:%{!shared:-l:crt0.o}}"
-#define VXWORKS_ENDFILE_SPEC ""
+#define VXWORKS_STARTFILE_SPEC \
+  VX_CRTBEGIN_SPEC " %{mrtp:%{!shared:-l:crt0.o}}"
+
+#undef VXWORKS_ENDFILE_SPEC
+#define VXWORKS_ENDFILE_SPEC VX_CRTEND_SPEC
 
 #undef  VXWORKS_CC1_SPEC
 #if TARGET_VXWORKS7
index ff26a0ced5de54b6c1753992a9708fa455180257..845dbd0c11a067215bdb1897193045e84894ffa7 100644 (file)
@@ -1,3 +1,11 @@
+2019-11-06  Jerome Lambourg  <lambourg@adacore.com>
+           Olivier Hainque  <hainque@adacore.com>
+
+       * config/vxcrtstuff.c: New file.
+       * config/t-vxcrtstuff: New Makefile fragment.
+       * config.host: Append t-vxcrtstuff to the tmake_file list
+       on all VxWorks ports using dwarf for table based EH.
+
 2019-11-07  Georg-Johann Lay  <avr@gjlay.de>
 
        Support 64-bit double and 64-bit long double configurations.
index 0b8eb4e5d73cf8b76139cd40d6be16e462a5e9eb..b2004afb02f76dbea1cd9fe77b49b87025585dae 100644 (file)
@@ -329,6 +329,16 @@ case ${host} in
   ;;
 esac
 
+# Except on ARM where we do not use DWARF, table based EH on VxWorks
+# relies on specially crafted crtstuff files
+case ${host} in
+arm-*-vxworks*)
+  ;;
+*-*-vxworks*)
+  tmake_file="${tmake_file} t-vxcrtstuff"
+  ;;
+esac
+
 case ${host} in
 *-*-darwin* | *-*-dragonfly* | *-*-freebsd* | *-*-netbsd* | *-*-openbsd* | \
   *-*-solaris2*)
diff --git a/libgcc/config/t-vxcrtstuff b/libgcc/config/t-vxcrtstuff
new file mode 100644 (file)
index 0000000..96b7285
--- /dev/null
@@ -0,0 +1,12 @@
+# crtbegin/crtend for VxWorks (DKM or RTP)
+
+vx_crtbegin-kernel.o: $(srcdir)/config/vxcrtstuff.c
+       $(crt_compile) $(CRTSTUFF_T_CFLAGS) -DCRT_BEGIN -c $<
+
+vx_crtbegin-rtp.o: $(srcdir)/config/vxcrtstuff.c
+       $(crt_compile) $(CRTSTUFF_T_CFLAGS) -DCRT_BEGIN -c $< -mrtp
+
+vx_crtend.o: $(srcdir)/config/vxcrtstuff.c
+       $(crt_compile) $(CRTSTUFF_T_CFLAGS) -DCRT_END -c $<
+
+EXTRA_PARTS += vx_crtbegin-kernel.o vx_crtbegin-rtp.o vx_crtend.o
diff --git a/libgcc/config/vxcrtstuff.c b/libgcc/config/vxcrtstuff.c
new file mode 100644 (file)
index 0000000..616ad07
--- /dev/null
@@ -0,0 +1,132 @@
+/* This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+/* The essential point of the crtbegin/crtend files on VxWorks is to handle
+   the eh frames registration thanks to dedicated constructors and
+   destructors.  What needs to be done depends on the VxWorks version and the
+   kind of module (rtp, dkm, ...) one is building.  */
+
+#define IN_LIBGCC2
+
+#include "auto-host.h"
+#include "tconfig.h"
+#include "tsystem.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "libgcc_tm.h"
+#include "unwind-dw2-fde.h"
+
+/* If we are entitled/requested to use init/fini arrays, we'll rely on that.
+   Otherwise, we may rely on ctors/dtors sections for RTPs or expect munch to
+   be involved for kernel modules.  */
+
+#if !defined(USE_INIT_FINI_ARRAY) && defined(__RTP__)
+#define USE_CDTORS_SECTIONS
+#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)))
+  = { };
+
+/* Determine what names to use for the constructor/destructor functions.  */
+
+#if defined(USE_CDTORS_SECTIONS) || defined(USE_INITFINI_ARRAY)
+
+#define EH_CTOR_NAME _crtbe_register_frame
+#define EH_DTOR_NAME _ctrbe_deregister_frame
+
+#else
+
+/* No specific sections for constructors or destructors: we thus use a
+   symbol naming convention so that the constructors are then recognized
+   by munch or whatever tool is used for the final link phase.  */
+#define EH_CTOR_NAME _GLOBAL__I_00101_0__crtbe_register_frame
+#define EH_DTOR_NAME _GLOBAL__D_00101_1__crtbe_deregister_frame
+
+#endif
+
+#ifdef USE_INITFINI_ARRAY
+/* .init_array and .fini_array is supported starting VxWorks 7.2 in all
+   cases. The compiler is then configured to always support priorities in
+   constructors, so we can rely on the constructor and destructor attributes
+   to generate the proper sections.  */
+#define EH_CTOR_ATTRIBUTE __attribute__((constructor (101)))
+#define EH_DTOR_ATTRIBUTE __attribute__((destructor (101)))
+
+#else /* USE_INITFINI_ARRAY  */
+
+/* Note: Even in case of .ctors/.dtors sections, we can't use the attribute
+   (constructor (15)) here as gcc may have been configured with constructors
+   priority disabled.  We will instead craft an explicit section name for this
+   purpose.  */
+#define EH_CTOR_ATTRIBUTE
+#define EH_DTOR_ATTRIBUTE
+
+#endif /* USE_INITFINI_ARRAY  */
+
+void EH_CTOR_NAME (void);
+void EH_DTOR_NAME (void);
+
+EH_CTOR_ATTRIBUTE void EH_CTOR_NAME (void)
+{
+  static struct object object;
+  __register_frame_info (__EH_FRAME_BEGIN__, &object);
+}
+
+EH_DTOR_ATTRIBUTE void EH_DTOR_NAME (void)
+{
+  __deregister_frame_info (__EH_FRAME_BEGIN__);
+}
+
+#ifdef USE_CDTORS_SECTIONS
+/* As explained above, we need to manually build the sections here as the
+   compiler may not have support for constructors priority enabled.  */
+static void (* volatile eh_registration_ctors[])()
+  __attribute__((section (".ctors.101")))
+= { &EH_CTOR_NAME };
+static void (* volatile eh_registration_dtors[])()
+  __attribute__((section (".dtors.65434")))
+= { &EH_DTOR_NAME };
+#endif
+
+/*  ------------------------------ crtend ---------------------------------  */
+
+#elif defined (CRT_END) /* ! CRT_BEGIN */
+
+/* Terminate the frame unwind info section with a 4byte 0 as a sentinel;
+   this would be the 'length' field in a real FDE.  */
+
+static const char __FRAME_END__[]
+     __attribute__ ((used, section(__LIBGCC_EH_FRAME_SECTION_NAME__),
+                    aligned(4)))
+  = { 0, 0, 0, 0 };
+
+#else /* ! CRT_BEGIN & ! CRT_END */
+
+#error "One of CRT_BEGIN or CRT_END must be defined."
+
+#endif
This page took 0.100322 seconds and 5 git commands to generate.