|
Packit Service |
82fcde |
#include <dlfcn.h>
|
|
Packit Service |
82fcde |
#include <error.h>
|
|
Packit Service |
82fcde |
#include <stdio.h>
|
|
Packit Service |
82fcde |
#include <stdlib.h>
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
int
|
|
Packit Service |
82fcde |
main (void)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
void *h;
|
|
Packit Service |
82fcde |
int (*fp) (int);
|
|
Packit Service |
82fcde |
int res;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
h = dlopen ("${ORIGIN}/testobj1.so", RTLD_LAZY);
|
|
Packit Service |
82fcde |
if (h == NULL)
|
|
Packit Service |
82fcde |
error (EXIT_FAILURE, 0, "while loading `%s': %s", "testobj1.so",
|
|
Packit Service |
82fcde |
dlerror ());
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
fp = dlsym (h, "obj1func1");
|
|
Packit Service |
82fcde |
if (fp == NULL)
|
|
Packit Service |
82fcde |
error (EXIT_FAILURE, 0, "getting `obj1func1' in `%s': %s",
|
|
Packit Service |
82fcde |
"testobj1.so", dlerror ());
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
res = fp (10);
|
|
Packit Service |
82fcde |
printf ("fp(10) = %d\n", res);
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
if (dlclose (h) != 0)
|
|
Packit Service |
82fcde |
error (EXIT_FAILURE, 0, "while close `%s': %s",
|
|
Packit Service |
82fcde |
"testobj1.so", dlerror ());
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
return res != 42;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
extern int foo (int a);
|
|
Packit Service |
82fcde |
int
|
|
Packit Service |
82fcde |
foo (int a)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
return a + 10;
|
|
Packit Service |
82fcde |
}
|