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: A patch for the unversioned lookup


On Thu, May 03, 2001 at 08:39:40PM -0700, H . J . Lu wrote:
> On Thu, May 03, 2001 at 08:27:46PM -0700, Ulrich Drepper wrote:
> > "H . J . Lu" <hjl@lucon.org> writes:
> > 
> > > While working on the atexit related problem, I noticed 2 problems
> > > with the unversioned lookup:
> > 
> > I will not even look at this unless you provide examples.
> > 
> 
> I enclosed a testcase in
> 
> http://sources.redhat.com/ml/libc-alpha/2001-05/msg00021.html
> 
> The current glibc does
> 
> # make
> cc    -c -o foo.o foo.c
> cc -fPIC -c b.c
> cc -shared -o lib-b.so b.o
> cc -fPIC -c c0.c
> cc -Wl,-soname,lib-c.so -shared -o lib-c0.so c0.o
> cp lib-c0.so lib-c.so
> cc -o foo -Wl,-rpath,. foo.o lib-b.so lib-c.so
> cc -fPIC -c c1.c
> cc -Wl,-soname,lib-c.so -Wl,--version-script=c.map -shared -o lib-c1.so c1.o
> cc -fPIC -c c2.c
> cc -Wl,-soname,lib-c.so -Wl,--version-script=c.map -shared -o lib-c2.so c2.o
> ./foo
> bar
> cp lib-c1.so lib-c.so
> ./foo
> bar
> cp lib-c2.so lib-c.so
> ./foo
> bar
> 
> The last one should fail since
> 
> # objdump --dynamic-sym lib-c.so | grep bar
> 000000000000086c g    DF .text  000000000000002a  Base        _old_bar_1
> 0000000000000840 g    DF .text  000000000000002a  Base        _old_bar
> 000000000000086c g    DF .text  000000000000002a (VERS.1)     bar
> 0000000000000840 g    DF .text  000000000000002a (VERS.0)     bar
> 
> There are 2 versions of bar, but none of them is default. With my
> patch, I got
> 
> # /export/build/gnu/glibc/elf/ld-linux.so.2 ./foo
> ./foo: error while loading shared libraries: ./lib-b.so: undefined symbol: bar
> 
> Let me know if you have trouble getting my testcase.
> 
> Thanks.
> 
> 

That is incorrect. Here is a new one. I will send a patch for a new
testcase in glibc.


H.J.
----
2001-05-03  H.J. Lu  <hjl@gnu.org>

	* do-lookup.h (FCT): Fix the unversioned lookup against the
	nono-default version definition.

--- libc/elf/do-lookup.h.nodef	Tue Feb 27 22:22:10 2001
+++ libc/elf/do-lookup.h	Thu May  3 23:06:37 2001
@@ -125,13 +125,21 @@ FCT (const char *undef_name, unsigned lo
 	  if (verstab != NULL)
 	    {
 	      ElfW(Half) ndx = verstab[symidx] & 0x7fff;
-	      if (ndx > 2) /* map->l_versions[ndx].hash != 0) */
+	      if (ndx > 1) /* map->l_versions[ndx].hash != 0) */
 		{
-		  /* Don't accept hidden symbols.  */
-		  if ((verstab[symidx] & 0x8000) == 0 && num_versions++ == 0)
-		    /* No version so far.  */
-		    versioned_sym = sym;
-		  continue;
+		  if ((verstab[symidx] & 0x8000) == 0)
+		    {
+		      /* We found the default version.  */
+		      goto found_it;
+		    }
+		  else
+		    {
+		      /* We found a hidden symbol. Only one version is
+			 allowed.  */
+		      if (num_versions++ == 0)
+			versioned_sym = sym;
+		      continue;
+		    }
 		}
 	    }
 #endif


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