aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorDoug Rupp <rupp@adacore.com>2022-03-29 09:22:31 -0700
committerPierre-Marie de Rodat <derodat@adacore.com>2022-05-18 08:40:58 +0000
commit1ef3f0911cf08f1b80c845ee7eee07ecf43b9c8a (patch)
tree27fffad711e7c7ede54038669ce16ffeb85ad5cc /gcc
parent9d1336d977cf0cab75679d4b4170e7c9a86cd1f4 (diff)
downloadgcc-1ef3f0911cf08f1b80c845ee7eee07ecf43b9c8a.zip
gcc-1ef3f0911cf08f1b80c845ee7eee07ecf43b9c8a.tar.gz
gcc-1ef3f0911cf08f1b80c845ee7eee07ecf43b9c8a.tar.bz2
[Ada] New port arm-qnx
The QNX system specs for ARM and AARCH64 are identical. It makes more sense to have it named for the base architecture. gcc/ada/ * Makefile.rtl: Rename system-qnx-aarch64.ads to system-qnx-arm.ads. (AARCH64 QNX section): Modify to handle both arm and arch64. * tracebak.c (__QNX__): Add new __ARMEL__ section. * sigtramp-arm-qnx.c: New file. * libgnat/system-qnx-aarch64.ads: Renamed to ... * libgnat/system-qnx-arm.ads: this.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/Makefile.rtl23
-rw-r--r--gcc/ada/libgnat/system-qnx-arm.ads (renamed from gcc/ada/libgnat/system-qnx-aarch64.ads)2
-rw-r--r--gcc/ada/sigtramp-arm-qnx.c155
-rw-r--r--gcc/ada/tracebak.c3
4 files changed, 174 insertions, 9 deletions
diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl
index fde20d4..e4ca894 100644
--- a/gcc/ada/Makefile.rtl
+++ b/gcc/ada/Makefile.rtl
@@ -1493,8 +1493,8 @@ ifeq ($(strip $(filter-out arm% linux-androideabi,$(target_cpu) $(target_os))),)
LIBRARY_VERSION := $(LIB_VERSION)
endif
-# AARCH64 QNX
-ifeq ($(strip $(filter-out aarch64 %qnx,$(target_cpu) $(target_os))),)
+# ARM and AARCH64 QNX
+ifeq ($(strip $(filter-out arm aarch64 %qnx,$(target_cpu) $(target_os))),)
LIBGNAT_TARGET_PAIRS = \
a-intnam.ads<libgnarl/a-intnam__qnx.ads \
a-nallfl.ads<libgnat/a-nallfl__wraplf.ads \
@@ -1511,21 +1511,28 @@ ifeq ($(strip $(filter-out aarch64 %qnx,$(target_cpu) $(target_os))),)
g-soliop.ads<libgnat/g-soliop__qnx.ads \
$(ATOMICS_TARGET_PAIRS) \
$(ATOMICS_BUILTINS_TARGET_PAIRS) \
- $(GNATRTL_128BIT_PAIRS) \
- system.ads<libgnat/system-qnx-aarch64.ads
+ system.ads<libgnat/system-qnx-arm.ads
TOOLS_TARGET_PAIRS = indepsw.adb<indepsw-gnu.adb
- EXTRA_GNATRTL_NONTASKING_OBJS = $(GNATRTL_128BIT_OBJS)
EXTRA_GNATRTL_TASKING_OBJS=s-qnx.o
- EXTRA_LIBGNAT_OBJS+=sigtramp-qnx.o
+ ifeq ($(strip $(filter-out arm%, $(target_cpu))),)
+ EH_MECHANISM=-arm
+ SIGTRAMP_OBJ=sigtramp-arm-qnx.o
+ else
+ EH_MECHANISM=-gcc
+ SIGTRAMP_OBJ=sigtramp-qnx.o
+ LIBGNAT_TARGET_PAIRS += $(GNATRTL_128BIT_PAIRS)
+ EXTRA_GNATRTL_NONTASKING_OBJS = $(GNATRTL_128BIT_OBJS)
+ # Temporarily restrict shared library build to aarch64 (V303-025)
+ GNATLIB_SHARED = gnatlib-shared-dual
+ endif
+ EXTRA_LIBGNAT_OBJS+=$(SIGTRAMP_OBJ)
EXTRA_LIBGNAT_SRCS+=sigtramp.h
- EH_MECHANISM=-gcc
SO_OPTS= -shared-libgcc -Wl,-soname,
MISCLIB= -lsocket
THREADSLIB=
- GNATLIB_SHARED = gnatlib-shared-dual
LIBRARY_VERSION := $(LIB_VERSION)
endif
diff --git a/gcc/ada/libgnat/system-qnx-aarch64.ads b/gcc/ada/libgnat/system-qnx-arm.ads
index 7e61ae3..5f4b90e 100644
--- a/gcc/ada/libgnat/system-qnx-aarch64.ads
+++ b/gcc/ada/libgnat/system-qnx-arm.ads
@@ -5,7 +5,7 @@
-- S Y S T E M --
-- --
-- S p e c --
--- (QNX/Aarch64 Version) --
+-- (QNX-ARM/AARCH64 Version) --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
diff --git a/gcc/ada/sigtramp-arm-qnx.c b/gcc/ada/sigtramp-arm-qnx.c
new file mode 100644
index 0000000..4d359d7
--- /dev/null
+++ b/gcc/ada/sigtramp-arm-qnx.c
@@ -0,0 +1,155 @@
+/****************************************************************************
+ * *
+ * GNAT COMPILER COMPONENTS *
+ * *
+ * S I G T R A M P *
+ * *
+ * Asm Implementation File *
+ * *
+ * Copyright (C) 2015-2022, Free Software Foundation, Inc. *
+ * *
+ * GNAT is free software; you can redistribute it and/or modify it under *
+ * terms of the GNU General Public License as published by the Free Soft- *
+ * ware Foundation; either version 3, or (at your option) any later ver- *
+ * sion. GNAT is distributed in the hope that it will be useful, but WITH- *
+ * OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
+ * or FITNESS FOR A PARTICULAR PURPOSE. *
+ * *
+ * As a special exception 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. *
+ * *
+ * In particular, you can freely distribute your programs built with the *
+ * GNAT Pro compiler, including any required library run-time units, using *
+ * any licensing terms of your choosing. See the AdaCore Software License *
+ * for full details. *
+ * *
+ * GNAT was originally developed by the GNAT team at New York University. *
+ * Extensive contributions were provided by Ada Core Technologies Inc. *
+ * *
+ ****************************************************************************/
+
+/**************************************************
+ * ARM-QNX version of the __gnat_sigtramp service *
+ **************************************************/
+
+#include <ucontext.h>
+
+#include "sigtramp.h"
+/* See sigtramp.h for a general explanation of functionality. */
+
+/* ----------------------
+ -- General comments --
+ ----------------------
+
+ Stubs are generated from toplevel asms,
+ The general idea is to establish CFA as the sigcontext
+ and state where to find the registers as offsets from there.
+
+ Note that the registers we "restore" here are those to which we have
+ direct access through the system sigcontext structure, which includes
+ only a partial set of the non-volatiles ABI-wise. */
+
+/* -----------------------------------------
+ -- Protypes for our internal asm stubs --
+ -----------------------------------------
+
+ The registers are expected to be at SIGCONTEXT + 12 (reference the
+ sicontext structure in asm/sigcontext.h which describes the first
+ 3 * 4byte fields.) Even though our symbols will remain local, the
+ prototype claims "extern" and not "static" to prevent compiler complaints
+ about a symbol used but never defined. */
+
+/* sigtramp stub providing unwind info for common registers. */
+
+extern void __gnat_sigtramp_common
+ (int signo, void *siginfo, void *sigcontext,
+ __sigtramphandler_t * handler);
+
+void __gnat_sigtramp (int signo, void *si, void *sc,
+ __sigtramphandler_t * handler)
+ __attribute__((optimize(2)));
+
+void __gnat_sigtramp (int signo, void *si, void *ucontext,
+ __sigtramphandler_t * handler)
+{
+ struct sigcontext *mcontext = &((ucontext_t *) ucontext)->uc_mcontext;
+
+ __gnat_sigtramp_common (signo, si, mcontext, handler);
+}
+
+/* asm string construction helpers. */
+
+#define STR(TEXT) #TEXT
+/* stringify expanded TEXT, surrounding it with double quotes. */
+
+#define S(E) STR(E)
+/* stringify E, which will resolve as text but may contain macros
+ still to be expanded. */
+
+/* asm (TEXT) outputs <tab>TEXT. These facilitate the output of
+ multiline contents: */
+#define TAB(S) "\t" S
+#define CR(S) S "\n"
+
+#undef TCR
+#define TCR(S) TAB(CR(S))
+
+/* Trampoline body block
+ --------------------- */
+
+#define SIGTRAMP_BODY \
+CR("") \
+TCR("# Allocate frame and also save r2 which is the argument register") \
+TCR("# containing the sigcontext, so that we can restore it during") \
+TCR("# unwinding and thereby load the rest of the desired context.") \
+TCR("stmfd sp!, {r2, r3, lr}") \
+TCR("# The unwinder undo's these operations in reverse order so starting") \
+TCR("# from bottom, restore r2 from the current vsp location, move r2 into") \
+TCR("# the vsp, add 12 bytes to get the start of the register save area") \
+TCR("# then restore the 15 general purpose registers of the frame which") \
+TCR("# raised the signal.") \
+TCR(".save {r0-r15}") \
+TCR(".pad #12") \
+TCR(".movsp r2") \
+TCR(".save {r2}") \
+TCR("# Call the real handler. The signo, siginfo and sigcontext") \
+TCR("# arguments are the same as those we received in r0, r1 and r2.") \
+TCR("blx r3") \
+TCR("# Restore our callee-saved items, release our frame and return") \
+TCR("# (should never get here!).") \
+TCR("ldmfd sp, {r2, r3, pc}")
+
+/* Symbol definition block
+ ----------------------- */
+
+#define SIGTRAMP_START(SYM) \
+CR("# " S(SYM) " unwind trampoline") \
+TCR(".type " S(SYM) ", %function") \
+CR("") \
+CR(S(SYM) ":") \
+TCR(".fnstart")
+
+/* Symbol termination block
+ ------------------------ */
+
+#define SIGTRAMP_END(SYM) \
+CR(".fnend") \
+TCR(".size " S(SYM) ", .-" S(SYM))
+
+/*----------------------------
+ -- And now, the real code --
+ ---------------------------- */
+
+/* Text section start. The compiler isn't aware of that switch. */
+
+asm (".text\n"
+ TCR(".align 2"));
+
+/* sigtramp stub for common registers. */
+
+#define TRAMP_COMMON __gnat_sigtramp_common
+
+asm (SIGTRAMP_START(TRAMP_COMMON));
+asm (SIGTRAMP_BODY);
+asm (SIGTRAMP_END(TRAMP_COMMON));
diff --git a/gcc/ada/tracebak.c b/gcc/ada/tracebak.c
index 6cc5d30..f4e739d 100644
--- a/gcc/ada/tracebak.c
+++ b/gcc/ada/tracebak.c
@@ -555,6 +555,9 @@ is_return_from(void *symbol_addr, void *ret_addr)
#if defined (__aarch64__)
#define PC_ADJUST -4
+#elif defined (__ARMEL__)
+#define PC_ADJUST -2
+#define USING_ARM_UNWINDING 1
#else
#error Unhandled QNX architecture.
#endif