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