aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sigtramp-armdroid.c
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2022-01-18 09:54:35 +0100
committerMartin Liska <mliska@suse.cz>2022-01-18 10:18:51 +0100
commit903e846578b8a97c311a6e120edbd116a8b3f992 (patch)
tree3d2da3ff95ab1b0c6063d3cb08bac81243669df4 /gcc/ada/sigtramp-armdroid.c
parent27404a02508b99d641840b031429385d0a92b114 (diff)
downloadgcc-903e846578b8a97c311a6e120edbd116a8b3f992.zip
gcc-903e846578b8a97c311a6e120edbd116a8b3f992.tar.gz
gcc-903e846578b8a97c311a6e120edbd116a8b3f992.tar.bz2
Revert Ada .cc renaming renaming.
gcc/ada/ChangeLog: * Make-generated.in: Revert renaming changes. * Makefile.rtl: Likewise. * adadecode.cc: Moved to... * adadecode.c: ...here. * affinity.cc: Moved to... * affinity.c: ...here. * argv-lynxos178-raven-cert.cc: Moved to... * argv-lynxos178-raven-cert.c: ...here. * argv.cc: Moved to... * argv.c: ...here. * aux-io.cc: Moved to... * aux-io.c: ...here. * cio.cc: Moved to... * cio.c: ...here. * cstreams.cc: Moved to... * cstreams.c: ...here. * env.cc: Moved to... * env.c: ...here. * exit.cc: Moved to... * exit.c: ...here. * expect.cc: Moved to... * expect.c: ...here. * final.cc: Moved to... * final.c: ...here. * gcc-interface/Makefile.in: * init.cc: Moved to... * init.c: ...here. * initialize.cc: Moved to... * initialize.c: ...here. * libgnarl/thread.cc: Moved to... * libgnarl/thread.c: ...here. * link.cc: Moved to... * link.c: ...here. * locales.cc: Moved to... * locales.c: ...here. * mkdir.cc: Moved to... * mkdir.c: ...here. * raise.cc: Moved to... * raise.c: ...here. * rtfinal.cc: Moved to... * rtfinal.c: ...here. * rtinit.cc: Moved to... * rtinit.c: ...here. * s-oscons-tmplt.c (CND): Revert renaming changes. * seh_init.cc: Moved to... * seh_init.c: ...here. * sigtramp-armdroid.cc: Moved to... * sigtramp-armdroid.c: ...here. * sigtramp-ios.cc: Moved to... * sigtramp-ios.c: ...here. * sigtramp-qnx.cc: Moved to... * sigtramp-qnx.c: ...here. * sigtramp-vxworks.cc: Moved to... * sigtramp-vxworks.c: ...here. * socket.cc: Moved to... * socket.c: ...here. * tracebak.cc: Moved to... * tracebak.c: ...here. * version.cc: Moved to... * version.c: ...here. * vx_stack_info.cc: Moved to... * vx_stack_info.c: ...here.
Diffstat (limited to 'gcc/ada/sigtramp-armdroid.c')
-rw-r--r--gcc/ada/sigtramp-armdroid.c163
1 files changed, 163 insertions, 0 deletions
diff --git a/gcc/ada/sigtramp-armdroid.c b/gcc/ada/sigtramp-armdroid.c
new file mode 100644
index 0000000..cd15b32
--- /dev/null
+++ b/gcc/ada/sigtramp-armdroid.c
@@ -0,0 +1,163 @@
+/****************************************************************************
+ * *
+ * 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-Android version of the __gnat_sigtramp service *
+ ******************************************************/
+
+#include <sys/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.
+
+ We support stubs for VxWorks and Android, providing unwind info for
+ common registers. We might need variants with support for floating
+ point or altivec registers as well at some point.
+
+ For Android it would be simpler to write this in Asm since there's only
+ one variant, but to keep it looking like the VxWorks stubs,
+ C is the choice for our toplevel interface.
+
+ 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));