|
Packit Service |
82fcde |
#include <dlfcn.h>
|
|
Packit Service |
82fcde |
#include <stdio.h>
|
|
Packit Service |
82fcde |
#include <malloc.h>
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
int
|
|
Packit Service |
82fcde |
main (void)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
#ifdef M_PERTURB
|
|
Packit Service |
82fcde |
mallopt (M_PERTURB, 0xaa);
|
|
Packit Service |
82fcde |
#endif
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
void *h;
|
|
Packit Service |
82fcde |
int (*fn) (int);
|
|
Packit Service |
82fcde |
h = dlopen ("unload4mod1.so", RTLD_LAZY);
|
|
Packit Service |
82fcde |
if (h == NULL)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
puts ("1st dlopen failed");
|
|
Packit Service |
82fcde |
return 1;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
fn = dlsym (h, "foo");
|
|
Packit Service |
82fcde |
if (fn == NULL)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
puts ("dlsym failed");
|
|
Packit Service |
82fcde |
return 1;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
int n = fn (10);
|
|
Packit Service |
82fcde |
if (n != 28)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
printf ("foo (10) returned %d != 28\n", n);
|
|
Packit Service |
82fcde |
return 1;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
dlclose (h);
|
|
Packit Service |
82fcde |
h = dlopen ("unload4mod3.so", RTLD_LAZY);
|
|
Packit Service |
82fcde |
fn = dlsym (h, "mod3fn2");
|
|
Packit Service |
82fcde |
if (fn == NULL)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
puts ("second dlsym failed");
|
|
Packit Service |
82fcde |
return 1;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
n = fn (10);
|
|
Packit Service |
82fcde |
if (n != 22)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
printf ("mod3fn2 (10) returned %d != 22\n", n);
|
|
Packit Service |
82fcde |
return 1;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
dlclose (h);
|
|
Packit Service |
82fcde |
return 0;
|
|
Packit Service |
82fcde |
}
|