summaryrefslogtreecommitdiff
path: root/elf/unload6.c
blob: 1efc7eb841dc40f9fec69f933470258f39f5ea9c (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
29
30
#include <dlfcn.h>
#include <stdio.h>

int
main (void)
{
  void *h = dlopen ("unload6mod1.so", RTLD_LAZY);
  if (h == NULL)
    {
      puts ("dlopen unload6mod1.so failed");
      return 1;
    }

  int (*fn) (int);
  fn = dlsym (h, "foo");
  if (fn == NULL)
    {
      puts ("dlsym failed");
      return 1;
    }

  int val = fn (16);
  if (val != 24)
    {
      printf ("foo returned %d != 24\n", val);
      return 1;
    }

  return 0;
}