xref: /llvm-project/compiler-rt/test/orc/TestCases/Linux/x86-64/trivial-atexit.S (revision b4e19155171edf14412dc4132b7b10a84ac65fc5)
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// OnExit destructor resets the test result override to zero.
14	.section	.text._ZN6OnExitD2Ev,"axG",@progbits,_ZN6OnExitD2Ev,comdat
15	.p2align	4, 0x90
16	.type	_ZN6OnExitD2Ev,@function
17_ZN6OnExitD2Ev:                         # @_ZN6OnExitD2Ev
18	.cfi_startproc
19	xorl	%edi, %edi
20	jmp	llvm_jitlink_setTestResultOverride@PLT # TAILCALL
21	.cfi_endproc
22
23// main registers the atexit and sets the test result to one.
24	.globl main
25	.p2align	4, 0x90                         # -- Begin function main
26	.type	main,@function
27main:              # @main
28	.cfi_startproc
29# %bb.0:
30	movq	_ZN6OnExitD2Ev@GOTPCREL(%rip), %rdi
31	callq	atexit@PLT
32	movl	$1, %edi
33	callq	llvm_jitlink_setTestResultOverride@PLT
34	xorl	%eax, %eax
35	retq
36.Lfunc_end1:
37	.size	main, .Lfunc_end1-main
38	.cfi_endproc
39                                        # -- End function
40	.type	_ZL6onExit,@object              # @_ZL6onExit
41	.local	_ZL6onExit
42	.comm	_ZL6onExit,1,1
43