brintos

brintos / llvm-project-archived public Read only

0
0
Text · 956 B · fd17993 Raw
35 lines · c
1// Test that __orc_rt_coff_jit_dlopen and __orc_rt_coff_jit_dlclose work as2// expected for a straightforward dlopen; dlclose sequence: first the3// constructors should be run.4//5// RUN: %clang_cl -MD -c -o %t.inits.o %p/Inputs/standalone-dylib.c6// RUN: %clang_cl -MD -c -o %t.test.o %s7// RUN: %llvm_jitlink \8// RUN:   -alias Platform:dlopen=__orc_rt_coff_jit_dlopen \9// RUN:   -alias Platform:dlclose=__orc_rt_coff_jit_dlclose \10// RUN:   %t.test.o -jd inits %t.inits.o -lmain | FileCheck %s11 12// CHECK: entering main13// CHECK-NEXT: constructor14// CHECK-NEXT: destructor15// CHECK-NEXT: leaving main16 17#include <stdio.h>18void *dlopen(const char *path, int mode);19int dlclose(void *handle);20 21int 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}35