Blame elf/reldep7.c

Packit 6c4009
#include <dlfcn.h>
Packit 6c4009
#include <stdio.h>
Packit 6c4009
#include <stdlib.h>
Packit 6c4009
Packit 6c4009
int
Packit 6c4009
main (void)
Packit 6c4009
{
Packit 6c4009
  void *h1;
Packit 6c4009
  void *h2;
Packit 6c4009
  void *mod1_bar, *mod2_bar;
Packit 6c4009
Packit 6c4009
  h1 = dlopen ("reldep7mod1.so", RTLD_GLOBAL | RTLD_LAZY);
Packit 6c4009
  if (h1 == NULL)
Packit 6c4009
    {
Packit 6c4009
      printf ("cannot open reldep7mod1.so: %s\n", dlerror ());
Packit 6c4009
      exit (1);
Packit 6c4009
    }
Packit 6c4009
Packit 6c4009
  h2 = dlopen ("reldep7mod2.so", RTLD_GLOBAL | RTLD_LAZY);
Packit 6c4009
  if (h2 == NULL)
Packit 6c4009
    {
Packit 6c4009
      printf ("cannot open reldep7mod1.so: %s\n", dlerror ());
Packit 6c4009
      exit (1);
Packit 6c4009
    }
Packit 6c4009
Packit 6c4009
  mod1_bar = dlsym (h1, "mod1_bar");
Packit 6c4009
  if (mod1_bar == NULL)
Packit 6c4009
    {
Packit 6c4009
      printf ("cannot get address of \"mod1_bar\": %s\n", dlerror ());
Packit 6c4009
      exit (1);
Packit 6c4009
    }
Packit 6c4009
Packit 6c4009
  mod2_bar = dlsym (h2, "mod2_bar");
Packit 6c4009
  if (mod2_bar == NULL)
Packit 6c4009
    {
Packit 6c4009
      printf ("cannot get address of \"mod2_bar\": %s\n", dlerror ());
Packit 6c4009
      exit (1);
Packit 6c4009
    }
Packit 6c4009
Packit 6c4009
  printf ("%d\n", ((int (*) (void)) mod1_bar) ());
Packit 6c4009
  printf ("%d\n", ((int (*) (void)) mod2_bar) ());
Packit 6c4009
Packit 6c4009
  if (dlclose (h1) != 0)
Packit 6c4009
    {
Packit 6c4009
      printf ("closing h1 failed: %s\n", dlerror ());
Packit 6c4009
      exit (1);
Packit 6c4009
    }
Packit 6c4009
Packit 6c4009
  printf ("%d\n", ((int (*) (void)) mod2_bar) ());
Packit 6c4009
Packit 6c4009
  if (dlclose (h2) != 0)
Packit 6c4009
    {
Packit 6c4009
      printf ("closing h2 failed: %s\n", dlerror ());
Packit 6c4009
      exit (1);
Packit 6c4009
    }
Packit 6c4009
Packit 6c4009
  return 0;
Packit 6c4009
}