45eeb9b17daf0cd716c2bf6f2928099f2084af57
[binutils-gdb.git] / gdb / testsuite / gdb.arch / amd64-disp-step.S
1 /* Copyright 2009 Free Software Foundation, Inc.
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
26 /* test call/ret */
27
28 .global test_call
29 test_call:
30 call test_call_subr
31 nop
32 .global test_ret_end
33 test_ret_end:
34 nop
35
36 /* test abs-jmp/rep-ret */
37
38 test_abs_jmp_setup:
39 mov $test_abs_jmp_return,%rdx
40 push %rdx
41 mov $test_abs_jmp_subr,%rdx
42 .global test_abs_jmp
43 test_abs_jmp:
44 jmp *%rdx
45 test_abs_jmp_return:
46 nop
47 .global test_rep_ret_end
48 test_rep_ret_end:
49 nop
50
51 /* test syscall */
52
53 .global test_syscall
54 mov $0x27,%eax /* getpid */
55 test_syscall:
56 syscall
57 nop
58 test_syscall_end:
59 nop
60
61 /* test rip-relative
62 GDB picks a spare register to hold the rip-relative address.
63 Exercise all the possibilities (rax-rdi, sans rsp). */
64
65 .global test_rip_rax
66 test_rip_rax:
67 add answer(%rip),%rax
68 .global test_rip_rax_end
69 test_rip_rax_end:
70 nop
71
72 .global test_rip_rbx
73 test_rip_rbx:
74 add answer(%rip),%rbx
75 .global test_rip_rbx_end
76 test_rip_rbx_end:
77 nop
78
79 .global test_rip_rcx
80 test_rip_rcx:
81 add answer(%rip),%rcx
82 .global test_rip_rcx_end
83 test_rip_rcx_end:
84 nop
85
86 .global test_rip_rdx
87 test_rip_rdx:
88 add answer(%rip),%rdx
89 .global test_rip_rdx_end
90 test_rip_rdx_end:
91 nop
92
93 .global test_rip_rbp
94 test_rip_rbp:
95 add answer(%rip),%rbp
96 .global test_rip_rbp_end
97 test_rip_rbp_end:
98 nop
99
100 .global test_rip_rsi
101 test_rip_rsi:
102 add answer(%rip),%rsi
103 .global test_rip_rsi_end
104 test_rip_rsi_end:
105 nop
106
107 .global test_rip_rdi
108 test_rip_rdi:
109 add answer(%rip),%rdi
110 .global test_rip_rdi_end
111 test_rip_rdi_end:
112 nop
113
114 /* skip over test data */
115 jmp done
116
117 /* test rip-relative data */
118
119 answer: .8byte 42
120
121 /* all done */
122
123 done:
124 mov $0,%rdi
125 call exit
126 hlt
127
128 /***********************************************/
129
130 /* subroutine to help test call/ret */
131
132 test_call_subr:
133 nop
134 .global test_call_end
135 test_call_end:
136 nop
137
138 .global test_ret
139 test_ret:
140 ret
141
142 /* subroutine to help test abs-jmp/rep-ret */
143
144 test_abs_jmp_subr:
145 nop
146 .global test_abs_jmp_end
147 test_abs_jmp_end:
148 nop
149
150 .global test_rep_ret
151 test_rep_ret:
152 repz
153 ret