91 lines · plain
1// Runs a sequence of dlopen, dlclose, dlopen, dlclose on a library "inits".2// This is intended as a standard harness for testing constructor / destructor3// behavior in the context of a full dlclose and then re-dlopen'ing of the4// 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_instructions33 .build_version macos, 13, 0 sdk_version 13, 034 .globl _main35 .p2align 4, 0x9036_main:37 38 pushq %r1439 pushq %rbx40 pushq %rax41 leaq L_str(%rip), %rdi42 callq _puts43 leaq L_.str.1(%rip), %rdi44 xorl %esi, %esi45 callq _dlopen46 movl $-1, %ebx47 leaq L_str.8(%rip), %r1448 testq %rax, %rax49 je LBB0_450 51 movq %rax, %rdi52 callq _dlclose53 cmpl $-1, %eax54 je LBB0_455 56 leaq L_.str.1(%rip), %rdi57 xorl %esi, %esi58 callq _dlopen59 testq %rax, %rax60 je LBB0_461 62 movq %rax, %rdi63 callq _dlclose64 xorl %ebx, %ebx65 cmpl $-1, %eax66 sete %bl67 leaq L_str.8(%rip), %rax68 leaq L_str.6(%rip), %r1469 cmoveq %rax, %r1470 negl %ebx71LBB0_4:72 movq %r14, %rdi73 callq _puts74 movl %ebx, %eax75 addq $8, %rsp76 popq %rbx77 popq %r1478 retq79 80 .section __TEXT,__cstring,cstring_literals81L_.str.1:82 .asciz "inits"83L_str:84 .asciz "entering main"85L_str.6:86 .asciz "leaving main"87L_str.8:88 .asciz "failed"89 90.subsections_via_symbols91