aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/gna/issue1623/load.c
blob: 5e45b3a707f95ff996613d02ff17d97587dd7548 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char** argv) {

  void* h = dlopen(argv[1], RTLD_LAZY);
  if (!h){
    fprintf(stderr, "dlopen: %s\n", dlerror());
    exit(1);
  }

  typedef int main_t(int, char**);

  main_t* entry = (main_t*)dlsym(h, "entry");
  if (!entry){
    fprintf(stderr, "dlsym: %s\n", dlerror());
    exit(2);
  }

  printf("Call entry\n");
  printf("Return from entry: %d\n", entry(0, NULL));

  dlclose(h);

  return 0;

}