about summary refs log tree commit diff
path: root/elf/loadfail.c
blob: 60deb7737b670de8fd45e6060cf151f92f3eac20 (plain) (blame)
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 <error.h>
#include <stdio.h>
#include <stdlib.h>

int
main (void)
{
  void *h;

  if (dlopen ("testobj1.so", RTLD_GLOBAL | RTLD_NOW) == NULL
      || dlopen ("testobj1.so", RTLD_GLOBAL | RTLD_NOW) == NULL
      || dlopen ("testobj2.so", RTLD_GLOBAL | RTLD_NOW) == NULL
      || dlopen ("testobj3.so", RTLD_GLOBAL | RTLD_NOW) == NULL
      || dlopen ("testobj4.so", RTLD_GLOBAL | RTLD_NOW) == NULL
      || dlopen ("testobj5.so", RTLD_GLOBAL | RTLD_NOW) == NULL)
    error (EXIT_FAILURE, 0, "failed to load shared object: %s", dlerror ());

  h = dlopen ("failobj.so", RTLD_GLOBAL | RTLD_NOW);

  printf ("h = %p, %s\n", h, h == NULL ? "ok" : "fail");

  return h != NULL;
}

int
foo (int a)
{
  return 10;
}