Last change
on this file was 2036, checked in by bird, 20 years ago |
Initial revision
|
-
Property cvs2svn:cvs-rev
set to
1.1
-
Property svn:eol-style
set to
native
-
Property svn:executable
set to
*
-
Property svn:keywords
set to
Author Date Id Revision
|
File size:
683 bytes
|
Line | |
---|
1 | #include <dlfcn.h>
|
---|
2 | #include <error.h>
|
---|
3 | #include <stdio.h>
|
---|
4 | #include <stdlib.h>
|
---|
5 |
|
---|
6 | int
|
---|
7 | main (void)
|
---|
8 | {
|
---|
9 | void *h;
|
---|
10 | int (*fp) (int);
|
---|
11 | int res;
|
---|
12 |
|
---|
13 | h = dlopen ("${ORIGIN}/testobj1.so", RTLD_LAZY);
|
---|
14 | if (h == NULL)
|
---|
15 | error (EXIT_FAILURE, 0, "while loading `%s': %s", "testobj1.so",
|
---|
16 | dlerror ());
|
---|
17 |
|
---|
18 | fp = dlsym (h, "obj1func1");
|
---|
19 | if (fp == NULL)
|
---|
20 | error (EXIT_FAILURE, 0, "getting `obj1func1' in `%s': %s",
|
---|
21 | "testobj1.so", dlerror ());
|
---|
22 |
|
---|
23 | res = fp (10);
|
---|
24 | printf ("fp(10) = %d\n", res);
|
---|
25 |
|
---|
26 | if (dlclose (h) != 0)
|
---|
27 | error (EXIT_FAILURE, 0, "while close `%s': %s",
|
---|
28 | "testobj1.so", dlerror ());
|
---|
29 |
|
---|
30 | return res != 42;
|
---|
31 | }
|
---|
32 |
|
---|
33 |
|
---|
34 | extern int foo (int a);
|
---|
35 | int
|
---|
36 | foo (int a)
|
---|
37 | {
|
---|
38 | return a + 10;
|
---|
39 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.