diff options
author | Eric Andersen <andersen@codepoet.org> | 2002-08-16 08:02:17 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2002-08-16 08:02:17 +0000 |
commit | 2a272e8265d3109faedcb4ee6b8b93f49c52b228 (patch) | |
tree | ff25e80d384bef2ea9330124107f94fe0c791dd5 /test/ldso/dltest2.c | |
parent | 9f8c3d23d00790b1b41587697f94890058ebf8f5 (diff) |
Demonstrate that dlopen() RTLD_NOW is currently broken.
-Erik
Diffstat (limited to 'test/ldso/dltest2.c')
-rw-r--r-- | test/ldso/dltest2.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/test/ldso/dltest2.c b/test/ldso/dltest2.c new file mode 100644 index 000000000..066c37202 --- /dev/null +++ b/test/ldso/dltest2.c @@ -0,0 +1,50 @@ +#include <fcntl.h> +#include <stdlib.h> +#include <stdio.h> +#include <dlfcn.h> +#include "thread_db.h" + +extern void _dlinfo(); + +int main(int argc, char **argv) { + void *handle; + td_err_e (*td_init_p) (void); + + fprintf(stderr, "Attempting to dlopen() libthread_db.so with RTLD_NOW\n"); + handle = dlopen ("libthread_db.so", RTLD_NOW); + if (!handle) { + fputs (dlerror(), stderr); + exit(1); + } + + td_init_p = dlsym (handle, "td_init"); + if (td_init_p == NULL) { + fprintf(stderr, "yipe! td_init() failed!\n"); + return EXIT_FAILURE; + } +#if 0 //def __UCLIBC__ + _dlinfo(); /* not supported by ld.so.2 */ +#endif + dlclose(handle); + + + fprintf(stderr, "Attempting to dlopen() libthread_db.so with RTLD_LAZY\n"); + handle = dlopen ("libthread_db.so", RTLD_LAZY); + if (!handle) { + fputs (dlerror(), stderr); + exit(1); + } + + td_init_p = dlsym (handle, "td_init"); + if (td_init_p == NULL) { + fprintf(stderr, "yipe! td_init() failed!"); + return EXIT_FAILURE; + } +#if 0 //def __UCLIBC__ + _dlinfo(); /* not supported by ld.so.2 */ +#endif + dlclose(handle); + + fprintf(stderr, "Everything worked as expected.\n"); + return EXIT_SUCCESS; +} |