Commit | Line | Data |
---|---|---|
32d0add0 | 1 | /* Copyright 2009-2015 Free Software Foundation, Inc. |
35669430 DE |
2 | |
3 | This program is free software; you can redistribute it and/or modify | |
4 | it under the terms of the GNU General Public License as published by | |
5 | the Free Software Foundation; either version 3 of the License, or | |
6 | (at your option) any later version. | |
7 | ||
8 | This program is distributed in the hope that it will be useful, | |
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | GNU General Public License for more details. | |
12 | ||
13 | You should have received a copy of the GNU General Public License | |
14 | along with this program. If not, see <http://www.gnu.org/licenses/>. | |
15 | ||
16 | This file is part of the gdb testsuite. | |
17 | It tests displaced stepping over various insns that require special | |
18 | handling. */ | |
19 | ||
20 | .text | |
21 | ||
22 | .global main | |
23 | main: | |
24 | nop | |
25 | ||
1903f0e6 DE |
26 | /***********************************************/ |
27 | ||
35669430 DE |
28 | /* test call/ret */ |
29 | ||
30 | .global test_call | |
31 | test_call: | |
32 | call test_call_subr | |
33 | nop | |
34 | .global test_ret_end | |
35 | test_ret_end: | |
36 | nop | |
37 | ||
1903f0e6 DE |
38 | /***********************************************/ |
39 | ||
35669430 DE |
40 | /* test abs-jmp/rep-ret */ |
41 | ||
42 | test_abs_jmp_setup: | |
43 | mov $test_abs_jmp_return,%rdx | |
44 | push %rdx | |
45 | mov $test_abs_jmp_subr,%rdx | |
46 | .global test_abs_jmp | |
47 | test_abs_jmp: | |
48 | jmp *%rdx | |
49 | test_abs_jmp_return: | |
50 | nop | |
51 | .global test_rep_ret_end | |
52 | test_rep_ret_end: | |
53 | nop | |
54 | ||
1903f0e6 DE |
55 | /***********************************************/ |
56 | ||
35669430 DE |
57 | /* test syscall */ |
58 | ||
59 | .global test_syscall | |
60 | mov $0x27,%eax /* getpid */ | |
61 | test_syscall: | |
62 | syscall | |
63 | nop | |
64 | test_syscall_end: | |
65 | nop | |
66 | ||
1903f0e6 DE |
67 | /***********************************************/ |
68 | ||
69 | /* Test stepping over int3. | |
70 | The prefixes are pointless, but it's possible, so we exercise it. */ | |
71 | ||
72 | nop | |
73 | .global test_int3 | |
74 | test_int3: | |
75 | repz | |
76 | repz | |
77 | int3 | |
78 | nop | |
79 | .global test_int3_end | |
80 | test_int3_end: | |
81 | nop | |
82 | ||
83 | /***********************************************/ | |
84 | ||
35669430 DE |
85 | /* test rip-relative |
86 | GDB picks a spare register to hold the rip-relative address. | |
87 | Exercise all the possibilities (rax-rdi, sans rsp). */ | |
88 | ||
89 | .global test_rip_rax | |
90 | test_rip_rax: | |
91 | add answer(%rip),%rax | |
92 | .global test_rip_rax_end | |
93 | test_rip_rax_end: | |
94 | nop | |
95 | ||
96 | .global test_rip_rbx | |
97 | test_rip_rbx: | |
98 | add answer(%rip),%rbx | |
99 | .global test_rip_rbx_end | |
100 | test_rip_rbx_end: | |
101 | nop | |
102 | ||
103 | .global test_rip_rcx | |
104 | test_rip_rcx: | |
105 | add answer(%rip),%rcx | |
106 | .global test_rip_rcx_end | |
107 | test_rip_rcx_end: | |
108 | nop | |
109 | ||
110 | .global test_rip_rdx | |
111 | test_rip_rdx: | |
112 | add answer(%rip),%rdx | |
113 | .global test_rip_rdx_end | |
114 | test_rip_rdx_end: | |
115 | nop | |
116 | ||
117 | .global test_rip_rbp | |
118 | test_rip_rbp: | |
119 | add answer(%rip),%rbp | |
120 | .global test_rip_rbp_end | |
121 | test_rip_rbp_end: | |
122 | nop | |
123 | ||
124 | .global test_rip_rsi | |
125 | test_rip_rsi: | |
126 | add answer(%rip),%rsi | |
127 | .global test_rip_rsi_end | |
128 | test_rip_rsi_end: | |
129 | nop | |
130 | ||
131 | .global test_rip_rdi | |
132 | test_rip_rdi: | |
133 | add answer(%rip),%rdi | |
134 | .global test_rip_rdi_end | |
135 | test_rip_rdi_end: | |
136 | nop | |
137 | ||
138 | /* skip over test data */ | |
139 | jmp done | |
140 | ||
141 | /* test rip-relative data */ | |
142 | ||
143 | answer: .8byte 42 | |
144 | ||
1903f0e6 DE |
145 | /***********************************************/ |
146 | ||
35669430 DE |
147 | /* all done */ |
148 | ||
149 | done: | |
150 | mov $0,%rdi | |
151 | call exit | |
152 | hlt | |
153 | ||
154 | /***********************************************/ | |
155 | ||
156 | /* subroutine to help test call/ret */ | |
157 | ||
158 | test_call_subr: | |
159 | nop | |
160 | .global test_call_end | |
161 | test_call_end: | |
162 | nop | |
163 | ||
164 | .global test_ret | |
165 | test_ret: | |
166 | ret | |
167 | ||
1903f0e6 DE |
168 | /***********************************************/ |
169 | ||
35669430 DE |
170 | /* subroutine to help test abs-jmp/rep-ret */ |
171 | ||
172 | test_abs_jmp_subr: | |
173 | nop | |
174 | .global test_abs_jmp_end | |
175 | test_abs_jmp_end: | |
176 | nop | |
177 | ||
178 | .global test_rep_ret | |
179 | test_rep_ret: | |
180 | repz | |
181 | ret |