This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [PATCH] Re: Changed shared library loading strategy on PPC, why?


On Wednesday 25 July 2001 13:42, Andreas Jaeger wrote:
> Franz Sirl <Franz.Sirl-kernel@lauterbach.com> writes:
> > At 08:34 25.07.2001, Andreas Jaeger wrote:
> >>Olaf Hering <olh@suse.de> writes:
> >> > On Tue, Jul 24, Andreas Jaeger wrote:
> >> >> Btw. Olaf is running a complete build of glibc and will tell the
> >> >> results later, but I'm convinced that this fixes the problems we
> >> >> encountered.
> >> >
> >> > I did a fresh build of binutils , glibc and rpm with the patch applied
> >> > and it works now.
> >>
> >>Since Geoff said previously for both patches:
> >> > Anyway, all the patches look fine to me.  It's only a heuristic,
> >> > it's known to break for various reasons, the important thing is that
> >> > it works most of the time.
> >>
> >>I'm going to commit this now since this version works better,
> >
> > Thanks. Is there a way to create a testcase for static binaries
> > accessing a shared lib?
>
> Just build a static binary that uses e.g. getpwuid.  Feel free to send
> patches,

Ok, here is a standalone testcase for this problem.

BTW, Jakub's gcc-3 patch is still missing in pre2.

Franz.

	* dlfcn/Makefile: Add new testcase tststatic.
	* dlfcn/tststatic.c: New testcase.
	* dlfcn/modstatic.c: Module code for tststatic.

Index: dlfcn/Makefile
===================================================================
RCS file: /cvs/glibc/libc/dlfcn/Makefile,v
retrieving revision 1.16
diff -u -p -u -p -r1.16 Makefile
--- dlfcn/Makefile	2001/07/06 04:54:45	1.16
+++ dlfcn/Makefile	2001/08/04 15:29:38
@@ -22,7 +22,7 @@ extra-libs	:= libdl
 libdl-routines	:= dlopen dlclose dlsym dlvsym dlerror dladdr eval
 distribute	:= dlopenold.c glreflib1.c glreflib2.c failtestmod.c eval.c \
 		   defaultmod1.c defaultmod2.c errmsg1mod.c modatexit.c \
-		   modcxaatexit.c
+		   modcxaatexit.c modstatic.c
 
 extra-libs-others := libdl
 
@@ -41,7 +41,13 @@ tests += tstatexit
 endif
 endif
 modules-names = glreflib1 glreflib2 failtestmod defaultmod1 defaultmod2 \
-		errmsg1mod modatexit modcxaatexit
+		errmsg1mod modatexit modcxaatexit modstatic
+ifeq (yesyes,$(build-static)$(build-shared))
+tests += tststatic
+tests-static = tststatic
+modules-names += modstatic
+tststatic-ENV = LD_LIBRARY_PATH=$(objpfx)
+endif
 extra-objs += $(modules-names:=.os) eval.os
 generated := $(modules-names:=.so)
 
@@ -79,6 +85,11 @@ $(objpfx)tstcxaatexit: $(libdl)
 $(objpfx)tstcxaatexit.out: $(objpfx)tstcxaatexit $(objpfx)modcxaatexit.so
 
 $(objpfx)modatexit.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a
+
+$(objpfx)tststatic: $(objpfx)/libdl.a
+$(objpfx)tststatic.out: $(objpfx)tststatic $(objpfx)modstatic.so
+
+$(objpfx)modstatic.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a
 
 # Depend on libc.so so a DT_NEEDED is generated in the shared objects.
 # This ensures they will load libc.so for needed symbols if loaded by
--- /dev/null	Wed Jul 25 15:50:10 2001
+++ dlfcn/tststatic.c	Sat Aug  4 07:46:57 2001
@@ -0,0 +1,34 @@
+#include <stdio.h>
+#include <dlfcn.h>
+
+int main (void) 
+{
+  void *handle;
+  int (*test)(int);
+  char *error;
+  int res;
+
+  handle = dlopen ("modstatic.so", RTLD_LAZY);
+  if (!handle) 
+    {
+      printf ("%s\n", dlerror());
+      exit(1);
+    }
+
+  test = dlsym(handle, "test");
+  if ((error = dlerror()) != NULL)  
+    {
+      
+      printf ("%s\n", error);
+      exit(1);
+    }
+
+  if ((res = (*test)(2)) != 4)
+    {
+      printf ("Got %i, expected 4\n", res);
+      exit (1);
+    }
+
+  dlclose(handle);
+  exit (0);
+}
--- /dev/null	Wed Jul 25 15:50:10 2001
+++ dlfcn/modstatic.c	Sat Aug  4 07:15:11 2001
@@ -0,0 +1,5 @@
+
+int test (int a)
+{
+  return a+a;
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]