2000-10-21 15:16:18 +08:00
|
|
|
#include <dlfcn.h>
|
|
|
|
#include <mcheck.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
int
|
|
|
|
main (void)
|
|
|
|
{
|
|
|
|
void *h[2];
|
|
|
|
int fail;
|
|
|
|
int (*fp) (void);
|
|
|
|
|
|
|
|
mtrace ();
|
|
|
|
|
|
|
|
h[0] = dlopen ("ltglobmod1.so", RTLD_LAZY);
|
2004-04-22 02:58:31 +08:00
|
|
|
if (h[0] == NULL)
|
2000-10-21 15:16:18 +08:00
|
|
|
{
|
2022-06-08 21:25:26 +08:00
|
|
|
printf ("%s: cannot open %s: %s\n",
|
2000-10-21 15:16:18 +08:00
|
|
|
__FUNCTION__, "ltglobmod1.so", dlerror ());
|
|
|
|
exit (EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
h[1] = dlopen ("ltglobmod2.so", RTLD_LAZY);
|
2004-04-22 02:58:31 +08:00
|
|
|
if (h[1] == NULL)
|
2000-10-21 15:16:18 +08:00
|
|
|
{
|
2022-06-08 21:25:26 +08:00
|
|
|
printf ("%s: cannot open %s: %s\n",
|
2000-10-21 15:16:18 +08:00
|
|
|
__FUNCTION__, "ltglobmod2.so", dlerror ());
|
|
|
|
exit (EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
puts ("loaded \"ltglobmod1.so\" without RTLD_GLOBAL");
|
|
|
|
|
|
|
|
fp = dlsym (h[1], "foo");
|
|
|
|
if (fp == NULL)
|
|
|
|
{
|
2022-06-08 21:25:26 +08:00
|
|
|
printf ("cannot get address of `foo': %s\n", dlerror ());
|
2000-10-21 15:16:18 +08:00
|
|
|
exit (EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
fail = fp ();
|
|
|
|
|
|
|
|
puts ("back in main");
|
|
|
|
|
|
|
|
dlclose (h[1]);
|
|
|
|
dlclose (h[0]);
|
|
|
|
|
|
|
|
return fail;
|
|
|
|
}
|