| 1 | /* |
| 2 | Copyright 2009, 2010, 2011 Free Software Foundation, Inc. |
| 3 | |
| 4 | This program is free software; you can redistribute it and/or modify |
| 5 | it under the terms of the GNU General Public License as published by |
| 6 | the Free Software Foundation; either version 3 of the License, or |
| 7 | (at your option) any later version. |
| 8 | |
| 9 | This program is distributed in the hope that it will be useful, |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | GNU General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU General Public License |
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | */ |
| 17 | |
| 18 | /* Compile with "gcc -nostdlib dw2-restore.S" */ |
| 19 | |
| 20 | .text |
| 21 | .globl _start |
| 22 | .func _start |
| 23 | _start: call foo |
| 24 | mov $0,%rax |
| 25 | ret |
| 26 | .endfunc |
| 27 | |
| 28 | .func foo |
| 29 | foo: .cfi_startproc |
| 30 | push %rbp |
| 31 | .cfi_adjust_cfa_offset 8 |
| 32 | mov %rsp,%rbp |
| 33 | .cfi_def_cfa_register %rbp |
| 34 | |
| 35 | .cfi_remember_state |
| 36 | jmp 2f |
| 37 | |
| 38 | 1: mov %rbp,%rsp |
| 39 | .cfi_restore %rbp |
| 40 | pop %rbp |
| 41 | .cfi_adjust_cfa_offset -8 |
| 42 | .cfi_def_cfa_register %rsp |
| 43 | ret |
| 44 | |
| 45 | .cfi_restore_state |
| 46 | 2: movq $0,%rax |
| 47 | movq $0,(%rax) /* crash here */ |
| 48 | jmp 1b |
| 49 | .cfi_endproc |
| 50 | .endfunc |