aarch64-pseudo-unwind-asm.S revision 1.1 1 1.1 christos /* Copyright 2018-2024 Free Software Foundation, Inc.
2 1.1 christos
3 1.1 christos This file is part of GDB.
4 1.1 christos
5 1.1 christos This program is free software; you can redistribute it and/or modify
6 1.1 christos it under the terms of the GNU General Public License as published by
7 1.1 christos the Free Software Foundation; either version 3 of the License, or
8 1.1 christos (at your option) any later version.
9 1.1 christos
10 1.1 christos This program is distributed in the hope that it will be useful,
11 1.1 christos but WITHOUT ANY WARRANTY; without even the implied warranty of
12 1.1 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 1.1 christos GNU General Public License for more details.
14 1.1 christos
15 1.1 christos You should have received a copy of the GNU General Public License
16 1.1 christos along with this program. If not, see <http://www.gnu.org/licenses/>. */
17 1.1 christos
18 1.1 christos .section .note.GNU-stack,"",%progbits
19 1.1 christos
20 1.1 christos .data
21 1.1 christos value_callee:
22 1.1 christos .quad 0x2021222324252627
23 1.1 christos value_caller:
24 1.1 christos .quad 0x1011121314151617
25 1.1 christos
26 1.1 christos .text
27 1.1 christos .global callee
28 1.1 christos callee:
29 1.1 christos /* Standard prologue:
30 1.1 christos - push fp (x29) and lr (x30) to the stack.
31 1.1 christos - mov sp to fp */
32 1.1 christos .cfi_startproc
33 1.1 christos stp x29, x30, [sp, -16]!
34 1.1 christos .cfi_def_cfa 29, 16
35 1.1 christos .cfi_offset 29, -16
36 1.1 christos .cfi_offset 30, -8
37 1.1 christos mov x29, sp
38 1.1 christos
39 1.1 christos /* Save caller's x19 value on the stack. */
40 1.1 christos .cfi_offset 19, -32
41 1.1 christos str x19, [sp, -16]!
42 1.1 christos
43 1.1 christos /* Put our own x19 value. */
44 1.1 christos adr x0, value_callee
45 1.1 christos ldr x19, [x0]
46 1.1 christos
47 1.1 christos break_here_asm:
48 1.1 christos
49 1.1 christos /* Restore caller's x19 value. */
50 1.1 christos ldr x19, [sp], 16
51 1.1 christos
52 1.1 christos /* Standard epilogue:
53 1.1 christos - pop fp (x29) and lr (x30) from the stack */
54 1.1 christos ldp x29, x30, [sp], 16
55 1.1 christos ret
56 1.1 christos .cfi_endproc
57 1.1 christos
58 1.1 christos
59 1.1 christos .global caller
60 1.1 christos caller:
61 1.1 christos /* Standard prologue. */
62 1.1 christos .cfi_startproc
63 1.1 christos stp x29, x30, [sp, -16]!
64 1.1 christos .cfi_def_cfa 29, 16
65 1.1 christos .cfi_offset x29, -16
66 1.1 christos .cfi_offset x30, -8
67 1.1 christos add x29, sp, 0
68 1.1 christos
69 1.1 christos /* Put our own x19 value. */
70 1.1 christos adr x0, value_caller
71 1.1 christos ldr x19, [x0]
72 1.1 christos
73 1.1 christos /* Call callee. */
74 1.1 christos bl callee
75 1.1 christos
76 1.1 christos /* Store our x19 value in x0 to return it. */
77 1.1 christos mov x0, x19
78 1.1 christos
79 1.1 christos /* Standard epilogue. */
80 1.1 christos ldp x29, x30, [sp], 16
81 1.1 christos ret
82 1.1 christos .cfi_endproc
83