2000-09-16 11:08:30 +02:00
|
|
|
#include <dlfcn.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2000-11-29 01:04:54 +01:00
|
|
|
extern int found_in_mod1 (void);
|
2000-09-16 11:08:30 +02:00
|
|
|
int
|
|
|
|
found_in_mod1 (void)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-08-15 05:58:56 +02:00
|
|
|
extern int test_in_mod1 (int (*mainp)(int, char **));
|
2000-09-16 11:08:30 +02:00
|
|
|
int
|
2003-08-15 05:58:56 +02:00
|
|
|
test_in_mod1 (int (*mainp)(int, char **))
|
2000-09-16 11:08:30 +02:00
|
|
|
{
|
|
|
|
int (*ifp) (void);
|
|
|
|
void *p;
|
|
|
|
int result = 0;
|
|
|
|
|
|
|
|
/* Find function `main'. */
|
|
|
|
p = dlsym (RTLD_DEFAULT, "main");
|
|
|
|
if (p == NULL)
|
|
|
|
{
|
|
|
|
printf ("%s: main not found\n", __FILE__);
|
|
|
|
result = 1;
|
|
|
|
}
|
2003-08-15 05:58:56 +02:00
|
|
|
else if ((int (*)(int, char **))p != mainp)
|
2000-09-16 11:08:30 +02:00
|
|
|
{
|
|
|
|
printf ("%s: wrong address returned for main\n", __FILE__);
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
printf ("%s: main correctly found\n", __FILE__);
|
|
|
|
|
|
|
|
ifp = dlsym (RTLD_DEFAULT, "found_in_mod1");
|
|
|
|
if ((void *) ifp == NULL)
|
|
|
|
{
|
|
|
|
printf ("%s: found_in_mod1 not found\n", __FILE__);
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
else if (ifp () != 1)
|
|
|
|
{
|
|
|
|
printf ("%s: wrong address returned for found_in_mod1\n", __FILE__);
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
printf ("%s: found_in_mod1 correctly found\n", __FILE__);
|
|
|
|
|
|
|
|
ifp = dlsym (RTLD_DEFAULT, "found_in_mod2");
|
|
|
|
if ((void *) ifp == NULL)
|
|
|
|
{
|
|
|
|
printf ("%s: found_in_mod2 not found\n", __FILE__);
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
else if (ifp () != 2)
|
|
|
|
{
|
|
|
|
printf ("%s: wrong address returned for found_in_mod2\n", __FILE__);
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
printf ("%s: found_in_mod2 correctly found\n", __FILE__);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|