Debian Codegraph @

compiler-rt/test/orc/TestCases/Darwin/x86-64/Inputs/dlopen-dlclose-x2.S

raw
1 // Runs a sequence of dlopen, dlclose, dlopen, dlclose on a library "inits".
2 // This is intended as a standard harness for testing constructor / destructor
3 // behavior in the context of a full dlclose and then re-dlopen'ing of the
4 // inits library.
5 //
6 // Compiled from:
7 //
8 // int main(int argc, char *argv[]) {
9 // printf("entering main\n");
10 // void *H = dlopen("inits", 0);
11 // if (!H) {
12 // printf("failed\n");
13 // return -1;
14 // }
15 // if (dlclose(H) == -1) {
16 // printf("failed\n");
17 // return -1;
18 // }
19 // H = dlopen("inits", 0);
20 // if (!H) {
21 // printf("failed\n");
22 // return -1;
23 // }
24 // if (dlclose(H) == -1) {
25 // printf("failed\n");
26 // return -1;
27 // }
28 // printf("leaving main\n");
29 // return 0;
30 //}
31
32 .section __TEXT,__text,regular,pure_instructions
33 .build_version macos, 13, 0 sdk_version 13, 0
34 .globl _main
35 .p2align 4, 0x90
36 _main:
37
38 pushq %r14
39 pushq %rbx
40 pushq %rax
41 leaq L_str(%rip), %rdi
42 callq _puts
43 leaq L_.str.1(%rip), %rdi
44 xorl %esi, %esi
45 callq _dlopen
46 movl $-1, %ebx
47 leaq L_str.8(%rip), %r14
48 testq %rax, %rax
49 je LBB0_4
50
51 movq %rax, %rdi
52 callq _dlclose
53 cmpl $-1, %eax
54 je LBB0_4
55
56 leaq L_.str.1(%rip), %rdi
57 xorl %esi, %esi
58 callq _dlopen
59 testq %rax, %rax
60 je LBB0_4
61
62 movq %rax, %rdi
63 callq _dlclose
64 xorl %ebx, %ebx
65 cmpl $-1, %eax
66 sete %bl
67 leaq L_str.8(%rip), %rax
68 leaq L_str.6(%rip), %r14
69 cmoveq %rax, %r14
70 negl %ebx
71 LBB0_4:
72 movq %r14, %rdi
73 callq _puts
74 movl %ebx, %eax
75 addq $8, %rsp
76 popq %rbx
77 popq %r14
78 retq
79
80 .section __TEXT,__cstring,cstring_literals
81 L_.str.1:
82 .asciz "inits"
83 L_str:
84 .asciz "entering main"
85 L_str.6:
86 .asciz "leaving main"
87 L_str.8:
88 .asciz "failed"
89
90 .subsections_via_symbols