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]

PATCH: An updated patch for non-versioned lookup testcase


Here is an update patch for

http://sources.redhat.com/ml/libc-alpha/2001-05/msg00026.html


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

	* elf/Makefile (distribute): Add tst-version.sh, version.map,
	versionobj.c, versionobj1.c, versionobj2.c and versionobj3.c.
	(test-srcs): Add tst-version.
	(modules-names): Add versionobj, versionobj1, versionobj and
	versionobj3.
	(tests): Also depend on $(objpfx)tst-version.out.
	$(objpfx)%.so: Also filter out versionobj1.so, versionobj2.so
	and versionobj3.so.
	($(objpfx)versionobj1.so): New target.
	($(objpfx)versionobj2.so): New target.
	($(objpfx)versionobj3.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/versionobj.c: New file.
	* elf/versionobj1.c: New file.
	* elf/versionobj2.c: New file.
	* elf/versionobj3.c: New file.

--- libc/elf/Makefile.version	Fri May  4 20:39:03 2001
+++ libc/elf/Makefile	Mon May  7 09:39:00 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 versionobj.c \
+		   versionobj1.c versionobj2.c versionobj3.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 \
+		versionobj versionobj1 versionobj2 versionobj3
 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
 
@@ -275,8 +278,12 @@ $(objpfx)ltglobmod2.so: $(libdl)
 $(objpfx)firstobj.so: $(shared-thread-library)
 $(objpfx)globalmod1.so: $(libdl)
 
-# filtmod1.so has a special rule
-$(filter-out $(objpfx)filtmod1.so, $(test-modules)): $(objpfx)%.so: $(objpfx)%.os
+# Some DSOs have special rules
+$(filter-out $(objpfx)filtmod1.so \
+	     $(objpfx)versionobj1.so \
+	     $(objpfx)versionobj2.so \
+	     $(objpfx)versionobj3.so, \
+	     $(test-modules)): $(objpfx)%.so: $(objpfx)%.os
 	$(build-module)
 
 $(objpfx)loadtest: $(libdl)
@@ -369,6 +376,36 @@ $(objpfx)filtmod1.so: $(objpfx)filtmod1.
 		  -Wl,-rpath-link=$(rpath-link) \
 		  $< -Wl,-F,$(objpfx)filtmod2.so
 $(objpfx)filter: $(objpfx)filtmod1.so
+
+$(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,-soname=versionobj.so \
+		  -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,-soname=versionobj.so \
+		  -Wl,-version-script=version.map
+
+$(objpfx)versionobj3.so: $(objpfx)versionobj3.os
+	$(LINK.o) -shared -o $@ -B$(csu-objpfx) $(LDFLAGS.so) \
+		  -L$(subst :, -L,$(rpath-link)) \
+		  -Wl,-rpath-link=$(rpath-link) $< \
+		  -Wl,-soname=versionobj.so \
+		  -Wl,-version-script=version.map
+
+$(objpfx)tst-version: $(objpfx)versionobj.so
+
+$(objpfx)tst-version.out: tst-version.sh $(objpfx)tst-version \
+			  $(objpfx)versionobj.so \
+			  $(objpfx)versionobj1.so \
+			  $(objpfx)versionobj2.so \
+			  $(objpfx)versionobj3.so
+	$(SHELL) $< $(common-objpfx) > $@ 2>&1
 
 $(objpfx)unload: $(libdl)
 $(objpfx)unload.out: $(objpfx)unloadmod.so
--- libc/elf/tst-version.c.version	Fri May  4 21:42:09 2001
+++ libc/elf/tst-version.c	Fri May  4 21:42:09 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	Fri May  4 21:42:09 2001
+++ libc/elf/tst-version.sh	Mon May  7 09:43:14 2001
@@ -0,0 +1,68 @@
+#! /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
+
+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
+
+mv ${common_objpfx}elf/versionobj.so \
+	${common_objpfx}elf/versionobj.so.saved
+
+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
+if test $? != 0; then
+  rm -f ${common_objpfx}elf/versionobj.so
+  mv ${common_objpfx}elf/versionobj.so.saved \
+	${common_objpfx}elf/versionobj.so
+  exit 1
+fi
+
+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
+if test $? != 0; then
+  rm -f ${common_objpfx}elf/versionobj.so
+  mv ${common_objpfx}elf/versionobj.so.saved \
+	${common_objpfx}elf/versionobj.so
+  exit 1
+fi
+
+rm -f ${common_objpfx}elf/versionobj.so
+ln -s versionobj3.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 3
+if test $? = 0; then
+  status=1
+else
+  status=0
+fi
+rm -f ${common_objpfx}elf/versionobj.so
+mv ${common_objpfx}elf/versionobj.so.saved \
+	${common_objpfx}elf/versionobj.so
+
+exit $status
--- libc/elf/version.map.version	Fri May  4 21:42:09 2001
+++ libc/elf/version.map	Fri May  4 21:42:09 2001
@@ -0,0 +1,11 @@
+VERS.0 {
+  global:
+    bar;
+    foo;
+};
+
+VERS.1 {
+  global:
+    bar;
+    foo;
+} VERS.0;
--- libc/elf/versionobj1.c.version	Fri May  4 21:42:09 2001
+++ libc/elf/versionobj1.c	Mon May  7 09:42:44 2001
@@ -0,0 +1,20 @@
+__asm__(".symver _old_bar,bar@VERS.0");
+__asm__(".symver _old_foo,foo@VERS.0");
+
+int _old_foo = 0;
+
+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 = 1;
+int
+_old_bar_1 (void) 
+{
+  return _old_foo_1;
+}
--- libc/elf/versionobj2.c.version	Mon May  7 09:13:02 2001
+++ libc/elf/versionobj2.c	Mon May  7 09:42:54 2001
@@ -0,0 +1,10 @@
+__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;
+}
--- libc/elf/versionobj3.c.version	Mon May  7 09:13:02 2001
+++ libc/elf/versionobj3.c	Mon May  7 09:43:02 2001
@@ -0,0 +1,20 @@
+__asm__(".symver _old_bar,bar@VERS.0");
+__asm__(".symver _old_foo,foo@VERS.0");
+
+int _old_foo = 0;
+
+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 = 3;
+int
+_old_bar_1 (void) 
+{
+  return _old_foo_1;
+}
--- libc/elf/versionobj.c.version	Fri May  4 21:42:09 2001
+++ libc/elf/versionobj.c	Fri May  4 21:42:09 2001
@@ -0,0 +1,7 @@
+int foo = 0;
+
+int
+bar (void) 
+{
+  return foo;
+}


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