| 1 |
// Test that the runtime correctly interposes ___cxa_atexit. |
| 2 |
// |
| 3 |
// RUN: %clang -c -o %t %s |
| 4 |
// RUN: %llvm_jitlink %t |
| 5 |
|
| 6 |
.section __TEXT,__text,regular,pure_instructions |
| 7 |
.build_version macos, 11, 0 sdk_version 11, 3 |
| 8 |
|
| 9 |
// OnExit destructor resets the test result override to zero. |
| 10 |
.globl __ZN6OnExitD1Ev |
| 11 |
.weak_def_can_be_hidden __ZN6OnExitD1Ev |
| 12 |
.p2align 4, 0x90 |
| 13 |
__ZN6OnExitD1Ev: |
| 14 |
xorl %edi, %edi |
| 15 |
jmp _llvm_jitlink_setTestResultOverride |
| 16 |
|
| 17 |
// main registers the atexit and sets the test result to one. |
| 18 |
.globl _main |
| 19 |
.p2align 4, 0x90 |
| 20 |
_main: |
| 21 |
pushq %rbp |
| 22 |
movq %rsp, %rbp |
| 23 |
|
| 24 |
movq __ZN6OnExitD1Ev@GOTPCREL(%rip), %rdi |
| 25 |
leaq _onExit(%rip), %rsi |
| 26 |
leaq ___dso_handle(%rip), %rdx |
| 27 |
callq ___cxa_atexit |
| 28 |
|
| 29 |
movl $1, %edi |
| 30 |
callq _llvm_jitlink_setTestResultOverride |
| 31 |
xorl %eax, %eax |
| 32 |
popq %rbp |
| 33 |
retq |
| 34 |
|
| 35 |
.globl _onExit |
| 36 |
.zerofill __DATA,__common,_onExit,1,0 |
| 37 |
|
| 38 |
.subsections_via_symbols |