1 // Test that the runtime correctly interposes ___cxa_atexit.
3 // RUN: %clang -c -o %t %s
4 // RUN: %llvm_jitlink %t
6 .section __TEXT,__text,regular,pure_instructions
7 .build_version macos, 12, 0 sdk_version 12, 0
9 # main registers the atexit and sets the test result to one.
10 .globl _main ; -- Begin function main
15 stp x29, x30, [sp, #16] ; 16-byte Folded Spill
16 add x29, sp, #16 ; =16
18 adrp x8, __ZGVZ4mainE6onExit@PAGE
19 add x8, x8, __ZGVZ4mainE6onExit@PAGEOFF
25 adrp x0, __ZGVZ4mainE6onExit@PAGE
26 add x0, x0, __ZGVZ4mainE6onExit@PAGEOFF
27 bl ___cxa_guard_acquire
30 adrp x0, __ZN6OnExitD1Ev@GOTPAGE
31 ldr x0, [x0, __ZN6OnExitD1Ev@GOTPAGEOFF]
32 adrp x1, __ZZ4mainE6onExit@PAGE
33 add x1, x1, __ZZ4mainE6onExit@PAGEOFF
34 adrp x2, ___dso_handle@PAGE
35 add x2, x2, ___dso_handle@PAGEOFF
37 adrp x0, __ZGVZ4mainE6onExit@PAGE
38 add x0, x0, __ZGVZ4mainE6onExit@PAGEOFF
39 bl ___cxa_guard_release
42 bl _llvm_jitlink_setTestResultOverride
44 ldp x29, x30, [sp, #16] ; 16-byte Folded Reload
49 # OnExit destructor resets the test result override to zero.
50 .globl __ZN6OnExitD1Ev ; -- Begin function _ZN6OnExitD1Ev
51 .weak_def_can_be_hidden __ZN6OnExitD1Ev
53 __ZN6OnExitD1Ev: ; @_ZN6OnExitD1Ev
56 stp x29, x30, [sp, #16] ; 16-byte Folded Spill
57 add x29, sp, #16 ; =16
60 str x0, [sp] ; 8-byte Folded Spill
62 ldr x0, [sp] ; 8-byte Folded Reload
63 ldp x29, x30, [sp, #16] ; 16-byte Folded Reload
67 .globl __ZN6OnExitD2Ev ; -- Begin function _ZN6OnExitD2Ev
68 .weak_def_can_be_hidden __ZN6OnExitD2Ev
70 __ZN6OnExitD2Ev: ; @_ZN6OnExitD2Ev
73 stp x29, x30, [sp, #16] ; 16-byte Folded Spill
74 add x29, sp, #16 ; =16
77 str x8, [sp] ; 8-byte Folded Spill
79 bl _llvm_jitlink_setTestResultOverride
80 ldr x0, [sp] ; 8-byte Folded Reload
81 ldp x29, x30, [sp, #16] ; 16-byte Folded Reload
85 .zerofill __DATA,__bss,__ZZ4mainE6onExit,1,0 ; @_ZZ4mainE6onExit
86 .zerofill __DATA,__bss,__ZGVZ4mainE6onExit,8,3 ; @_ZGVZ4mainE6onExit
87 .subsections_via_symbols