| 1 |
// Test that __orc_rt_macho_jit_dlopen and __orc_rt_macho_jit_dlclose work as |
| 2 |
// expected for a straightforward dlopen; dlclose sequence: first the |
| 3 |
// constructors should be run, then destructors. |
| 4 |
// |
| 5 |
// RUN: %clang -c -o %t.inits.o %p/Inputs/standalone-ctor-and-cxa-atexit-dtor.S |
| 6 |
// RUN: %clang -c -o %t.test.o %s |
| 7 |
// RUN: %llvm_jitlink \ |
| 8 |
// RUN: -alias Platform:_dlopen=___orc_rt_macho_jit_dlopen \ |
| 9 |
// RUN: -alias Platform:_dlclose=___orc_rt_macho_jit_dlclose \ |
| 10 |
// RUN: %t.test.o -jd inits %t.inits.o -lmain | FileCheck %s |
| 11 |
|
| 12 |
// CHECK: entering main |
| 13 |
// CHECK-NEXT: constructor |
| 14 |
// CHECK-NEXT: destructor |
| 15 |
// CHECK-NEXT: leaving main |
| 16 |
|
| 17 |
int printf(const char * restrict format, ...); |
| 18 |
void *dlopen(const char* path, int mode); |
| 19 |
int dlclose(void *handle); |
| 20 |
|
| 21 |
int main(int argc, char *argv[]) { |
| 22 |
printf("entering main\n"); |
| 23 |
void *H = dlopen("inits", 0); |
| 24 |
if (!H) { |
| 25 |
printf("failed\n"); |
| 26 |
return -1; |
| 27 |
} |
| 28 |
if (dlclose(H) == -1) { |
| 29 |
printf("failed\n"); |
| 30 |
return -1; |
| 31 |
} |
| 32 |
printf("leaving main\n"); |
| 33 |
return 0; |
| 34 |
} |