aboutsummaryrefslogtreecommitdiff
path: root/elf/reldepmod4.c
diff options
context:
space:
mode:
Diffstat (limited to 'elf/reldepmod4.c')
-rw-r--r--elf/reldepmod4.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/elf/reldepmod4.c b/elf/reldepmod4.c
new file mode 100644
index 0000000..7036af8
--- /dev/null
+++ b/elf/reldepmod4.c
@@ -0,0 +1,34 @@
+#include <dlfcn.h>
+#include <stdlib.h>
+
+int
+call_me (void)
+{
+ void *h;
+ int (*fp) (void);
+ int res;
+
+ h = dlopen ("reldepmod1.so", RTLD_LAZY);
+ if (h == NULL)
+ {
+ printf ("cannot open reldepmod1.so in %s: %s\n", __FILE__, dlerror ());
+ exit (1);
+ }
+
+ fp = dlsym (h, "foo");
+ if (fp == NULL)
+ {
+ printf ("cannot get address of foo in global scope: %s\n", dlerror ());
+ exit (1);
+ }
+
+ res = fp () - 42;
+
+ if (dlclose (h) != 0)
+ {
+ printf ("failure when closing h in %s: %s\n", __FILE__, dlerror ());
+ exit (1);
+ }
+
+ return res;
+}