Back to index

glibc  2.9
Functions
tstcxaatexit.c File Reference
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>

Go to the source code of this file.

Functions

void *__dso_handle __attribute__ ((__weak__))
int main (void)

Function Documentation

void* __dso_handle __attribute__ ( (__weak__)  )
int main ( void  )

Definition at line 26 of file tstcxaatexit.c.

{
  const char fname[] = "modcxaatexit.so";
  void *h;
  void (*fp) (void *);
  int v = 0;

  if (&__dso_handle == NULL)
    {
      puts ("__dso_handle not available, cannot perform the test");
      exit (0);
    }

  h = dlopen (fname, RTLD_LAZY);
  if (h == NULL)
    {
      printf ("cannot open \"%s\": %s\n", fname, dlerror ());
      exit (1);
    }

  fp = dlsym (h, "bar");
  if (fp == NULL)
    {
      printf ("cannot find \"bar\": %s\n", dlerror ());
      exit (1);
    }

  fp (&v);

  if (dlclose (h) != 0)
    {
      printf ("cannot close \"%s\": %s\n", fname, dlerror ());
      exit (1);
    }

  if (v != 1)
    {
      puts ("module unload didn't change `v'");
      exit (1);
    }

  puts ("finishing now");

  return 0;
}

Here is the call graph for this function: