|
Packit Service |
82fcde |
#include <dlfcn.h>
|
|
Packit Service |
82fcde |
#include <mcheck.h>
|
|
Packit Service |
82fcde |
#include <stdio.h>
|
|
Packit Service |
82fcde |
#include <stdlib.h>
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
typedef int (*fn)(void);
|
|
Packit Service |
82fcde |
#define CHUNKS 1024
|
|
Packit Service |
82fcde |
#define REPEAT 64
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
int
|
|
Packit Service |
82fcde |
main (void)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
void *h1;
|
|
Packit Service |
82fcde |
void *h2;
|
|
Packit Service |
82fcde |
fn **foopp;
|
|
Packit Service |
82fcde |
fn bar, baz;
|
|
Packit Service |
82fcde |
int i, j;
|
|
Packit Service |
82fcde |
int n;
|
|
Packit Service |
82fcde |
void *allocs[REPEAT][CHUNKS];
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
mtrace ();
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Open the two objects. */
|
|
Packit Service |
82fcde |
h1 = dlopen ("reldep6mod3.so", RTLD_LAZY);
|
|
Packit Service |
82fcde |
if (h1 == NULL)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
printf ("cannot open reldep6mod3.so: %s\n", dlerror ());
|
|
Packit Service |
82fcde |
exit (1);
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
foopp = dlsym (h1, "foopp");
|
|
Packit Service |
82fcde |
if (foopp == NULL)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
printf ("cannot get address of \"foopp\": %s\n", dlerror ());
|
|
Packit Service |
82fcde |
exit (1);
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
n = (**foopp) ();
|
|
Packit Service |
82fcde |
if (n != 20)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
printf ("(**foopp)() return %d, not return 20\n", n);
|
|
Packit Service |
82fcde |
exit (1);
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
h2 = dlopen ("reldep6mod4.so", RTLD_LAZY);
|
|
Packit Service |
82fcde |
if (h2 == NULL)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
printf ("cannot open reldep6mod4.so: %s\n", dlerror ());
|
|
Packit Service |
82fcde |
exit (1);
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
baz = dlsym (h2, "baz");
|
|
Packit Service |
82fcde |
if (baz == NULL)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
printf ("cannot get address of \"baz\": %s\n", dlerror ());
|
|
Packit Service |
82fcde |
exit (1);
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
if (baz () != 31)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
printf ("baz() did not return 31\n");
|
|
Packit Service |
82fcde |
exit (1);
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
if (dlclose (h1) != 0)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
printf ("closing h1 failed: %s\n", dlerror ());
|
|
Packit Service |
82fcde |
exit (1);
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Clobber memory. */
|
|
Packit Service |
82fcde |
for (i = 0; i < REPEAT; ++i)
|
|
Packit Service |
82fcde |
for (j = 0; j < CHUNKS; ++j)
|
|
Packit Service |
82fcde |
allocs[i][j] = calloc (1, j + 1);
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
bar = dlsym (h2, "bar");
|
|
Packit Service |
82fcde |
if (bar == NULL)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
printf ("cannot get address of \"bar\": %s\n", dlerror ());
|
|
Packit Service |
82fcde |
exit (1);
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
if (bar () != 40)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
printf ("bar() did not return 40\n");
|
|
Packit Service |
82fcde |
exit (1);
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
baz = dlsym (h2, "baz");
|
|
Packit Service |
82fcde |
if (baz == NULL)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
printf ("cannot get address of \"baz\": %s\n", dlerror ());
|
|
Packit Service |
82fcde |
exit (1);
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
if (baz () != 31)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
printf ("baz() did not return 31\n");
|
|
Packit Service |
82fcde |
exit (1);
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
for (i = 0; i < REPEAT; ++i)
|
|
Packit Service |
82fcde |
for (j = 0; j < CHUNKS; ++j)
|
|
Packit Service |
82fcde |
free (allocs[i][j]);
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
if (dlclose (h2) != 0)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
printf ("closing h2 failed: %s\n", dlerror ());
|
|
Packit Service |
82fcde |
exit (1);
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
return 0;
|
|
Packit Service |
82fcde |
}
|