annotate gcc/ada/sigtramp-vxworks-target.inc @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
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 - T A R G E T *
kono
parents:
diff changeset
6 * *
kono
parents:
diff changeset
7 * Asm Implementation Include File *
kono
parents:
diff changeset
8 * *
kono
parents:
diff changeset
9 * Copyright (C) 2011-2015, Free Software Foundation, Inc. *
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 * VxWorks target specific part of the __gnat_sigtramp service *
kono
parents:
diff changeset
34 ***************************************************************/
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 /* Note: This target specific part is kept in a separate file to avoid
kono
parents:
diff changeset
37 duplication of its code for the vxworks and vxworks-vxsim asm
kono
parents:
diff changeset
38 implementation files. */
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 /* ---------------------------
kono
parents:
diff changeset
41 -- And now the asm stubs --
kono
parents:
diff changeset
42 ---------------------------
kono
parents:
diff changeset
43
kono
parents:
diff changeset
44 They all have a common structure with blocks of asm sequences queued one
kono
parents:
diff changeset
45 after the others. Typically:
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 SYMBOL_START
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 CFI_DIRECTIVES
kono
parents:
diff changeset
50 CFI_DEF_CFA,
kono
parents:
diff changeset
51 CFI_COMMON_REGISTERS,
kono
parents:
diff changeset
52 ...
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 STUB_BODY
kono
parents:
diff changeset
55 asm code to establish frame, setup the cfa reg value,
kono
parents:
diff changeset
56 call the real signal handler, ...
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 SYMBOL_END
kono
parents:
diff changeset
59 */
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 /*--------------------------------
kono
parents:
diff changeset
62 -- Misc constants and helpers --
kono
parents:
diff changeset
63 -------------------------------- */
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 /* asm string construction helpers. */
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 #define STR(TEXT) #TEXT
kono
parents:
diff changeset
68 /* stringify expanded TEXT, surrounding it with double quotes. */
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 #define S(E) STR(E)
kono
parents:
diff changeset
71 /* stringify E, which will resolve as text but may contain macros
kono
parents:
diff changeset
72 still to be expanded. */
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 /* asm (TEXT) outputs <tab>TEXT. These facilitate the output of
kono
parents:
diff changeset
75 multine contents: */
kono
parents:
diff changeset
76 #define TAB(S) "\t" S
kono
parents:
diff changeset
77 #define CR(S) S "\n"
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 #undef TCR
kono
parents:
diff changeset
80 #define TCR(S) TAB(CR(S))
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 /* REGNO constants, dwarf column numbers for registers of interest. */
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 #if defined (__PPC__)
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 #define REGNO_LR 65
kono
parents:
diff changeset
87 #define REGNO_CTR 66
kono
parents:
diff changeset
88 #define REGNO_CR 70
kono
parents:
diff changeset
89 #define REGNO_XER 76
kono
parents:
diff changeset
90 #define REGNO_GR(N) (N)
kono
parents:
diff changeset
91
kono
parents:
diff changeset
92 #define REGNO_PC 67 /* ARG_POINTER_REGNUM */
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 #define FUNCTION "@function"
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 #elif defined (__ARMEL__)
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 #define REGNO_G_REG_OFFSET(N) (N)
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 #define REGNO_PC_OFFSET 15 /* PC_REGNUM */
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 #define FUNCTION "%function"
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104 #elif defined (i386)
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 /* These are the cfi colunm numbers */
kono
parents:
diff changeset
107
kono
parents:
diff changeset
108 #define REGNO_EDI 7
kono
parents:
diff changeset
109 #define REGNO_ESI 6
kono
parents:
diff changeset
110 #define REGNO_EBP 5
kono
parents:
diff changeset
111 #define REGNO_ESP 4
kono
parents:
diff changeset
112 #define REGNO_EBX 3
kono
parents:
diff changeset
113 #define REGNO_EDX 2
kono
parents:
diff changeset
114 #define REGNO_ECX 1
kono
parents:
diff changeset
115 #define REGNO_EAX 0
kono
parents:
diff changeset
116 #define REGNO_EFLAGS 9
kono
parents:
diff changeset
117 #define REGNO_SET_PC 8 /* aka %eip */
kono
parents:
diff changeset
118
kono
parents:
diff changeset
119 #define FUNCTION "@function"
kono
parents:
diff changeset
120
kono
parents:
diff changeset
121 /* Mapping of CFI Column, Gcc Regno, Signal context offset for 32bit
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123 Name CFI GCC SCTX
kono
parents:
diff changeset
124 %eax 0 0 7
kono
parents:
diff changeset
125 %ecx 1 2 6
kono
parents:
diff changeset
126 %edx 2 1 5
kono
parents:
diff changeset
127 %ebx 3 3 4
kono
parents:
diff changeset
128 %esp 4 7 3
kono
parents:
diff changeset
129 %ebp 5 6 2
kono
parents:
diff changeset
130 %esi 6 4 1
kono
parents:
diff changeset
131 %edi 7 5 0
kono
parents:
diff changeset
132 %eflags 9 17 8
kono
parents:
diff changeset
133 %eip 8 n/a 9
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135
kono
parents:
diff changeset
136 In general:
kono
parents:
diff changeset
137 There is no unique numbering for the x86 architecture. It's parameterized
kono
parents:
diff changeset
138 by DWARF_FRAME_REGNUM, which is DBX_REGISTER_NUMBER except for Windows, and
kono
parents:
diff changeset
139 the latter depends on the platform.
kono
parents:
diff changeset
140 */
kono
parents:
diff changeset
141
kono
parents:
diff changeset
142 #elif defined (__x86_64__)
kono
parents:
diff changeset
143
kono
parents:
diff changeset
144 /* These are the cfi colunm numbers */
kono
parents:
diff changeset
145
kono
parents:
diff changeset
146 #define REGNO_RAX 0
kono
parents:
diff changeset
147 #define REGNO_RDX 1
kono
parents:
diff changeset
148 #define REGNO_RCX 2
kono
parents:
diff changeset
149 #define REGNO_RBX 3
kono
parents:
diff changeset
150 #define REGNO_RSI 4
kono
parents:
diff changeset
151 #define REGNO_RDI 5
kono
parents:
diff changeset
152 #define REGNO_RBP 6
kono
parents:
diff changeset
153 #define REGNO_RSP 7
kono
parents:
diff changeset
154 #define REGNO_R8 8
kono
parents:
diff changeset
155 #define REGNO_R9 9
kono
parents:
diff changeset
156 #define REGNO_R10 10
kono
parents:
diff changeset
157 #define REGNO_R11 11
kono
parents:
diff changeset
158 #define REGNO_R12 12
kono
parents:
diff changeset
159 #define REGNO_R13 13
kono
parents:
diff changeset
160 #define REGNO_R14 14
kono
parents:
diff changeset
161 #define REGNO_R15 15
kono
parents:
diff changeset
162 #define REGNO_RPC 16 /* aka %rip */
kono
parents:
diff changeset
163 #define REGNO_EFLAGS 49
kono
parents:
diff changeset
164 #define REGNO_FS 54
kono
parents:
diff changeset
165
kono
parents:
diff changeset
166 #define FUNCTION "@function"
kono
parents:
diff changeset
167
kono
parents:
diff changeset
168 #else
kono
parents:
diff changeset
169 Not_implemented;
kono
parents:
diff changeset
170 #endif /* REGNO constants */
kono
parents:
diff changeset
171
kono
parents:
diff changeset
172
kono
parents:
diff changeset
173 /*------------------------------
kono
parents:
diff changeset
174 -- Stub construction blocks --
kono
parents:
diff changeset
175 ------------------------------ */
kono
parents:
diff changeset
176
kono
parents:
diff changeset
177 /* CFA setup block
kono
parents:
diff changeset
178 ---------------
kono
parents:
diff changeset
179 Only non-volatile registers are suitable for a CFA base. These are the
kono
parents:
diff changeset
180 only ones we can expect to be able retrieve from the unwinding context
kono
parents:
diff changeset
181 while walking up the chain, saved by at least the bottom-most exception
kono
parents:
diff changeset
182 propagation services. We set a non-volatile register to the value we
kono
parents:
diff changeset
183 need in the stub body that follows. */
kono
parents:
diff changeset
184
kono
parents:
diff changeset
185 #if defined (__PPC__)
kono
parents:
diff changeset
186
kono
parents:
diff changeset
187 /* Use r15 for PPC. Note that r14 is inappropriate here, even though it
kono
parents:
diff changeset
188 is non-volatile according to the ABI, because GCC uses it as an extra
kono
parents:
diff changeset
189 SCRATCH on SPE targets. */
kono
parents:
diff changeset
190
kono
parents:
diff changeset
191 #define CFA_REG 15
kono
parents:
diff changeset
192
kono
parents:
diff changeset
193 #elif defined (__ARMEL__)
kono
parents:
diff changeset
194
kono
parents:
diff changeset
195 /* Use r8 for ARM. Any of r4-r8 should work. */
kono
parents:
diff changeset
196
kono
parents:
diff changeset
197 #define CFA_REG 8
kono
parents:
diff changeset
198
kono
parents:
diff changeset
199 #elif defined (i386)
kono
parents:
diff changeset
200
kono
parents:
diff changeset
201 #define CFA_REG 7
kono
parents:
diff changeset
202
kono
parents:
diff changeset
203 #elif defined (__x86_64__)
kono
parents:
diff changeset
204
kono
parents:
diff changeset
205 /* R15 register */
kono
parents:
diff changeset
206 #define CFA_REG 15
kono
parents:
diff changeset
207
kono
parents:
diff changeset
208 #else
kono
parents:
diff changeset
209 Not_implemented;
kono
parents:
diff changeset
210 #endif /* CFA setup block */
kono
parents:
diff changeset
211
kono
parents:
diff changeset
212 #define CFI_DEF_CFA \
kono
parents:
diff changeset
213 CR(".cfi_def_cfa " S(CFA_REG) ", 0")
kono
parents:
diff changeset
214
kono
parents:
diff changeset
215 /* Register location blocks
kono
parents:
diff changeset
216 ------------------------
kono
parents:
diff changeset
217 Rules to find registers of interest from the CFA. This should comprise
kono
parents:
diff changeset
218 all the non-volatile registers relevant to the interrupted context.
kono
parents:
diff changeset
219
kono
parents:
diff changeset
220 Note that we include r1 in this set, unlike the libgcc unwinding
kono
parents:
diff changeset
221 fallbacks. This is useful for fallbacks to allow the use of r1 in CFI
kono
parents:
diff changeset
222 expressions and the absence of rule for r1 gets compensated by using the
kono
parents:
diff changeset
223 target CFA instead. We don't need the expression facility here and
kono
parents:
diff changeset
224 setup a fake CFA to allow very simple offset expressions, so having a
kono
parents:
diff changeset
225 rule for r1 is the proper thing to do. We for sure have observed
kono
parents:
diff changeset
226 crashes in some cases without it. */
kono
parents:
diff changeset
227
kono
parents:
diff changeset
228 #if defined (__PPC__)
kono
parents:
diff changeset
229
kono
parents:
diff changeset
230 #define COMMON_CFI(REG) \
kono
parents:
diff changeset
231 ".cfi_offset " S(REGNO_##REG) "," S(REG_SET_##REG)
kono
parents:
diff changeset
232
kono
parents:
diff changeset
233 #define CFI_COMMON_REGS \
kono
parents:
diff changeset
234 CR("# CFI for common registers\n") \
kono
parents:
diff changeset
235 TCR(COMMON_CFI(GR(0))) \
kono
parents:
diff changeset
236 TCR(COMMON_CFI(GR(1))) \
kono
parents:
diff changeset
237 TCR(COMMON_CFI(GR(2))) \
kono
parents:
diff changeset
238 TCR(COMMON_CFI(GR(3))) \
kono
parents:
diff changeset
239 TCR(COMMON_CFI(GR(4))) \
kono
parents:
diff changeset
240 TCR(COMMON_CFI(GR(5))) \
kono
parents:
diff changeset
241 TCR(COMMON_CFI(GR(6))) \
kono
parents:
diff changeset
242 TCR(COMMON_CFI(GR(7))) \
kono
parents:
diff changeset
243 TCR(COMMON_CFI(GR(8))) \
kono
parents:
diff changeset
244 TCR(COMMON_CFI(GR(9))) \
kono
parents:
diff changeset
245 TCR(COMMON_CFI(GR(10))) \
kono
parents:
diff changeset
246 TCR(COMMON_CFI(GR(11))) \
kono
parents:
diff changeset
247 TCR(COMMON_CFI(GR(12))) \
kono
parents:
diff changeset
248 TCR(COMMON_CFI(GR(13))) \
kono
parents:
diff changeset
249 TCR(COMMON_CFI(GR(14))) \
kono
parents:
diff changeset
250 TCR(COMMON_CFI(GR(15))) \
kono
parents:
diff changeset
251 TCR(COMMON_CFI(GR(16))) \
kono
parents:
diff changeset
252 TCR(COMMON_CFI(GR(17))) \
kono
parents:
diff changeset
253 TCR(COMMON_CFI(GR(18))) \
kono
parents:
diff changeset
254 TCR(COMMON_CFI(GR(19))) \
kono
parents:
diff changeset
255 TCR(COMMON_CFI(GR(20))) \
kono
parents:
diff changeset
256 TCR(COMMON_CFI(GR(21))) \
kono
parents:
diff changeset
257 TCR(COMMON_CFI(GR(22))) \
kono
parents:
diff changeset
258 TCR(COMMON_CFI(GR(23))) \
kono
parents:
diff changeset
259 TCR(COMMON_CFI(GR(24))) \
kono
parents:
diff changeset
260 TCR(COMMON_CFI(GR(25))) \
kono
parents:
diff changeset
261 TCR(COMMON_CFI(GR(26))) \
kono
parents:
diff changeset
262 TCR(COMMON_CFI(GR(27))) \
kono
parents:
diff changeset
263 TCR(COMMON_CFI(GR(28))) \
kono
parents:
diff changeset
264 TCR(COMMON_CFI(GR(29))) \
kono
parents:
diff changeset
265 TCR(COMMON_CFI(GR(30))) \
kono
parents:
diff changeset
266 TCR(COMMON_CFI(GR(31))) \
kono
parents:
diff changeset
267 TCR(COMMON_CFI(LR)) \
kono
parents:
diff changeset
268 TCR(COMMON_CFI(CR)) \
kono
parents:
diff changeset
269 TCR(COMMON_CFI(CTR)) \
kono
parents:
diff changeset
270 TCR(COMMON_CFI(XER)) \
kono
parents:
diff changeset
271 TCR(COMMON_CFI(PC)) \
kono
parents:
diff changeset
272 TCR(".cfi_return_column " S(REGNO_PC))
kono
parents:
diff changeset
273
kono
parents:
diff changeset
274 /* Trampoline body block
kono
parents:
diff changeset
275 --------------------- */
kono
parents:
diff changeset
276
kono
parents:
diff changeset
277 #if !defined (__PPC64__)
kono
parents:
diff changeset
278 #define SIGTRAMP_BODY \
kono
parents:
diff changeset
279 CR("") \
kono
parents:
diff changeset
280 TCR("# Allocate frame and save the non-volatile") \
kono
parents:
diff changeset
281 TCR("# registers we're going to modify") \
kono
parents:
diff changeset
282 TCR("stwu %r1,-16(%r1)") \
kono
parents:
diff changeset
283 TCR("mflr %r0") \
kono
parents:
diff changeset
284 TCR("stw %r0,20(%r1)") \
kono
parents:
diff changeset
285 TCR("stw %r" S(CFA_REG) ",8(%r1)") \
kono
parents:
diff changeset
286 TCR("") \
kono
parents:
diff changeset
287 TCR("# Setup CFA_REG = context, which we'll retrieve as our CFA value") \
kono
parents:
diff changeset
288 TCR("mr %r" S(CFA_REG) ", %r7") \
kono
parents:
diff changeset
289 TCR("") \
kono
parents:
diff changeset
290 TCR("# Call the real handler. The signo, siginfo and sigcontext") \
kono
parents:
diff changeset
291 TCR("# arguments are the same as those we received in r3, r4 and r5") \
kono
parents:
diff changeset
292 TCR("mtctr %r6") \
kono
parents:
diff changeset
293 TCR("bctrl") \
kono
parents:
diff changeset
294 TCR("") \
kono
parents:
diff changeset
295 TCR("# Restore our callee-saved items, release our frame and return") \
kono
parents:
diff changeset
296 TCR("lwz %r" S(CFA_REG) ",8(%r1)") \
kono
parents:
diff changeset
297 TCR("lwz %r0,20(%r1)") \
kono
parents:
diff changeset
298 TCR("mtlr %r0") \
kono
parents:
diff changeset
299 TCR("") \
kono
parents:
diff changeset
300 TCR("addi %r1,%r1,16") \
kono
parents:
diff changeset
301 TCR("blr")
kono
parents:
diff changeset
302 #else
kono
parents:
diff changeset
303 #define SIGTRAMP_BODY \
kono
parents:
diff changeset
304 CR("") \
kono
parents:
diff changeset
305 TCR("0:") \
kono
parents:
diff changeset
306 TCR("addis 2,12,.TOC.-0@ha") \
kono
parents:
diff changeset
307 TCR("addi 2,2,.TOC.-0@l") \
kono
parents:
diff changeset
308 TCR(".localentry __gnat_sigtramp_common,.-__gnat_sigtramp_common") \
kono
parents:
diff changeset
309 TCR("# Allocate frame and save the non-volatile") \
kono
parents:
diff changeset
310 TCR("# registers we're going to modify") \
kono
parents:
diff changeset
311 TCR("mflr %r0") \
kono
parents:
diff changeset
312 TCR("std %r0,16(%r1)") \
kono
parents:
diff changeset
313 TCR("stdu %r1,-32(%r1)") \
kono
parents:
diff changeset
314 TCR("std %r2,24(%r1)") \
kono
parents:
diff changeset
315 TCR("std %r" S(CFA_REG) ",8(%r1)") \
kono
parents:
diff changeset
316 TCR("") \
kono
parents:
diff changeset
317 TCR("# Setup CFA_REG = context, which we'll retrieve as our CFA value") \
kono
parents:
diff changeset
318 TCR("mr %r" S(CFA_REG) ", %r7") \
kono
parents:
diff changeset
319 TCR("") \
kono
parents:
diff changeset
320 TCR("# Call the real handler. The signo, siginfo and sigcontext") \
kono
parents:
diff changeset
321 TCR("# arguments are the same as those we received in r3, r4 and r5") \
kono
parents:
diff changeset
322 TCR("mr %r12,%r6") \
kono
parents:
diff changeset
323 TCR("mtctr %r6") \
kono
parents:
diff changeset
324 TCR("bctrl") \
kono
parents:
diff changeset
325 TCR("") \
kono
parents:
diff changeset
326 TCR("# Restore our callee-saved items, release our frame and return") \
kono
parents:
diff changeset
327 TCR("ld %r" S(CFA_REG) ",8(%r1)") \
kono
parents:
diff changeset
328 TCR("ld %r2,24(%r1)") \
kono
parents:
diff changeset
329 TCR("addi %r1,%r1,32") \
kono
parents:
diff changeset
330 TCR("ld %r0,16(%r1)") \
kono
parents:
diff changeset
331 TCR("mtlr %r0") \
kono
parents:
diff changeset
332 TCR("blr")
kono
parents:
diff changeset
333 #endif
kono
parents:
diff changeset
334
kono
parents:
diff changeset
335 #elif defined (__ARMEL__)
kono
parents:
diff changeset
336
kono
parents:
diff changeset
337 #define COMMON_CFI(REG) \
kono
parents:
diff changeset
338 ".cfi_offset " S(REGNO_##REG) "," S(REG_SET_##REG)
kono
parents:
diff changeset
339
kono
parents:
diff changeset
340 #define CFI_COMMON_REGS \
kono
parents:
diff changeset
341 CR("# CFI for common registers\n") \
kono
parents:
diff changeset
342 TCR(COMMON_CFI(G_REG_OFFSET(0))) \
kono
parents:
diff changeset
343 TCR(COMMON_CFI(G_REG_OFFSET(1))) \
kono
parents:
diff changeset
344 TCR(COMMON_CFI(G_REG_OFFSET(2))) \
kono
parents:
diff changeset
345 TCR(COMMON_CFI(G_REG_OFFSET(3))) \
kono
parents:
diff changeset
346 TCR(COMMON_CFI(G_REG_OFFSET(4))) \
kono
parents:
diff changeset
347 TCR(COMMON_CFI(G_REG_OFFSET(5))) \
kono
parents:
diff changeset
348 TCR(COMMON_CFI(G_REG_OFFSET(6))) \
kono
parents:
diff changeset
349 TCR(COMMON_CFI(G_REG_OFFSET(7))) \
kono
parents:
diff changeset
350 TCR(COMMON_CFI(G_REG_OFFSET(8))) \
kono
parents:
diff changeset
351 TCR(COMMON_CFI(G_REG_OFFSET(9))) \
kono
parents:
diff changeset
352 TCR(COMMON_CFI(G_REG_OFFSET(10))) \
kono
parents:
diff changeset
353 TCR(COMMON_CFI(G_REG_OFFSET(11))) \
kono
parents:
diff changeset
354 TCR(COMMON_CFI(G_REG_OFFSET(12))) \
kono
parents:
diff changeset
355 TCR(COMMON_CFI(G_REG_OFFSET(13))) \
kono
parents:
diff changeset
356 TCR(COMMON_CFI(G_REG_OFFSET(14))) \
kono
parents:
diff changeset
357 TCR(COMMON_CFI(PC_OFFSET)) \
kono
parents:
diff changeset
358 TCR(".cfi_return_column " S(REGNO_PC_OFFSET))
kono
parents:
diff changeset
359
kono
parents:
diff changeset
360 /* Trampoline body block
kono
parents:
diff changeset
361 --------------------- */
kono
parents:
diff changeset
362
kono
parents:
diff changeset
363 #define SIGTRAMP_BODY \
kono
parents:
diff changeset
364 CR("") \
kono
parents:
diff changeset
365 TCR("# Allocate frame and save the non-volatile") \
kono
parents:
diff changeset
366 TCR("# registers we're going to modify") \
kono
parents:
diff changeset
367 TCR("mov ip, sp") \
kono
parents:
diff changeset
368 TCR("stmfd sp!, {r"S(CFA_REG)", fp, ip, lr, pc}") \
kono
parents:
diff changeset
369 TCR("# Setup CFA_REG = context, which we'll retrieve as our CFA value") \
kono
parents:
diff changeset
370 TCR("ldr r"S(CFA_REG)", [ip]") \
kono
parents:
diff changeset
371 TCR("") \
kono
parents:
diff changeset
372 TCR("# Call the real handler. The signo, siginfo and sigcontext") \
kono
parents:
diff changeset
373 TCR("# arguments are the same as those we received in r0, r1 and r2") \
kono
parents:
diff changeset
374 TCR("sub fp, ip, #4") \
kono
parents:
diff changeset
375 TCR("blx r3") \
kono
parents:
diff changeset
376 TCR("# Restore our callee-saved items, release our frame and return") \
kono
parents:
diff changeset
377 TCR("ldmfd sp, {r"S(CFA_REG)", fp, sp, pc}")
kono
parents:
diff changeset
378
kono
parents:
diff changeset
379 #elif defined (i386)
kono
parents:
diff changeset
380
kono
parents:
diff changeset
381 #if CPU == SIMNT || CPU == SIMPENTIUM || CPU == SIMLINUX
kono
parents:
diff changeset
382 #define COMMON_CFI(REG) \
kono
parents:
diff changeset
383 ".cfi_offset " S(REGNO_##REG) "," S(REG_SET_##REG)
kono
parents:
diff changeset
384 #else
kono
parents:
diff changeset
385 #define COMMON_CFI(REG) \
kono
parents:
diff changeset
386 ".cfi_offset " S(REGNO_##REG) "," S(REG_##REG)
kono
parents:
diff changeset
387 #endif
kono
parents:
diff changeset
388
kono
parents:
diff changeset
389 #define PC_CFI(REG) \
kono
parents:
diff changeset
390 ".cfi_offset " S(REGNO_##REG) "," S(REG_##REG)
kono
parents:
diff changeset
391
kono
parents:
diff changeset
392 #define CFI_COMMON_REGS \
kono
parents:
diff changeset
393 CR("# CFI for common registers\n") \
kono
parents:
diff changeset
394 TCR(COMMON_CFI(EDI)) \
kono
parents:
diff changeset
395 TCR(COMMON_CFI(ESI)) \
kono
parents:
diff changeset
396 TCR(COMMON_CFI(EBP)) \
kono
parents:
diff changeset
397 TCR(COMMON_CFI(ESP)) \
kono
parents:
diff changeset
398 TCR(COMMON_CFI(EBX)) \
kono
parents:
diff changeset
399 TCR(COMMON_CFI(EDX)) \
kono
parents:
diff changeset
400 TCR(COMMON_CFI(ECX)) \
kono
parents:
diff changeset
401 TCR(COMMON_CFI(EAX)) \
kono
parents:
diff changeset
402 TCR(COMMON_CFI(EFLAGS)) \
kono
parents:
diff changeset
403 TCR(PC_CFI(SET_PC)) \
kono
parents:
diff changeset
404 TCR(".cfi_return_column " S(REGNO_SET_PC))
kono
parents:
diff changeset
405
kono
parents:
diff changeset
406 /* Trampoline body block
kono
parents:
diff changeset
407 --------------------- */
kono
parents:
diff changeset
408
kono
parents:
diff changeset
409 #define SIGTRAMP_BODY \
kono
parents:
diff changeset
410 CR("") \
kono
parents:
diff changeset
411 TCR("# Allocate frame and save the non-volatile") \
kono
parents:
diff changeset
412 TCR("# registers we're going to modify") \
kono
parents:
diff changeset
413 TCR("pushl %ebp") \
kono
parents:
diff changeset
414 TCR("movl %esp, %ebp") \
kono
parents:
diff changeset
415 TCR("pushl %edi") \
kono
parents:
diff changeset
416 TCR("subl $24, %esp") \
kono
parents:
diff changeset
417 TCR("# Setup CFA_REG = context, which we'll retrieve as our CFA value") \
kono
parents:
diff changeset
418 TCR("movl 24(%ebp), %edi") \
kono
parents:
diff changeset
419 TCR("# Call the real handler. The signo, siginfo and sigcontext") \
kono
parents:
diff changeset
420 TCR("# arguments are the same as those we received") \
kono
parents:
diff changeset
421 TCR("movl 16(%ebp), %eax") \
kono
parents:
diff changeset
422 TCR("movl %eax, 8(%esp)") \
kono
parents:
diff changeset
423 TCR("movl 12(%ebp), %eax") \
kono
parents:
diff changeset
424 TCR("movl %eax, 4(%esp)") \
kono
parents:
diff changeset
425 TCR("movl 8(%ebp), %eax") \
kono
parents:
diff changeset
426 TCR("movl %eax, (%esp)") \
kono
parents:
diff changeset
427 TCR("call *20(%ebp)") \
kono
parents:
diff changeset
428 TCR("# Restore our callee-saved items, release our frame and return") \
kono
parents:
diff changeset
429 TCR("popl %edi") \
kono
parents:
diff changeset
430 TCR("leave") \
kono
parents:
diff changeset
431 TCR("ret")
kono
parents:
diff changeset
432
kono
parents:
diff changeset
433 #elif defined (__x86_64__)
kono
parents:
diff changeset
434
kono
parents:
diff changeset
435 #define COMMON_CFI(REG) \
kono
parents:
diff changeset
436 ".cfi_offset " S(REGNO_##REG) "," S(REG_##REG)
kono
parents:
diff changeset
437
kono
parents:
diff changeset
438 #define CFI_COMMON_REGS \
kono
parents:
diff changeset
439 CR("# CFI for common registers\n") \
kono
parents:
diff changeset
440 TCR(COMMON_CFI(R15)) \
kono
parents:
diff changeset
441 TCR(COMMON_CFI(R14)) \
kono
parents:
diff changeset
442 TCR(COMMON_CFI(R13)) \
kono
parents:
diff changeset
443 TCR(COMMON_CFI(R12)) \
kono
parents:
diff changeset
444 TCR(COMMON_CFI(R11)) \
kono
parents:
diff changeset
445 TCR(COMMON_CFI(R10)) \
kono
parents:
diff changeset
446 TCR(COMMON_CFI(R9)) \
kono
parents:
diff changeset
447 TCR(COMMON_CFI(R8)) \
kono
parents:
diff changeset
448 TCR(COMMON_CFI(RDI)) \
kono
parents:
diff changeset
449 TCR(COMMON_CFI(RSI)) \
kono
parents:
diff changeset
450 TCR(COMMON_CFI(RBP)) \
kono
parents:
diff changeset
451 TCR(COMMON_CFI(RSP)) \
kono
parents:
diff changeset
452 TCR(COMMON_CFI(RBX)) \
kono
parents:
diff changeset
453 TCR(COMMON_CFI(RDX)) \
kono
parents:
diff changeset
454 TCR(COMMON_CFI(RCX)) \
kono
parents:
diff changeset
455 TCR(COMMON_CFI(RAX)) \
kono
parents:
diff changeset
456 TCR(COMMON_CFI(RPC)) \
kono
parents:
diff changeset
457 TCR(".cfi_return_column " S(REGNO_RPC))
kono
parents:
diff changeset
458
kono
parents:
diff changeset
459 /* Trampoline body block
kono
parents:
diff changeset
460 --------------------- */
kono
parents:
diff changeset
461
kono
parents:
diff changeset
462 #define SIGTRAMP_BODY \
kono
parents:
diff changeset
463 CR("") \
kono
parents:
diff changeset
464 TCR("# Allocate frame and save the non-volatile") \
kono
parents:
diff changeset
465 TCR("# registers we're going to modify") \
kono
parents:
diff changeset
466 TCR("subq $8, %rsp") \
kono
parents:
diff changeset
467 TCR("# Setup CFA_REG = context, which we'll retrieve as our CFA value") \
kono
parents:
diff changeset
468 TCR("movq %r8, %r15") \
kono
parents:
diff changeset
469 TCR("# Call the real handler. The signo, siginfo and sigcontext") \
kono
parents:
diff changeset
470 TCR("# arguments are the same as those we received") \
kono
parents:
diff changeset
471 TCR("call *%rcx") \
kono
parents:
diff changeset
472 TCR("# This part should never be executed") \
kono
parents:
diff changeset
473 TCR("addq $8, %rsp") \
kono
parents:
diff changeset
474 TCR("ret")
kono
parents:
diff changeset
475
kono
parents:
diff changeset
476 #else
kono
parents:
diff changeset
477 Not_implemented;
kono
parents:
diff changeset
478 #endif /* CFI_COMMON_REGS and SIGTRAMP_BODY */
kono
parents:
diff changeset
479
kono
parents:
diff changeset
480 /* Symbol definition block
kono
parents:
diff changeset
481 ----------------------- */
kono
parents:
diff changeset
482
kono
parents:
diff changeset
483 #ifdef __x86_64__
kono
parents:
diff changeset
484 #define FUNC_ALIGN TCR(".p2align 4,,15")
kono
parents:
diff changeset
485 #else
kono
parents:
diff changeset
486 #define FUNC_ALIGN
kono
parents:
diff changeset
487 #endif
kono
parents:
diff changeset
488
kono
parents:
diff changeset
489 #define SIGTRAMP_START(SYM) \
kono
parents:
diff changeset
490 CR("# " S(SYM) " cfi trampoline") \
kono
parents:
diff changeset
491 TCR(".type " S(SYM) ", "FUNCTION) \
kono
parents:
diff changeset
492 CR("") \
kono
parents:
diff changeset
493 FUNC_ALIGN \
kono
parents:
diff changeset
494 CR(S(SYM) ":") \
kono
parents:
diff changeset
495 TCR(".cfi_startproc") \
kono
parents:
diff changeset
496 TCR(".cfi_signal_frame")
kono
parents:
diff changeset
497
kono
parents:
diff changeset
498 /* Symbol termination block
kono
parents:
diff changeset
499 ------------------------ */
kono
parents:
diff changeset
500
kono
parents:
diff changeset
501 #define SIGTRAMP_END(SYM) \
kono
parents:
diff changeset
502 CR(".cfi_endproc") \
kono
parents:
diff changeset
503 TCR(".size " S(SYM) ", .-" S(SYM))
kono
parents:
diff changeset
504
kono
parents:
diff changeset
505 /*----------------------------
kono
parents:
diff changeset
506 -- And now, the real code --
kono
parents:
diff changeset
507 ---------------------------- */
kono
parents:
diff changeset
508
kono
parents:
diff changeset
509 /* Text section start. The compiler isn't aware of that switch. */
kono
parents:
diff changeset
510
kono
parents:
diff changeset
511 asm (".text\n"
kono
parents:
diff changeset
512 TCR(".align 2"));