brintos

brintos / llvm-project-archived public Read only

0
0
Text · 515 B · 711471b Raw
23 lines · cpp
1#include <dlfcn.h>2#include <stdio.h>3 4int main(int argc, char const *argv[]) {5 6#if defined(__APPLE__)7  const char *libother_name = "libother.dylib";8#else9  const char *libother_name = "libother.so";10#endif11 12  printf("before dlopen\n"); // breakpoint 113  void *handle = dlopen(libother_name, RTLD_NOW);14  int (*foo)(int) = (int (*)(int))dlsym(handle, "foo");15  foo(12);16 17  printf("before dlclose\n"); // breakpoint 218  dlclose(handle);19  printf("after dlclose\n"); // breakpoint 320 21  return 0; // breakpoint 122}23