annotate gcc/ada/sigtramp-armdroid.c @ 143:76e1cf5455ef

add cbc_gc test
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 23 Dec 2018 19:24:05 +0900
parents 84e7813d76e9
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /****************************************************************************
kono
parents:
diff changeset
2 * *
kono
parents:
diff changeset
3 * GNAT COMPILER COMPONENTS *
kono
parents:
diff changeset
4 * *
kono
parents:
diff changeset
5 * S I G T R A M P *
kono
parents:
diff changeset
6 * *
kono
parents:
diff changeset
7 * Asm Implementation File *
kono
parents:
diff changeset
8 * *
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 * Copyright (C) 2015-2018, Free Software Foundation, Inc. *
111
kono
parents:
diff changeset
10 * *
kono
parents:
diff changeset
11 * GNAT is free software; you can redistribute it and/or modify it under *
kono
parents:
diff changeset
12 * terms of the GNU General Public License as published by the Free Soft- *
kono
parents:
diff changeset
13 * ware Foundation; either version 3, or (at your option) any later ver- *
kono
parents:
diff changeset
14 * sion. GNAT is distributed in the hope that it will be useful, but WITH- *
kono
parents:
diff changeset
15 * OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
kono
parents:
diff changeset
16 * or FITNESS FOR A PARTICULAR PURPOSE. *
kono
parents:
diff changeset
17 * *
kono
parents:
diff changeset
18 * As a special exception under Section 7 of GPL version 3, you are granted *
kono
parents:
diff changeset
19 * additional permissions described in the GCC Runtime Library Exception, *
kono
parents:
diff changeset
20 * version 3.1, as published by the Free Software Foundation. *
kono
parents:
diff changeset
21 * *
kono
parents:
diff changeset
22 * In particular, you can freely distribute your programs built with the *
kono
parents:
diff changeset
23 * GNAT Pro compiler, including any required library run-time units, using *
kono
parents:
diff changeset
24 * any licensing terms of your choosing. See the AdaCore Software License *
kono
parents:
diff changeset
25 * for full details. *
kono
parents:
diff changeset
26 * *
kono
parents:
diff changeset
27 * GNAT was originally developed by the GNAT team at New York University. *
kono
parents:
diff changeset
28 * Extensive contributions were provided by Ada Core Technologies Inc. *
kono
parents:
diff changeset
29 * *
kono
parents:
diff changeset
30 ****************************************************************************/
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 /******************************************************
kono
parents:
diff changeset
33 * ARM-Android version of the __gnat_sigtramp service *
kono
parents:
diff changeset
34 ******************************************************/
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 #include <sys/ucontext.h>
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 #include "sigtramp.h"
kono
parents:
diff changeset
39 /* See sigtramp.h for a general explanation of functionality. */
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 /* ----------------------
kono
parents:
diff changeset
42 -- General comments --
kono
parents:
diff changeset
43 ----------------------
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 Stubs are generated from toplevel asms,
kono
parents:
diff changeset
46 The general idea is to establish CFA as the sigcontext
kono
parents:
diff changeset
47 and state where to find the registers as offsets from there.
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 We support stubs for VxWorks and Android, providing unwind info for
kono
parents:
diff changeset
50 common registers. We might need variants with support for floating
kono
parents:
diff changeset
51 point or altivec registers as well at some point.
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 For Android it would be simpler to write this in Asm since there's only
kono
parents:
diff changeset
54 one variant, but to keep it looking like the VxWorks stubs,
kono
parents:
diff changeset
55 C is the choice for our toplevel interface.
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 Note that the registers we "restore" here are those to which we have
kono
parents:
diff changeset
58 direct access through the system sigcontext structure, which includes
kono
parents:
diff changeset
59 only a partial set of the non-volatiles ABI-wise. */
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 /* -----------------------------------------
kono
parents:
diff changeset
62 -- Protypes for our internal asm stubs --
kono
parents:
diff changeset
63 -----------------------------------------
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 The registers are expected to be at SIGCONTEXT + 12 (reference the
kono
parents:
diff changeset
66 sicontext structure in asm/sigcontext.h which describes the first
kono
parents:
diff changeset
67 3 * 4byte fields.) Even though our symbols will remain local, the
kono
parents:
diff changeset
68 prototype claims "extern" and not "static" to prevent compiler complaints
kono
parents:
diff changeset
69 about a symbol used but never defined. */
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71 /* sigtramp stub providing unwind info for common registers. */
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 extern void __gnat_sigtramp_common
kono
parents:
diff changeset
74 (int signo, void *siginfo, void *sigcontext,
kono
parents:
diff changeset
75 __sigtramphandler_t * handler);
kono
parents:
diff changeset
76
kono
parents:
diff changeset
77 void __gnat_sigtramp (int signo, void *si, void *sc,
kono
parents:
diff changeset
78 __sigtramphandler_t * handler)
kono
parents:
diff changeset
79 __attribute__((optimize(2)));
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 void __gnat_sigtramp (int signo, void *si, void *ucontext,
kono
parents:
diff changeset
82 __sigtramphandler_t * handler)
kono
parents:
diff changeset
83 {
kono
parents:
diff changeset
84 struct sigcontext *mcontext = &((ucontext_t *) ucontext)->uc_mcontext;
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 __gnat_sigtramp_common (signo, si, mcontext, handler);
kono
parents:
diff changeset
87 }
kono
parents:
diff changeset
88
kono
parents:
diff changeset
89 /* asm string construction helpers. */
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 #define STR(TEXT) #TEXT
kono
parents:
diff changeset
92 /* stringify expanded TEXT, surrounding it with double quotes. */
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 #define S(E) STR(E)
kono
parents:
diff changeset
95 /* stringify E, which will resolve as text but may contain macros
kono
parents:
diff changeset
96 still to be expanded. */
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 /* asm (TEXT) outputs <tab>TEXT. These facilitate the output of
kono
parents:
diff changeset
99 multiline contents: */
kono
parents:
diff changeset
100 #define TAB(S) "\t" S
kono
parents:
diff changeset
101 #define CR(S) S "\n"
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 #undef TCR
kono
parents:
diff changeset
104 #define TCR(S) TAB(CR(S))
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 /* Trampoline body block
kono
parents:
diff changeset
107 --------------------- */
kono
parents:
diff changeset
108
kono
parents:
diff changeset
109 #define SIGTRAMP_BODY \
kono
parents:
diff changeset
110 CR("") \
kono
parents:
diff changeset
111 TCR("# Allocate frame and also save r2 which is the argument register") \
kono
parents:
diff changeset
112 TCR("# containing the sigcontext, so that we can restore it during") \
kono
parents:
diff changeset
113 TCR("# unwinding and thereby load the rest of the desired context.") \
kono
parents:
diff changeset
114 TCR("stmfd sp!, {r2, r3, lr}") \
kono
parents:
diff changeset
115 TCR("# The unwinder undo's these operations in reverse order so starting") \
kono
parents:
diff changeset
116 TCR("# from bottom, restore r2 from the current vsp location, move r2 into") \
kono
parents:
diff changeset
117 TCR("# the vsp, add 12 bytes to get the start of the register save area") \
kono
parents:
diff changeset
118 TCR("# then restore the 15 general purpose registers of the frame which") \
kono
parents:
diff changeset
119 TCR("# raised the signal.") \
kono
parents:
diff changeset
120 TCR(".save {r0-r15}") \
kono
parents:
diff changeset
121 TCR(".pad #12") \
kono
parents:
diff changeset
122 TCR(".movsp r2") \
kono
parents:
diff changeset
123 TCR(".save {r2}") \
kono
parents:
diff changeset
124 TCR("# Call the real handler. The signo, siginfo and sigcontext") \
kono
parents:
diff changeset
125 TCR("# arguments are the same as those we received in r0, r1 and r2.") \
kono
parents:
diff changeset
126 TCR("blx r3") \
kono
parents:
diff changeset
127 TCR("# Restore our callee-saved items, release our frame and return") \
kono
parents:
diff changeset
128 TCR("# (should never get here!).") \
kono
parents:
diff changeset
129 TCR("ldmfd sp, {r2, r3, pc}")
kono
parents:
diff changeset
130
kono
parents:
diff changeset
131 /* Symbol definition block
kono
parents:
diff changeset
132 ----------------------- */
kono
parents:
diff changeset
133
kono
parents:
diff changeset
134 #define SIGTRAMP_START(SYM) \
kono
parents:
diff changeset
135 CR("# " S(SYM) " unwind trampoline") \
kono
parents:
diff changeset
136 TCR(".type " S(SYM) ", %function") \
kono
parents:
diff changeset
137 CR("") \
kono
parents:
diff changeset
138 CR(S(SYM) ":") \
kono
parents:
diff changeset
139 TCR(".fnstart")
kono
parents:
diff changeset
140
kono
parents:
diff changeset
141 /* Symbol termination block
kono
parents:
diff changeset
142 ------------------------ */
kono
parents:
diff changeset
143
kono
parents:
diff changeset
144 #define SIGTRAMP_END(SYM) \
kono
parents:
diff changeset
145 CR(".fnend") \
kono
parents:
diff changeset
146 TCR(".size " S(SYM) ", .-" S(SYM))
kono
parents:
diff changeset
147
kono
parents:
diff changeset
148 /*----------------------------
kono
parents:
diff changeset
149 -- And now, the real code --
kono
parents:
diff changeset
150 ---------------------------- */
kono
parents:
diff changeset
151
kono
parents:
diff changeset
152 /* Text section start. The compiler isn't aware of that switch. */
kono
parents:
diff changeset
153
kono
parents:
diff changeset
154 asm (".text\n"
kono
parents:
diff changeset
155 TCR(".align 2"));
kono
parents:
diff changeset
156
kono
parents:
diff changeset
157 /* sigtramp stub for common registers. */
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 #define TRAMP_COMMON __gnat_sigtramp_common
kono
parents:
diff changeset
160
kono
parents:
diff changeset
161 asm (SIGTRAMP_START(TRAMP_COMMON));
kono
parents:
diff changeset
162 asm (SIGTRAMP_BODY);
kono
parents:
diff changeset
163 asm (SIGTRAMP_END(TRAMP_COMMON));