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 11:14:02PM -0700, H . J . Lu wrote:
> 
> That is incorrect. Here is a new one. I will send a patch for a new
> testcase in glibc.
> 

Here is the testcase for glibc.


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

	* elf/Makefile (distribute): Add tst-version.sh, version.map,
	versionobj0.c, versionobj1.c and versionobj2.c.
	(test-srcs): Add tst-version.
	(modules-names): Add versionobj1 and versionobj2.
	(tests): Also depend on $(objpfx)tst-version.out.
	$(objpfx)%.so: Also filter out versionobj1 and versionobj2.
	($(objpfx)versionobj0a.so): New target.
	($(objpfx)versionobj0b.so): New target.
	($(objpfx)versionobj1.so): New target.
	($(objpfx)versionobj2.so): New target.
	($(objpfx)versionobj.so): New target.
	($(objpfx)tst-version): New target.
	($(objpfx)tst-version.out): New target.

	* elf/tst-version.c: New file.
	* elf/tst-version.sh: New file.
	* elf/version.map: New file.
	* elf/versionobj0.c: New file.
	* elf/versionobj1.c: New file.
	* elf/versionobj2.c: New file.

--- libc/elf/Makefile.version	Sat Mar 24 21:04:33 2001
+++ libc/elf/Makefile	Fri May  4 00:23:43 2001
@@ -57,7 +57,9 @@ distribute	:= $(rtld-routines:=.c) dynam
 		   neededobj1.c neededobj2.c neededobj3.c neededobj4.c \
 		   neededobj5.c neededobj6.c firstobj.c \
 		   unload2mod.c unload2dep.c ltglobmod1.c ltglobmod2.c \
-		   testobj.h vismod.h globalmod1.c
+		   testobj.h vismod.h globalmod1.c \
+		   tst-version.sh version.map versionobj0.c \
+		   versionobj1.c versionobj2.c
 
 include ../Makeconfig
 
@@ -102,7 +104,7 @@ tests = loadtest restest1 preloadtest lo
 	reldep reldep2 reldep3 next $(tests-nodelete-$(have-z-nodelete)) \
 	$(tests-nodlopen-$(have-z-nodlopen)) neededtest neededtest2 \
 	neededtest3 neededtest4 unload2 lateglobal initfirst global
-test-srcs = tst-pathopt
+test-srcs = tst-pathopt tst-version
 tests-vis-yes = vismain
 tests-nodelete-yes = nodelete
 tests-nodlopen-yes = nodlopen
@@ -115,7 +117,8 @@ modules-names = testobj1 testobj2 testob
 		reldepmod1 reldepmod2 reldepmod3 reldepmod4 nextmod1 nextmod2 \
 		neededobj1 neededobj2 neededobj3 neededobj4 \
 		neededobj5 neededobj6 firstobj globalmod1 \
-		unload2mod unload2dep ltglobmod1 ltglobmod2 pathoptobj
+		unload2mod unload2dep ltglobmod1 ltglobmod2 pathoptobj \
+		versionobj1 versionobj2
 modules-vis-yes = vismod1 vismod2 vismod3
 modules-nodelete-yes = nodelmod1 nodelmod2 nodelmod3 nodelmod4
 modules-nodlopen-yes = nodlopenmod
@@ -247,7 +250,7 @@ generated += $(addsuffix .so,$(strip $(m
 
 ifeq (yes,$(build-shared))
 ifeq ($(cross-compiling),no)
-tests: $(objpfx)tst-pathopt.out
+tests: $(objpfx)tst-pathopt.out $(objpfx)tst-version.out
 endif
 endif
 
@@ -276,7 +279,10 @@ $(objpfx)firstobj.so: $(shared-thread-li
 $(objpfx)globalmod1.so: $(libdl)
 
 # filtmod1.so has a special rule
-$(filter-out $(objpfx)filtmod1.so, $(test-modules)): $(objpfx)%.so: $(objpfx)%.os
+$(filter-out $(objpfx)filtmod1.so \
+	     $(objpfx)versionobj1.so \
+	     $(objpfx)versionobj2.so, \
+	     $(test-modules)): $(objpfx)%.so: $(objpfx)%.os
 	$(build-module)
 
 $(objpfx)loadtest: $(libdl)
@@ -369,6 +375,41 @@ $(objpfx)filtmod1.so: $(objpfx)filtmod1.
 		  -Wl,-rpath-link=$(rpath-link) \
 		  $< -Wl,-F,$(objpfx)filtmod2.so
 $(objpfx)filter: $(objpfx)filtmod1.so
+
+$(objpfx)versionobj0a.so: $(objpfx)versionobj0.os
+	$(LINK.o) -shared -o $@ -B$(csu-objpfx) $(LDFLAGS.so) \
+		  -L$(subst :, -L,$(rpath-link)) \
+		  -Wl,-rpath-link=$(rpath-link) $<
+
+$(objpfx)versionobj0b.so: $(objpfx)versionobj0.os
+	$(LINK.o) -shared -o $@ -B$(csu-objpfx) $(LDFLAGS.so) \
+		  -L$(subst :, -L,$(rpath-link)) \
+		  -Wl,-rpath-link=$(rpath-link) $< \
+		  -Wl,--version-script=version.map
+
+$(objpfx)versionobj1.so: $(objpfx)versionobj1.os
+	$(LINK.o) -shared -o $@ -B$(csu-objpfx) $(LDFLAGS.so) \
+		  -L$(subst :, -L,$(rpath-link)) \
+		  -Wl,-rpath-link=$(rpath-link) $< \
+		  -Wl,--version-script=version.map
+
+$(objpfx)versionobj2.so: $(objpfx)versionobj2.os
+	$(LINK.o) -shared -o $@ -B$(csu-objpfx) $(LDFLAGS.so) \
+		  -L$(subst :, -L,$(rpath-link)) \
+		  -Wl,-rpath-link=$(rpath-link) $< \
+		  -Wl,--version-script=version.map
+
+$(objpfx)tst-version: $(objpfx)versionobj.so
+$(objpfx)versionobj.so: $(objpfx)versionobj0a.so
+	rm -f $@
+	ln -s $(<F) $@
+
+$(objpfx)tst-version.out: tst-version.sh $(objpfx)tst-version \
+			  $(objpfx)versionobj0a.so \
+			  $(objpfx)versionobj0b.so \
+			  $(objpfx)versionobj1.so \
+			  $(objpfx)versionobj2.so
+	$(SHELL) $< $(common-objpfx) > $@
 
 $(objpfx)unload: $(libdl)
 $(objpfx)unload.out: $(objpfx)unloadmod.so
--- libc/elf/tst-version.c.version	Thu May  3 23:40:15 2001
+++ libc/elf/tst-version.c	Thu May  3 23:36:48 2001
@@ -0,0 +1,20 @@
+#include <stdlib.h>
+
+extern int bar (void);
+extern int foo;
+
+int
+main(int argc, char **argv)
+{
+  int result = 0;
+
+  if (argc > 1)
+    result = atoi (argv [1]);
+  
+  if (bar () != result || foo != result)
+    result = 1;
+  else
+    result = 0;
+
+  return result;
+}
--- libc/elf/tst-version.sh.version	Thu May  3 23:27:01 2001
+++ libc/elf/tst-version.sh	Fri May  4 00:27:06 2001
@@ -0,0 +1,52 @@
+#! /bin/sh
+# Test versioned symbol lookup.
+# Copyright (C) 2001 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+#
+# The GNU C Library 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 Software Foundation; either version 2 of the
+# License, or (at your option) any later version.
+#
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU Library General Public
+# License along with the GNU C Library; see the file COPYING.LIB.  If
+# not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+common_objpfx=$1
+
+rm -f ${common_objpfx}elf/versionobj.so
+ln -s versionobj0a.so ${common_objpfx}elf/versionobj.so
+LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
+LC_ALL=C LD_LIBRARY_PATH=${common_objpfx}. \
+  ${common_objpfx}elf/ld.so ${common_objpfx}elf/tst-version 0
+test $? = 0 || exit 1
+
+rm -f ${common_objpfx}elf/versionobj.so
+ln -s versionobj0b.so ${common_objpfx}elf/versionobj.so
+LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
+LC_ALL=C LD_LIBRARY_PATH=${common_objpfx}. \
+  ${common_objpfx}elf/ld.so ${common_objpfx}elf/tst-version 0
+test $? = 0 || exit 1
+
+rm -f ${common_objpfx}elf/versionobj.so
+ln -s versionobj1.so ${common_objpfx}elf/versionobj.so
+LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
+LC_ALL=C LD_LIBRARY_PATH=${common_objpfx}. \
+  ${common_objpfx}elf/ld.so ${common_objpfx}elf/tst-version 1
+test $? = 0 || exit 1
+
+rm -f ${common_objpfx}elf/versionobj.so
+ln -s versionobj2.so ${common_objpfx}elf/versionobj.so
+LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
+LC_ALL=C LD_LIBRARY_PATH=${common_objpfx}. \
+  ${common_objpfx}elf/ld.so ${common_objpfx}elf/tst-version 2
+test $? = 0 && rm -f ${common_objpfx}elf/versionobj.so && exit 1
+rm -f ${common_objpfx}elf/versionobj.so
+
+exit 0
--- libc/elf/version.map.version	Thu May  3 23:40:02 2001
+++ libc/elf/version.map	Thu May  3 23:40:33 2001
@@ -0,0 +1,11 @@
+VERS.0 {
+  global:
+    bar;
+    foo;
+};
+
+VERS.1 {
+  global:
+    bar;
+    foo;
+} VERS.0;
--- libc/elf/versionobj0.c.version	Thu May  3 23:42:15 2001
+++ libc/elf/versionobj0.c	Thu May  3 23:41:44 2001
@@ -0,0 +1,7 @@
+int foo = 0;
+
+int
+bar (void) 
+{
+  return foo;
+}
--- libc/elf/versionobj1.c.version	Thu May  3 23:42:18 2001
+++ libc/elf/versionobj1.c	Thu May  3 23:41:57 2001
@@ -0,0 +1,10 @@
+__asm__(".symver _old_bar,bar@VERS.0");
+__asm__(".symver _old_foo,foo@VERS.0");
+
+int _old_foo = 1;
+
+int
+_old_bar (void) 
+{
+  return _old_foo;
+}
--- libc/elf/versionobj2.c.version	Thu May  3 23:42:31 2001
+++ libc/elf/versionobj2.c	Thu May  3 23:42:05 2001
@@ -0,0 +1,20 @@
+__asm__(".symver _old_bar,bar@VERS.0");
+__asm__(".symver _old_foo,foo@VERS.0");
+
+int _old_foo = 2;
+
+int
+_old_bar (void) 
+{
+  return _old_foo;
+}
+
+__asm__(".symver _old_bar_1,bar@VERS.1");
+__asm__(".symver _old_foo_1,foo@VERS.1");
+
+int _old_foo_1 = 2;
+int
+_old_bar_1 (void) 
+{
+  return _old_foo_1;
+}


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