[uClibc-cvs] uClibc/test/ldso libtest.c, NONE, 1.1 .cvsignore, 1.3, 1.4 Makefile, 1.11, 1.12 dltest.c, 1.1, 1.2 howdy.c, 1.3, NONE

Erik Andersen andersen at uclibc.org
Mon Sep 1 20:42:42 UTC 2003


Update of /var/cvs/uClibc/test/ldso
In directory winder:/tmp/cvs-serv15301

Modified Files:
	.cvsignore Makefile dltest.c 
Added Files:
	libtest.c 
Removed Files:
	howdy.c 
Log Message:
A better test for a dlopen problem with weak symbols, based
on a much improve test by mjn3.


Index: dltest.c
===================================================================
RCS file: /var/cvs/uClibc/test/ldso/dltest.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- dltest.c	29 Jun 2001 22:48:24 -0000	1.1
+++ dltest.c	1 Sep 2003 20:42:39 -0000	1.2
@@ -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;
 }
+

Index: .cvsignore
===================================================================
RCS file: /var/cvs/uClibc/test/ldso/.cvsignore,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- .cvsignore	27 Aug 2002 19:38:14 -0000	1.3
+++ .cvsignore	1 Sep 2003 20:42:39 -0000	1.4
@@ -1,5 +1,4 @@
 dltest
-libhowdy.so
 dltest2
-dlttest
-dlttest2
+libtest.so
+libtest2.so

Index: Makefile
===================================================================
RCS file: /var/cvs/uClibc/test/ldso/Makefile,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- Makefile	8 Nov 2002 03:33:50 -0000	1.11
+++ Makefile	1 Sep 2003 20:42:39 -0000	1.12
@@ -1,6 +1,6 @@
 # Makefile for uClibc
 #
-# Copyright (C) 2000,2001 Erik Andersen <andersen at uclibc.org>
+# Copyright (C) 2000-2003 Erik Andersen <andersen at 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
-
-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
-	./dltest2
-
-dltest.o: dltest.c
-	$(CC) $(CFLAGS) -c dltest.c -o dltest.o
+all: run
 
-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
+dltest: dltest.c
+	$(CC) $(CFLAGS) -DLIBNAME="\"./libtest.so\"" dltest.c -ldl -lpthread -o dltest
 
-dltest: dltest.o
-	$(CC) $(CFLAGS) -o dltest dltest.o -ldl
+libtest.so: libtest.c
+	$(CC) $(CFLAGS) -fPIC -shared -Wl,-soname,libtest.so libtest.c -o libtest.so
 
-dlttest: dlttest.o
-	$(CC) $(CFLAGS) -o dlttest dlttest.o -ldl -lpthread
+# Second time, directly link libtest2.so with libpthread
+dltest2: dltest.c
+	$(CC) $(CFLAGS) -DLIBNAME="\"./libtest2.so\"" dltest.c -ldl -lpthread -o dltest2
 
-dlttest2: dlttest2.o
-	$(CC) $(CFLAGS) -o dlttest2 dlttest2.o -ldl -lpthread
+libtest2.so: libtest.c
+	$(CC) $(CFLAGS) -fPIC -shared -Wl,-soname,libtest2.so libtest.c -o libtest2.so -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
+

--- NEW FILE: libtest.c ---
#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
}


--- howdy.c DELETED ---




More information about the uClibc-cvs mailing list