|
Packit Service |
82fcde |
#include <dlfcn.h>
|
|
Packit Service |
82fcde |
#include <stdio.h>
|
|
Packit Service |
82fcde |
#include <stdlib.h>
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
extern int bar (void);
|
|
Packit Service |
82fcde |
extern int foo (void);
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
int
|
|
Packit Service |
82fcde |
foo (void)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
void *h;
|
|
Packit Service |
82fcde |
int res;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Load ltglobalmod1 in the global namespace. */
|
|
Packit Service |
82fcde |
h = dlopen ("ltglobmod1.so", RTLD_GLOBAL | RTLD_LAZY);
|
|
Packit Service |
82fcde |
if (h == NULL)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
printf ("%s: cannot open %s: %s",
|
|
Packit Service |
82fcde |
__FUNCTION__, "ltglobmod1.so", dlerror ());
|
|
Packit Service |
82fcde |
exit (EXIT_FAILURE);
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Call bar. This is undefined in the DSO. */
|
|
Packit Service |
82fcde |
puts ("about to call `bar'");
|
|
Packit Service |
82fcde |
fflush (stdout);
|
|
Packit Service |
82fcde |
res = bar ();
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
printf ("bar returned %d\n", res);
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
dlclose (h);
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
return res != 42;
|
|
Packit Service |
82fcde |
}
|