1// Test that the runtime correctly interposes atexit.
2//
3// REQUIRES: disabled
4// This test is disabled until a proper atexit interpose can be implemented:
5// the current one assumes that atexit is defined in the dylib that calls it,
6// which is not true in general. See
7// https://github.com/llvm/llvm-project/issues/74641.
8//
9// RUN: %clang -c -o %t %s
10// RUN: %llvm_jitlink %t
11
12 .text
13 .abiversion 2
14// on_exit_hook destructor resets the test result override to zero.
15 .globl on_exit_hook
16 .p2align 4
17 .type on_exit_hook,@function
18on_exit_hook:
19.Lfunc_begin0:
20.Lfunc_gep0:
21 addis 2, 12, .TOC.-.Lfunc_gep0@ha
22 addi 2, 2, .TOC.-.Lfunc_gep0@l
23.Lfunc_lep0:
24 .localentry on_exit_hook, .Lfunc_lep0-.Lfunc_gep0
25 mflr 0
26 stdu 1, -32(1)
27 std 0, 48(1)
28 li 3, 0
29 bl llvm_jitlink_setTestResultOverride
30 nop
31 addi 1, 1, 32
32 ld 0, 16(1)
33 mtlr 0
34 blr
35 .long 0
36 .quad 0
37.Lfunc_end0:
38 .size on_exit_hook, .Lfunc_end0-.Lfunc_begin0
39
40// main registers the atexit and sets the test result to one.
41 .globl main
42 .p2align 4
43 .type main,@function
44main:
45.Lfunc_begin1:
46.Lfunc_gep1:
47 addis 2, 12, .TOC.-.Lfunc_gep1@ha
48 addi 2, 2, .TOC.-.Lfunc_gep1@l
49.Lfunc_lep1:
50 .localentry main, .Lfunc_lep1-.Lfunc_gep1
51 mflr 0
52 stdu 1, -32(1)
53 std 0, 48(1)
54 addis 3, 2, on_exit_hook@toc@ha
55 addi 3, 3, on_exit_hook@toc@l
56 bl atexit
57 nop
58 li 3, 1
59 bl llvm_jitlink_setTestResultOverride
60 nop
61 li 3, 0
62 addi 1, 1, 32
63 ld 0, 16(1)
64 mtlr 0
65 blr
66 .long 0
67 .quad 0
68.Lfunc_end1:
69 .size main, .Lfunc_end1-.Lfunc_begin1
70

source code of compiler-rt/test/orc/TestCases/Linux/ppc64/trivial-atexit.S