From a74fc341b922f38161d10a9470b63ad537e13f07 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Tue, 27 Aug 2002 19:38:14 +0000 Subject: Semonstrate a problem where weak symbols referenced in shared libs are not being overridden when those same symbols _are_ overridden by other shared libs in the main app. Ick. -Erik --- test/ldso/.cvsignore | 2 ++ test/ldso/Makefile | 21 +++++++++++++++++++-- test/ldso/dlttest.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ test/ldso/howdy.c | 11 ++++++++--- 4 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 test/ldso/dlttest.c diff --git a/test/ldso/.cvsignore b/test/ldso/.cvsignore index d837b46a4..aac695f97 100644 --- a/test/ldso/.cvsignore +++ b/test/ldso/.cvsignore @@ -1,3 +1,5 @@ dltest libhowdy.so dltest2 +dlttest +dlttest2 diff --git a/test/ldso/Makefile b/test/ldso/Makefile index 2d3611222..9a750e8a3 100644 --- a/test/ldso/Makefile +++ b/test/ldso/Makefile @@ -21,6 +21,13 @@ include $(TESTDIR)/Rules.mak CFLAGS+=--uclibc-ctors all: dltest2 dltest libhowdy.so run +all: dlttest dlttest2 dltest2 dltest libhowdy.so run + +dlttest.o: dlttest.c + $(CC) $(CFLAGS) -c dlttest.c -o dlttest.o + +dlttest2.o: dlttest.c + $(CC) $(CFLAGS) -DFORCE -c dlttest.c -o dlttest2.o dltest2: dltest2.c $(CC) $(CFLAGS) dltest2.c -o dltest2 -ldl @@ -37,10 +44,20 @@ libhowdy.so: howdy.o dltest: dltest.o $(CC) $(CFLAGS) -o dltest dltest.o -ldl - -run: dltest libhowdy.so + +dlttest: dlttest.o + $(CC) $(CFLAGS) -o dlttest dlttest.o -ldl -lpthread + +dlttest2: dlttest2.o + $(CC) $(CFLAGS) -o dlttest2 dlttest2.o -ldl -lpthread + +run: dltest dlttest dlttest2 libhowdy.so @echo Running dltest ./dltest + @echo Running dlttest + ./dlttest + @echo Running dlttest2 + ./dlttest2 clean: rm -f *.o *.so dltest2 dltest core libhowdy.so diff --git a/test/ldso/dlttest.c b/test/ldso/dlttest.c new file mode 100644 index 000000000..591f5b56f --- /dev/null +++ b/test/ldso/dlttest.c @@ -0,0 +1,45 @@ +#include +#include +#include +#include +#include + +extern void _dlinfo(); +extern int __pthread_return_0 (void); +#undef __UCLIBC__ + +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); + } + +#ifdef FORCE + printf("main: __pthread_return_0 = %p\n", __pthread_return_0); +#endif + myhowdy("hello world!\n"); + +#ifdef __UCLIBC__ + _dlinfo(); /* not supported by ld.so.2 */ +#endif + + dlclose(handle); + + return EXIT_SUCCESS; +} diff --git a/test/ldso/howdy.c b/test/ldso/howdy.c index 343c81d7c..e2724068e 100644 --- a/test/ldso/howdy.c +++ b/test/ldso/howdy.c @@ -1,18 +1,23 @@ +#include #include +extern int __pthread_return_0 (void); + int howdy(const char *s) { - return printf("howdy: %s\n", s); + return printf("howdy: __pthread_return_0 = %p\n" + "howdy: pthread_cond_signal = %p\n", + __pthread_return_0, pthread_cond_signal); } void __attribute__((constructor)) howdy_ctor(void) { - printf("I am the libhowdy constructor!\n"); + printf("I am the libhowdy constructor!\n"); } void __attribute__((destructor)) howdy_dtor(void) { - printf("I am the libhowdy destructor!\n"); + printf("I am the libhowdy destructor!\n"); } -- cgit v1.2.3