From 2a272e8265d3109faedcb4ee6b8b93f49c52b228 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Fri, 16 Aug 2002 08:02:17 +0000 Subject: Demonstrate that dlopen() RTLD_NOW is currently broken. -Erik --- test/ldso/.cvsignore | 1 + test/ldso/Makefile | 8 ++++++-- test/ldso/dltest2.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 test/ldso/dltest2.c (limited to 'test') diff --git a/test/ldso/.cvsignore b/test/ldso/.cvsignore index e144aa0db..d837b46a4 100644 --- a/test/ldso/.cvsignore +++ b/test/ldso/.cvsignore @@ -1,2 +1,3 @@ dltest libhowdy.so +dltest2 diff --git a/test/ldso/Makefile b/test/ldso/Makefile index 57b4a1fa6..3d2a47ad9 100644 --- a/test/ldso/Makefile +++ b/test/ldso/Makefile @@ -20,7 +20,11 @@ TESTDIR=../ include $(TESTDIR)/Rules.mak CFLAGS+=--uclibc-ctors -all: dltest libhowdy.so run +all: dltest2 dltest libhowdy.so run + +dltest2: dltest.c + $(CC) $(CFLAGS) dltest2.c -o dltest2 -ldl + ./dltest2 dltest.o: dltest.c $(CC) $(CFLAGS) -c dltest.c -o dltest.o @@ -39,4 +43,4 @@ run: dltest libhowdy.so ./dltest clean: - rm -f *.o *.so dltest core libhowdy.so + rm -f *.o *.so dltest2 dltest core libhowdy.so 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 +#include +#include +#include +#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; +} -- cgit v1.2.3