]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | /* Copyright 2009-2024 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 | ||
cf141dd8 AB |
26 | callq setup_signal_handler |
27 | ||
28 | nop | |
29 | ||
1903f0e6 DE |
30 | /***********************************************/ |
31 | ||
35669430 DE |
32 | /* test call/ret */ |
33 | ||
34 | .global test_call | |
35 | test_call: | |
36 | call test_call_subr | |
37 | nop | |
38 | .global test_ret_end | |
39 | test_ret_end: | |
40 | nop | |
41 | ||
1903f0e6 DE |
42 | /***********************************************/ |
43 | ||
35669430 DE |
44 | /* test abs-jmp/rep-ret */ |
45 | ||
46 | test_abs_jmp_setup: | |
47 | mov $test_abs_jmp_return,%rdx | |
48 | push %rdx | |
49 | mov $test_abs_jmp_subr,%rdx | |
50 | .global test_abs_jmp | |
51 | test_abs_jmp: | |
52 | jmp *%rdx | |
53 | test_abs_jmp_return: | |
54 | nop | |
55 | .global test_rep_ret_end | |
56 | test_rep_ret_end: | |
57 | nop | |
58 | ||
1903f0e6 DE |
59 | /***********************************************/ |
60 | ||
35669430 DE |
61 | /* test syscall */ |
62 | ||
63 | .global test_syscall | |
64 | mov $0x27,%eax /* getpid */ | |
65 | test_syscall: | |
66 | syscall | |
67 | nop | |
68 | test_syscall_end: | |
69 | nop | |
70 | ||
1903f0e6 DE |
71 | /***********************************************/ |
72 | ||
73 | /* Test stepping over int3. | |
74 | The prefixes are pointless, but it's possible, so we exercise it. */ | |
75 | ||
76 | nop | |
77 | .global test_int3 | |
78 | test_int3: | |
79 | repz | |
80 | repz | |
81 | int3 | |
82 | nop | |
83 | .global test_int3_end | |
84 | test_int3_end: | |
85 | nop | |
86 | ||
87 | /***********************************************/ | |
88 | ||
35669430 DE |
89 | /* test rip-relative |
90 | GDB picks a spare register to hold the rip-relative address. | |
91 | Exercise all the possibilities (rax-rdi, sans rsp). */ | |
92 | ||
93 | .global test_rip_rax | |
94 | test_rip_rax: | |
95 | add answer(%rip),%rax | |
96 | .global test_rip_rax_end | |
97 | test_rip_rax_end: | |
98 | nop | |
99 | ||
100 | .global test_rip_rbx | |
101 | test_rip_rbx: | |
102 | add answer(%rip),%rbx | |
103 | .global test_rip_rbx_end | |
104 | test_rip_rbx_end: | |
105 | nop | |
106 | ||
107 | .global test_rip_rcx | |
108 | test_rip_rcx: | |
109 | add answer(%rip),%rcx | |
110 | .global test_rip_rcx_end | |
111 | test_rip_rcx_end: | |
112 | nop | |
113 | ||
114 | .global test_rip_rdx | |
115 | test_rip_rdx: | |
116 | add answer(%rip),%rdx | |
117 | .global test_rip_rdx_end | |
118 | test_rip_rdx_end: | |
119 | nop | |
120 | ||
121 | .global test_rip_rbp | |
122 | test_rip_rbp: | |
123 | add answer(%rip),%rbp | |
124 | .global test_rip_rbp_end | |
125 | test_rip_rbp_end: | |
126 | nop | |
127 | ||
128 | .global test_rip_rsi | |
129 | test_rip_rsi: | |
130 | add answer(%rip),%rsi | |
131 | .global test_rip_rsi_end | |
132 | test_rip_rsi_end: | |
133 | nop | |
134 | ||
135 | .global test_rip_rdi | |
136 | test_rip_rdi: | |
137 | add answer(%rip),%rdi | |
138 | .global test_rip_rdi_end | |
139 | test_rip_rdi_end: | |
140 | nop | |
141 | ||
cf141dd8 AB |
142 | .global test_jmp |
143 | test_jmp: | |
144 | jmpq *jmp_dest(%rip) | |
145 | nop | |
146 | .global test_jmp_end | |
147 | test_jmp_end: | |
148 | nop | |
149 | ||
35669430 DE |
150 | /* skip over test data */ |
151 | jmp done | |
152 | ||
153 | /* test rip-relative data */ | |
154 | ||
155 | answer: .8byte 42 | |
156 | ||
cf141dd8 AB |
157 | jmp_dest: |
158 | .8byte test_jmp_end | |
159 | ||
1903f0e6 DE |
160 | /***********************************************/ |
161 | ||
35669430 DE |
162 | /* all done */ |
163 | ||
164 | done: | |
165 | mov $0,%rdi | |
166 | call exit | |
167 | hlt | |
168 | ||
169 | /***********************************************/ | |
170 | ||
171 | /* subroutine to help test call/ret */ | |
172 | ||
173 | test_call_subr: | |
174 | nop | |
175 | .global test_call_end | |
176 | test_call_end: | |
177 | nop | |
178 | ||
179 | .global test_ret | |
180 | test_ret: | |
181 | ret | |
182 | ||
1903f0e6 DE |
183 | /***********************************************/ |
184 | ||
35669430 DE |
185 | /* subroutine to help test abs-jmp/rep-ret */ |
186 | ||
187 | test_abs_jmp_subr: | |
188 | nop | |
189 | .global test_abs_jmp_end | |
190 | test_abs_jmp_end: | |
191 | nop | |
192 | ||
193 | .global test_rep_ret | |
194 | test_rep_ret: | |
195 | repz | |
196 | ret | |
0f2cd53c | 197 | .section .note.GNU-stack,"",@progbits |