summaryrefslogtreecommitdiff
path: root/test/ldso
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2002-08-27 19:38:14 +0000
committerEric Andersen <andersen@codepoet.org>2002-08-27 19:38:14 +0000
commita74fc341b922f38161d10a9470b63ad537e13f07 (patch)
tree38fd28fd134269bc9266be0ae25a1a006515ccd3 /test/ldso
parent345b9927e608fd92e6231ef803b940afd6e6558c (diff)
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
Diffstat (limited to 'test/ldso')
-rw-r--r--test/ldso/.cvsignore2
-rw-r--r--test/ldso/Makefile21
-rw-r--r--test/ldso/dlttest.c45
-rw-r--r--test/ldso/howdy.c11
4 files changed, 74 insertions, 5 deletions
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 <pthread.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <dlfcn.h>
+
+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 <pthread.h>
#include <stdio.h>
+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");
}