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]

Re: a few minor gold notes


Tom Tromey <tromey@redhat.com> writes:

> Ian> This should all be better now, I hope.  gold now prints what
> Ian> config.guess is looking for.
>
> I did a new gcc configure/build with gold in my path.
> It crashes building libgfortran:
>
> /home/tromey/gnu/baseline-gdb/install/bin/ld: internal error in override_base, at ../../src/gold/resolve.cc:46

Thanks for trying it out.

The version script sets the version of a symbol which is not defined
in the library.  It is instead defined in a shared library included in
the link.  gold was incorrectly applying the version from the version
script, and then crashing when the symbol was defined with a different
version.

I committed this patch to fix this problem, with a test case.

Ian


2008-03-26  Ian Lance Taylor  <iant@google.com>

	* symtab.cc (Symbol_table::add_from_relobj): Don't set the version
	of an undefined symbol from a version script.
	* testsuite/Makefile.am (ver_test_5.so): New target.
	(ver_test_5.o): New target.
	(check_SCRIPTS): Add ver_test_5.sh.
	(check_DATA): Add ver_test_5.syms.
	(ver_test_5.syms): New target.
	* testsuite/ver_test_5.cc: New file.
	* testsuite/ver_test_5.script: New file.
	* testsuite/ver_test_5.sh: New file.
	* Makefile.in, testsuite/Makefile.in: Rebuild.


Index: symtab.cc
===================================================================
RCS file: /cvs/src/src/gold/symtab.cc,v
retrieving revision 1.83
diff -p -u -r1.83 symtab.cc
--- symtab.cc	26 Mar 2008 23:36:46 -0000	1.83
+++ symtab.cc	27 Mar 2008 06:09:19 -0000
@@ -719,7 +719,11 @@ Symbol_table::add_from_relobj(
 	      ++ver;
 	    }
         }
-      else if (!version_script_.empty())
+      // We don't want to assign a version to an undefined symbol,
+      // even if it is listed in the version script.  FIXME: What
+      // about a common symbol?
+      else if (!version_script_.empty()
+	       && psym->get_st_shndx() != elfcpp::SHN_UNDEF)
         {
           // The symbol name did not have a version, but
           // the version script may assign a version anyway.
Index: testsuite/Makefile.am
===================================================================
RCS file: /cvs/src/src/gold/testsuite/Makefile.am,v
retrieving revision 1.47
diff -p -u -r1.47 Makefile.am
--- testsuite/Makefile.am	14 Mar 2008 05:57:19 -0000	1.47
+++ testsuite/Makefile.am	27 Mar 2008 06:09:19 -0000
@@ -549,6 +549,19 @@ ver_test_2.syms: ver_test_2
 
 endif
 
+if READELF
+
+ver_test_5.so: ver_test_5.o $(srcdir)/ver_test_5.script ver_test_4.so gcctestdir/ld
+	$(CXXLINK) -Bgcctestdir/ -shared -Wl,--version-script,$(srcdir)/ver_test_5.script ver_test_5.o ver_test_4.so
+ver_test_5.o: ver_test_5.cc
+	$(CXXCOMPILE) -c -fpic -o $@ $<
+check_SCRIPTS += ver_test_5.sh
+check_DATA += ver_test_5.syms
+ver_test_5.syms: ver_test_5.so
+	readelf -s $< >$@ 2>/dev/null
+
+endif
+
 check_PROGRAMS += script_test_1
 script_test_1_SOURCES = script_test_1.cc
 script_test_1_DEPENDENCIES = gcctestdir/ld script_test_1.t
Index: testsuite/ver_test_5.cc
===================================================================
RCS file: testsuite/ver_test_5.cc
diff -N testsuite/ver_test_5.cc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/ver_test_5.cc	27 Mar 2008 06:09:19 -0000
@@ -0,0 +1,29 @@
+// ver_test_5.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"
+
+int
+t3_2()
+{
+  return t2_2();
+}
Index: testsuite/ver_test_5.script
===================================================================
RCS file: testsuite/ver_test_5.script
diff -N testsuite/ver_test_5.script
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/ver_test_5.script	27 Mar 2008 06:09:19 -0000
@@ -0,0 +1,31 @@
+## ver_test_5.script -- 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.
+
+# This tests that we don't break when assigning a version to an
+# undefined symbol.  This is used with ver_test_2.cc, which defines
+# t3_2 but only refers to t2_2.
+
+VER5 {
+  global:
+    t2_2;
+    t3_2;
+};
Index: testsuite/ver_test_5.sh
===================================================================
RCS file: testsuite/ver_test_5.sh
diff -N testsuite/ver_test_5.sh
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/ver_test_5.sh	27 Mar 2008 06:09:19 -0000
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+# ver_test_5.sh -- test that symbol has correct version
+
+# 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.
+
+# This file goes with ver_test_4.script and ver_test_5.script.  The
+# symbol t2_2 is not defined when ver_test_5.script is used.
+
+check()
+{
+    if ! grep -q "$2" "$1"
+    then
+	echo "Did not find expected symbol in $1:"
+	echo "   $2"
+	echo ""
+	echo "Actual output below:"
+	cat "$1"
+	exit 1
+    fi
+}
+
+check ver_test_5.syms "t3_2@@VER5"
+check ver_test_5.syms "t2_2@VER2"
+
+exit 0

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