Back to index

glibc  2.9
Functions | Variables
tst-dlmopen1mod.c File Reference
#include <dlfcn.h>
#include <stdio.h>
#include <gnu/lib-names.h>

Go to the source code of this file.

Functions

static void __attribute ((constructor)) const
int foo (Lmid_t ns2)

Variables

static int cnt

Function Documentation

static void __attribute ( (constructor)  ) const [static]

Definition at line 9 of file tst-dlmopen1mod.c.

{
  ++cnt;
}
int foo ( Lmid_t  ns2)

Definition at line 17 of file tst-dlmopen1mod.c.

{
  void *h = dlopen (LIBC_SO, RTLD_LAZY|RTLD_NOLOAD);
  if (h == NULL)
    {
      printf ("cannot get handle for %s: %s\n", LIBC_SO, dlerror ());
      return 1;
    }

  Lmid_t ns = -10;
  if (dlinfo (h, RTLD_DI_LMID, &ns) != 0)
    {
      printf ("dlinfo for %s in %s failed: %s\n",
             LIBC_SO, __func__, dlerror ());
      return 1;
    }

  if (ns != ns2)
    {
      printf ("namespace for %s not LM_ID_BASE\n", LIBC_SO);
      return 1;
    }

  if (dlclose (h) != 0)
    {
      printf ("dlclose for %s in %s failed: %s\n",
             LIBC_SO, __func__, dlerror ());
      return 1;
    }

  if (cnt == 0)
    {
      puts ("constructor did not run");
      return 1;
    }
  else if (cnt != 1)
    {
      puts ("constructor did not run exactly once");
      return 1;
    }

  return 0;
}

Here is the call graph for this function:


Variable Documentation

int cnt [static]

Definition at line 6 of file tst-dlmopen1mod.c.