]>
Commit | Line | Data |
---|---|---|
1 | /* Unwinder test program. | |
2 | ||
3 | Copyright 2006, 2007 Free Software Foundation, Inc. | |
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 2 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, write to the Free Software | |
19 | Foundation, Inc., 59 Temple Place - Suite 330, | |
20 | Boston, MA 02111-1307, USA. */ | |
21 | ||
22 | void tpcs_frame (void); | |
23 | ||
24 | int | |
25 | main (void) | |
26 | { | |
27 | tpcs_frame (); | |
28 | return 0; | |
29 | } | |
30 | ||
31 | /* Normally Thumb functions use r7 as the frame pointer. However, | |
32 | with the GCC option -mtpcs-frame, they may use fp instead. Make | |
33 | sure that the prologue analyzer can handle this. */ | |
34 | ||
35 | asm(".text\n" | |
36 | " .align 2\n" | |
37 | " .thumb_func\n" | |
38 | " .code 16\n" | |
39 | "tpcs_frame_1:\n" | |
40 | " sub sp, #16\n" | |
41 | " push {r7}\n" | |
42 | " add r7, sp, #20\n" | |
43 | " str r7, [sp, #8]\n" | |
44 | " mov r7, pc\n" | |
45 | " str r7, [sp, #16]\n" | |
46 | " mov r7, fp\n" | |
47 | " str r7, [sp, #4]\n" | |
48 | " mov r7, lr\n" | |
49 | " str r7, [sp, #12]\n" | |
50 | " add r7, sp, #16\n" | |
51 | " mov fp, r7\n" | |
52 | " mov r7, sl\n" | |
53 | " push {r7}\n" | |
54 | ||
55 | /* We'll set a breakpoint at this call. We can't hardcode a trap | |
56 | instruction; the right instruction to use varies too much. And | |
57 | we can't use a global label, because GDB will think that's the | |
58 | start of a new function. So, this slightly convoluted | |
59 | technique. */ | |
60 | ".Ltpcs:\n" | |
61 | " nop\n" | |
62 | ||
63 | " pop {r2}\n" | |
64 | " mov sl, r2\n" | |
65 | " pop {r7}\n" | |
66 | " pop {r1, r2}\n" | |
67 | " mov fp, r1\n" | |
68 | " mov sp, r2\n" | |
69 | " bx lr\n" | |
70 | ||
71 | " .align 2\n" | |
72 | " .type tpcs_offset, %object\n" | |
73 | "tpcs_offset:\n" | |
74 | " .word .Ltpcs - tpcs_frame_1\n" | |
75 | ||
76 | " .align 2\n" | |
77 | " .thumb_func\n" | |
78 | " .code 16\n" | |
79 | "tpcs_frame:\n" | |
80 | " sub sp, #16\n" | |
81 | " push {r7}\n" | |
82 | " add r7, sp, #20\n" | |
83 | " str r7, [sp, #8]\n" | |
84 | " mov r7, pc\n" | |
85 | " str r7, [sp, #16]\n" | |
86 | " mov r7, fp\n" | |
87 | " str r7, [sp, #4]\n" | |
88 | " mov r7, lr\n" | |
89 | " str r7, [sp, #12]\n" | |
90 | " add r7, sp, #16\n" | |
91 | " mov fp, r7\n" | |
92 | " mov r7, sl\n" | |
93 | " push {r7}\n" | |
94 | ||
95 | /* Clobber saved regs around the call. */ | |
96 | " mov r7, #0\n" | |
97 | " mov lr, r7\n" | |
98 | " bl tpcs_frame_1\n" | |
99 | ||
100 | " pop {r2}\n" | |
101 | " mov sl, r2\n" | |
102 | " pop {r7}\n" | |
103 | " pop {r1, r2, r3}\n" | |
104 | " mov fp, r1\n" | |
105 | " mov sp, r2\n" | |
106 | " mov lr, r3\n" | |
107 | " bx lr\n" | |
108 | ); |