Commit | Line | Data |
---|---|---|
d9311bfa AT |
1 | /* Common target dependent code for GNU/Linux on ARM systems. |
2 | ||
618f726f | 3 | Copyright (C) 1999-2016 Free Software Foundation, Inc. |
d9311bfa AT |
4 | |
5 | This file is part of GDB. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 3 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
19 | ||
20 | #include "common-defs.h" | |
21 | #include "arch/arm.h" | |
22 | #include "arm-linux.h" | |
23 | ||
24 | /* Calculate the offset from stack pointer of the pc register on the stack | |
25 | in the case of a sigreturn or sigreturn_rt syscall. */ | |
26 | int | |
27 | arm_linux_sigreturn_next_pc_offset (unsigned long sp, | |
28 | unsigned long sp_data, | |
29 | unsigned long svc_number, | |
30 | int is_sigreturn) | |
31 | { | |
32 | /* Offset of R0 register. */ | |
33 | int r0_offset = 0; | |
34 | /* Offset of PC register. */ | |
35 | int pc_offset = 0; | |
36 | ||
37 | if (is_sigreturn) | |
38 | { | |
39 | if (sp_data == ARM_NEW_SIGFRAME_MAGIC) | |
40 | r0_offset = ARM_UCONTEXT_SIGCONTEXT + ARM_SIGCONTEXT_R0; | |
41 | else | |
42 | r0_offset = ARM_SIGCONTEXT_R0; | |
43 | } | |
44 | else | |
45 | { | |
46 | if (sp_data == sp + ARM_OLD_RT_SIGFRAME_SIGINFO) | |
47 | r0_offset = ARM_OLD_RT_SIGFRAME_UCONTEXT; | |
48 | else | |
49 | r0_offset = ARM_NEW_RT_SIGFRAME_UCONTEXT; | |
50 | ||
51 | r0_offset += ARM_UCONTEXT_SIGCONTEXT + ARM_SIGCONTEXT_R0; | |
52 | } | |
53 | ||
54 | pc_offset = r0_offset + INT_REGISTER_SIZE * ARM_PC_REGNUM; | |
55 | ||
56 | return pc_offset; | |
57 | } |