summaryrefslogtreecommitdiff
path: root/test/ldso
diff options
context:
space:
mode:
Diffstat (limited to 'test/ldso')
-rw-r--r--test/ldso/.cvsignore5
-rw-r--r--test/ldso/Makefile48
-rw-r--r--test/ldso/dltest.c42
-rw-r--r--test/ldso/howdy.c24
-rw-r--r--test/ldso/libtest.c16
5 files changed, 57 insertions, 78 deletions
diff --git a/test/ldso/.cvsignore b/test/ldso/.cvsignore
index aac695f97..7232c47f9 100644
--- a/test/ldso/.cvsignore
+++ b/test/ldso/.cvsignore
@@ -1,5 +1,4 @@
dltest
-libhowdy.so
dltest2
-dlttest
-dlttest2
+libtest.so
+libtest2.so
diff --git a/test/ldso/Makefile b/test/ldso/Makefile
index 1414a34e8..bfd8444c7 100644
--- a/test/ldso/Makefile
+++ b/test/ldso/Makefile
@@ -1,6 +1,6 @@
# Makefile for uClibc
#
-# Copyright (C) 2000,2001 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2003 Erik Andersen <andersen@uclibc.org>
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU Library General Public License as published by the Free
@@ -19,44 +19,26 @@
TESTDIR=../
include $(TESTDIR)/Rules.mak
-all: dltest2 dltest libhowdy.so run
-all: dlttest dlttest2 dltest2 dltest libhowdy.so run
+all: 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
+dltest: dltest.c
+ $(CC) $(CFLAGS) -DLIBNAME="\"./libtest.so\"" dltest.c -ldl -lpthread -o dltest
-dltest2: dltest2.c
- $(CC) $(CFLAGS) dltest2.c -o dltest2 -ldl
- ./dltest2
-
-dltest.o: dltest.c
- $(CC) $(CFLAGS) -c dltest.c -o dltest.o
-
-howdy.o: howdy.c
- $(CC) $(CFLAGS) -fPIC -c howdy.c -o howdy.o
-
-libhowdy.so: howdy.o
- $(CC) $(CFLAGS) -shared -o libhowdy.so -Wl,-soname,libhowdy.so howdy.o
+libtest.so: libtest.c
+ $(CC) $(CFLAGS) -fPIC -shared -Wl,-soname,libtest.so libtest.c -o libtest.so
-dltest: dltest.o
- $(CC) $(CFLAGS) -o dltest dltest.o -ldl
+# Second time, directly link libtest2.so with libpthread
+dltest2: dltest.c
+ $(CC) $(CFLAGS) -DLIBNAME="\"./libtest2.so\"" dltest.c -ldl -lpthread -o dltest2
-dlttest: dlttest.o
- $(CC) $(CFLAGS) -o dlttest dlttest.o -ldl -lpthread
+libtest2.so: libtest.c
+ $(CC) $(CFLAGS) -fPIC -shared -Wl,-soname,libtest2.so libtest.c -o libtest2.so -lpthread
-dlttest2: dlttest2.o
- $(CC) $(CFLAGS) -o dlttest2 dlttest2.o -ldl -lpthread
-
-run: dltest dlttest dlttest2 libhowdy.so
- @echo Running dltest
+run: dltest libtest.so dltest2 libtest2.so
+ ./dltest2
./dltest
- @echo Running dlttest
- ./dlttest
- @echo Running dlttest2
- ./dlttest2
clean:
- rm -f *.o *.so dltest2 dltest core libhowdy.so dlttest dlttest2
+ rm -f *.o dltest dltest2 libtest.so libtest2.so
+
diff --git a/test/ldso/dltest.c b/test/ldso/dltest.c
index 676e1ae55..244f3b76b 100644
--- a/test/ldso/dltest.c
+++ b/test/ldso/dltest.c
@@ -2,38 +2,44 @@
#include <stdlib.h>
#include <stdio.h>
#include <dlfcn.h>
-
-extern void _dlinfo();
-
-int main(int argc, char **argv) {
- void *handle;
- int (*myhowdy)(const char *s);
- char *error;
+#include <stdint.h>
#ifdef __UCLIBC__
- _dlinfo(); /* not supported by ld.so.2 */
+extern void _dlinfo(void);
#endif
- handle = dlopen ("./libhowdy.so", RTLD_LAZY);
+int main(int argc, char **argv)
+{
+ int ret = EXIT_SUCCESS;
+ void *handle;
+ void (*mydltest)(void *value1, void *value2);
+ char *error;
+ uint32_t *value1, *value2;
+ handle = dlopen (LIBNAME, RTLD_LAZY);
if (!handle) {
- fputs (dlerror(), stderr);
+ fprintf(stderr, "Could not open ./libtest.so: %s\n", dlerror());
exit(1);
}
- myhowdy = dlsym(handle, "howdy");
+ mydltest = dlsym(handle, "dltest");
if ((error = dlerror()) != NULL) {
- fputs(error, stderr);
+ fprintf(stderr, "Could not locate symbol 'dltest': %s\n", error);
exit(1);
}
- myhowdy("hello world!\n");
-
-#ifdef __UCLIBC__
- _dlinfo(); /* not supported by ld.so.2 */
-#endif
+ mydltest(&value1, &value2);
+ printf("dltest: __pthread_return_0=%p\n", value1);
+ printf("dltest: pthread_self=%p\n", value2);
+ if (value1 == value2) {
+ ret = EXIT_FAILURE;
+ printf("dltest: values should NOT be equal Weak values resolved incorrectly!\n");
+ } else {
+ printf("dltest: weak symbols resoved correctly.\n");
+ }
dlclose(handle);
- return EXIT_SUCCESS;
+ return ret;
}
+
diff --git a/test/ldso/howdy.c b/test/ldso/howdy.c
deleted file mode 100644
index e2724068e..000000000
--- a/test/ldso/howdy.c
+++ /dev/null
@@ -1,24 +0,0 @@
-#include <pthread.h>
-#include <stdio.h>
-
-extern int __pthread_return_0 (void);
-
-int howdy(const char *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");
-}
-
-void __attribute__((destructor)) howdy_dtor(void)
-{
- printf("I am the libhowdy destructor!\n");
-}
-
-
-
diff --git a/test/ldso/libtest.c b/test/ldso/libtest.c
new file mode 100644
index 000000000..cdb37403d
--- /dev/null
+++ b/test/ldso/libtest.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+#include <pthread.h>
+#include <stdint.h>
+
+extern int __pthread_return_0(void);
+
+void dltest(uint32_t **value1, uint32_t **value2)
+{
+ *value1 = (uint32_t *) __pthread_return_0;
+ *value2 = (uint32_t *) pthread_self;
+#if 0
+ printf("dltest: __pthread_return_0=%p\n", __pthread_return_0);
+ printf("dltest: pthread_self=%p\n", pthread_self);
+#endif
+}
+