This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gold patch committed: Another version handling fix


My last version handling fix broke another case:

* An object defines SYM with no version.
* The object is linked into a shared library S.
* The shared library S is linked against a shared library S1 which has
  an undefined reference to SYM with version VER.
* The shared library S is also linked against a subsequent shared
  library S2 which has a defined default definition of SYM at version
  VER.

In this case we wind up resolving SYM/VER with SYM/NULL.  The
resolution works, but the resulting symbol picks up version VER.

The fix turns out to be simple.  Now that we normally resolve, we no
longer need to handle the version specially.  I committed this patch
and test case.

Ian


2008-07-23  Ian Lance Taylor  <iant@google.com>

	* symtab.cc (Symbol_table::resolve): Remove version parameter.
	Change all callers.
	* symtab.h (class Symbol_table): Update declaration.
	* testsuite/ver_test_9.cc: New file.
	* testsuite/Makefile.am (check_PROGRAMS): Add ver_test_9.
	(ver_test_9_SOURCES, ver_test_9_DEPENDENCIES): Define.
	(ver_test_9_LDFLAGS, ver_test_9_LDADD): Define.
	(ver_test_9.so, ver_test_9.o): New targets.
	* testsuite/Makefile.in: Rebuild.


Index: symtab.cc
===================================================================
RCS file: /cvs/src/src/gold/symtab.cc,v
retrieving revision 1.104
diff -p -u -r1.104 symtab.cc
--- symtab.cc	22 Jul 2008 22:08:43 -0000	1.104
+++ symtab.cc	23 Jul 2008 14:33:03 -0000
@@ -489,8 +489,7 @@ Symbol_table::lookup(const char* name, c
 
 template<int size, bool big_endian>
 void
-Symbol_table::resolve(Sized_symbol<size>* to, const Sized_symbol<size>* from,
-		      const char* version)
+Symbol_table::resolve(Sized_symbol<size>* to, const Sized_symbol<size>* from)
 {
   unsigned char buf[elfcpp::Elf_sizes<size>::sym_size];
   elfcpp::Sym_write<size, big_endian> esym(buf);
@@ -502,7 +501,7 @@ Symbol_table::resolve(Sized_symbol<size>
   bool is_ordinary;
   unsigned int shndx = from->shndx(&is_ordinary);
   this->resolve(to, esym.sym(), shndx, is_ordinary, shndx, from->object(),
-		version);
+		from->version());
   if (from->in_reg())
     to->set_in_reg();
   if (from->in_dyn())
@@ -735,7 +734,7 @@ Symbol_table::add_from_object(Object* ob
 		{
 		  const Sized_symbol<size>* sym2;
 		  sym2 = this->get_sized_symbol<size>(insdef.first->second);
-		  Symbol_table::resolve<size, big_endian>(ret, sym2, version);
+		  Symbol_table::resolve<size, big_endian>(ret, sym2);
 		  this->make_forwarder(insdef.first->second, ret);
 		  insdef.first->second = ret;
 		}
Index: symtab.h
===================================================================
RCS file: /cvs/src/src/gold/symtab.h,v
retrieving revision 1.80
diff -p -u -r1.80 symtab.h
--- symtab.h	22 Jul 2008 22:08:43 -0000	1.80
+++ symtab.h	23 Jul 2008 14:33:05 -0000
@@ -1292,8 +1292,7 @@ class Symbol_table
 
   template<int size, bool big_endian>
   void
-  resolve(Sized_symbol<size>* to, const Sized_symbol<size>* from,
-          const char* version);
+  resolve(Sized_symbol<size>* to, const Sized_symbol<size>* from);
 
   // Record that a symbol is forced to be local by a version script.
   void
Index: testsuite/Makefile.am
===================================================================
RCS file: /cvs/src/src/gold/testsuite/Makefile.am,v
retrieving revision 1.71
diff -p -u -r1.71 Makefile.am
--- testsuite/Makefile.am	18 Jun 2008 04:39:41 -0000	1.71
+++ testsuite/Makefile.am	23 Jul 2008 14:33:05 -0000
@@ -774,6 +774,16 @@ ver_test_8_1.so: two_file_test_1_pic.o t
 ver_test_8_2.so: two_file_test_2_pic.o $(srcdir)/ver_test_8.script gcctestdir/ld
 	$(CXXLINK) -Bgcctestdir/ -shared -Wl,--version-script,$(srcdir)/ver_test_8.script two_file_test_2_pic.o
 
+check_PROGRAMS += ver_test_9
+ver_test_9_SOURCES = ver_test_main.cc
+ver_test_9_DEPENDENCIES = gcctestdir/ld ver_test_9.so
+ver_test_9_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
+ver_test_9_LDADD = ver_test_9.so
+ver_test_9.so: ver_test_9.o ver_test_4.so ver_test_5.so gcctestdir/ld
+	$(CXXLINK) -Bgcctestdir/ -shared ver_test_9.o ver_test_5.so ver_test_4.so
+ver_test_9.o: ver_test_9.cc
+	$(CXXCOMPILE) -c -fpic -o $@ $<
+
 check_PROGRAMS += protected_1
 protected_1_SOURCES = \
 	protected_main_1.cc protected_main_2.cc protected_main_3.cc
Index: testsuite/ver_test_9.cc
===================================================================
RCS file: testsuite/ver_test_9.cc
diff -N testsuite/ver_test_9.cc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/ver_test_9.cc	23 Jul 2008 14:33:06 -0000
@@ -0,0 +1,50 @@
+// ver_test_9.cc -- a test case for gold
+
+// Copyright 2008 Free Software Foundation, Inc.
+// Written by Ian Lance Taylor <iant@google.com>.
+
+// This file is part of gold.
+
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+
+// This program 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 General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+// MA 02110-1301, USA.
+
+#include "ver_test.h"
+
+bool
+t1()
+{
+  return true;
+}
+
+int
+t2_2()
+{
+  TRACE
+  return 22;
+}
+
+int
+t3_2()
+{
+  TRACE
+  return 12;
+}
+
+int
+t4_2()
+{
+  TRACE
+  return 42;
+}

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