From d9ea262db5f34295c2ad4c42559faf958abccf1b Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Fri, 29 Jun 2001 22:48:24 +0000 Subject: Add a dlopen test --- test/ldso/dltest.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 test/ldso/dltest.c (limited to 'test/ldso/dltest.c') diff --git a/test/ldso/dltest.c b/test/ldso/dltest.c new file mode 100644 index 000000000..676e1ae55 --- /dev/null +++ b/test/ldso/dltest.c @@ -0,0 +1,39 @@ +#include +#include +#include +#include + +extern void _dlinfo(); + +int main(int argc, char **argv) { + void *handle; + int (*myhowdy)(const char *s); + char *error; + +#ifdef __UCLIBC__ + _dlinfo(); /* not supported by ld.so.2 */ +#endif + + handle = dlopen ("./libhowdy.so", RTLD_LAZY); + + if (!handle) { + fputs (dlerror(), stderr); + exit(1); + } + + myhowdy = dlsym(handle, "howdy"); + if ((error = dlerror()) != NULL) { + fputs(error, stderr); + exit(1); + } + + myhowdy("hello world!\n"); + +#ifdef __UCLIBC__ + _dlinfo(); /* not supported by ld.so.2 */ +#endif + + dlclose(handle); + + return EXIT_SUCCESS; +} -- cgit v1.2.3