1 #===------------------------------------------------------------------------===#
3 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 # See https://llvm.org/LICENSE.txt for license information.
5 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 #===------------------------------------------------------------------------===#
9 # REQUIRES: target={{x86_64-.+-linux-gnu}}
11 # Inline assembly isn't supported by Memory Sanitizer
14 # RUN: %{build} -no-pie
17 # The following assembly is a translation of this code:
19 # _Unwind_Reason_Code callback(int, _Unwind_Action, long unsigned int,
20 # _Unwind_Exception*, _Unwind_Context*, void*) {
21 # return _Unwind_Reason_Code(0);
25 # asm(".cfi_remember_state\n\t");
26 # _Unwind_Exception exc;
27 # _Unwind_ForcedUnwind(&exc, callback, 0);
28 # asm(".cfi_restore_state\n\t");
31 # When unwinding, the CFI parser will stop parsing opcodes after the current PC,
32 # so in this case the DW_CFA_restore_state opcode will never be processed and,
33 # if the library doesn't clean up properly, the store allocated by
34 # DW_CFA_remember_state will be leaked.
36 # This test will fail when linked with an asan-enabled libunwind if the
37 # remembered state is leaked.
39 SIZEOF_UNWIND_EXCEPTION
= 32
46 .globl main # -- Begin function main
51 subq $
8, %rsp
# Adjust stack alignment
52 subq $SIZEOF_UNWIND_EXCEPTION
, %rsp
53 .cfi_def_cfa_offset 48
56 movabsq $callback
, %rsi
58 callq _Unwind_ForcedUnwind
61 addq $SIZEOF_UNWIND_EXCEPTION
, %rsp
62 addq $
8, %rsp
# Undo stack alignment adjustment
66 .size main, .Lfunc_end1-main