1# REQUIRES: x86, linux 2# RUN: %{build} -target x86_64-unknown-linux-gnu 3# RUN: %{run} 4 5# The following assembly is a translation of this code: 6# 7# _Unwind_Reason_Code callback(int, _Unwind_Action, long unsigned int, 8# _Unwind_Exception*, _Unwind_Context*, void*) { 9# return _Unwind_Reason_Code(0); 10# } 11# 12# int main() { 13# asm(".cfi_remember_state\n\t"); 14# _Unwind_Exception exc; 15# _Unwind_ForcedUnwind(&exc, callback, 0); 16# asm(".cfi_restore_state\n\t"); 17# } 18# 19# When unwinding, the CFI parser will stop parsing opcodes after the current PC, 20# so in this case the DW_CFA_restore_state opcode will never be processed and, 21# if the library doesn't clean up properly, the store allocated by 22# DW_CFA_remember_state will be leaked. 23# 24# This test will fail when linked with an asan-enabled libunwind if the 25# remembered state is leaked. 26 27 SIZEOF_UNWIND_EXCEPTION = 32 28 29 .text 30callback: 31 xorl %eax, %eax 32 retq 33 34 .globl main # -- Begin function main 35 .p2align 4, 0x90 36 .type main,@function 37main: # @main 38 .cfi_startproc 39 subq $8, %rsp # Adjust stack alignment 40 subq $SIZEOF_UNWIND_EXCEPTION, %rsp 41 .cfi_def_cfa_offset 48 42 .cfi_remember_state 43 movq %rsp, %rdi 44 movabsq $callback, %rsi 45 xorl %edx, %edx 46 callq _Unwind_ForcedUnwind 47 .cfi_restore_state 48 xorl %eax, %eax 49 addq $SIZEOF_UNWIND_EXCEPTION, %rsp 50 addq $8, %rsp # Undo stack alignment adjustment 51 .cfi_def_cfa_offset 8 52 retq 53.Lfunc_end1: 54 .size main, .Lfunc_end1-main 55 .cfi_endproc 56 # -- End function 57