This is the mail archive of the binutils-cvs@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]

[binutils-gdb/binutils-2_31-branch] Import patch from mainline to fix gold's handling of already versioned symbols.


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0694d6e5fb2c14934822e68a9a20b43317b0c2a8

commit 0694d6e5fb2c14934822e68a9a20b43317b0c2a8
Author: Nick Clifton <nickc@redhat.com>
Date:   Mon Jul 16 14:29:26 2018 +0100

    Import patch from mainline to fix gold's handling of already versioned symbols.
    
    gold	PR gold/23409
    	* symtab.cc (Symbol_table::define_special_symbol): Add check for
    	version name on existing symbol.
    	* testsuite/Makefile.am (ver_test_pr23409): New test case.
    	* testsuite/Makefile.in: Regenerate.
    	* testsuite/ver_test_pr23409.sh: New test script.
    	* testsuite/ver_test_pr23409_1.script: New version script.
    	* testsuite/ver_test_pr23409_2.script: New version script.

Diff:
---
 gold/ChangeLog                           | 15 ++++++++
 gold/symtab.cc                           |  7 +++-
 gold/testsuite/Makefile.am               |  9 +++++
 gold/testsuite/Makefile.in               | 19 +++++++++-
 gold/testsuite/ver_test_pr23409.sh       | 64 ++++++++++++++++++++++++++++++++
 gold/testsuite/ver_test_pr23409_1.script |  3 ++
 gold/testsuite/ver_test_pr23409_2.script |  3 ++
 7 files changed, 116 insertions(+), 4 deletions(-)

diff --git a/gold/ChangeLog b/gold/ChangeLog
index 87eebd5..ea54a97 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,18 @@
+2018-07-16  Nick Clifton  <nickc@redhat.com>
+
+	* Import patch from mainline:
+
+	2018-07-14  Cary Coutant  <ccoutant@gmail.com>
+
+	PR gold/23409
+	* symtab.cc (Symbol_table::define_special_symbol): Add check for
+	version name on existing symbol.
+	* testsuite/Makefile.am (ver_test_pr23409): New test case.
+	* testsuite/Makefile.in: Regenerate.
+	* testsuite/ver_test_pr23409.sh: New test script.
+	* testsuite/ver_test_pr23409_1.script: New version script.
+	* testsuite/ver_test_pr23409_2.script: New version script.
+
 2018-07-14  Nick Clifton  <nickc@redhat.com>
 
 	2.31 Release point.
diff --git a/gold/symtab.cc b/gold/symtab.cc
index c43d127..aa76441 100644
--- a/gold/symtab.cc
+++ b/gold/symtab.cc
@@ -1898,10 +1898,13 @@ Symbol_table::define_special_symbol(const char** pname, const char** pversion,
 	  add_to_table = true;
 	  add_loc = ins.first;
 
-	  if (is_default_version && !insdefault.second)
+	  if (is_default_version
+	      && !insdefault.second
+	      && insdefault.first->second->version() == NULL)
 	    {
 	      // We are adding NAME/VERSION, and it is the default
-	      // version.  We already have an entry for NAME/NULL.
+	      // version.  We already have an entry for NAME/NULL
+	      // that does not already have a version.
 	      oldsym = insdefault.first->second;
 	      *resolve_oldsym = true;
 	    }
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am
index 5f7d981..0b51d7e 100644
--- a/gold/testsuite/Makefile.am
+++ b/gold/testsuite/Makefile.am
@@ -1880,6 +1880,15 @@ ver_test_14.syms: ver_test_14
 ver_test_14: gcctestdir/ld ver_test_main.o ver_test_1.so ver_test_2.so ver_test_4.so ver_test_14.script
 	$(CXXLINK) -Bgcctestdir/ -Wl,--version-script,$(srcdir)/ver_test_14.script -Wl,-E -Wl,-R,. ver_test_main.o ver_test_1.so ver_test_2.so ver_test_4.so
 
+check_SCRIPTS += ver_test_pr23409.sh
+check_DATA += ver_test_pr23409.syms
+ver_test_pr23409.syms: ver_test_pr23409_1.so
+       $(TEST_READELF) --dyn-syms -W $< >$@
+ver_test_pr23409_1.so: gcctestdir/ld ver_test_1.o $(srcdir)/ver_test_pr23409_1.script ver_test_pr23409_2.so
+       gcctestdir/ld -shared -o $@ ver_test_1.o ver_test_pr23409_2.so --version-script $(srcdir)/ver_test_pr23409_1.script
+ver_test_pr23409_2.so: gcctestdir/ld ver_test_1.o $(srcdir)/ver_test_pr23409_2.script
+       gcctestdir/ld -shared -o $@ ver_test_1.o --version-script $(srcdir)/ver_test_pr23409_2.script
+
 check_SCRIPTS += weak_as_needed.sh
 check_DATA += weak_as_needed.stdout
 weak_as_needed.stdout: weak_as_needed_a.so
diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in
index b4729bc..7305d32 100644
--- a/gold/testsuite/Makefile.in
+++ b/gold/testsuite/Makefile.in
@@ -479,8 +479,9 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@	ver_test_4.sh ver_test_5.sh \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@	ver_test_7.sh ver_test_8.sh \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@	ver_test_10.sh ver_test_13.sh \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@	ver_test_14.sh weak_as_needed.sh \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@	relro_test.sh \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@	ver_test_14.sh \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@	ver_test_pr23409.sh \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@	weak_as_needed.sh relro_test.sh \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@	ver_matching_test.sh \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@	script_test_3.sh \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@	script_test_4.sh \
@@ -536,6 +537,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@	ver_test_10.syms \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@	ver_test_13.syms \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@	ver_test_14.syms \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@	ver_test_pr23409.syms \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@	weak_as_needed.stdout \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@	protected_3.err \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@	relro_test.stdout \
@@ -5807,6 +5809,13 @@ ver_test_14.sh.log: ver_test_14.sh
 	--log-file $$b.log --trs-file $$b.trs \
 	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
 	"$$tst" $(AM_TESTS_FD_REDIRECT)
+ver_test_pr23409.sh.log: ver_test_pr23409.sh
+	@p='ver_test_pr23409.sh'; \
+	b='ver_test_pr23409.sh'; \
+	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+	--log-file $$b.log --trs-file $$b.trs \
+	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+	"$$tst" $(AM_TESTS_FD_REDIRECT)
 weak_as_needed.sh.log: weak_as_needed.sh
 	@p='weak_as_needed.sh'; \
 	b='weak_as_needed.sh'; \
@@ -8731,6 +8740,12 @@ uninstall-am:
 @GCC_TRUE@@NATIVE_LINKER_TRUE@	$(TEST_OBJDUMP) -T $< | $(TEST_CXXFILT) >$@
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_14: gcctestdir/ld ver_test_main.o ver_test_1.so ver_test_2.so ver_test_4.so ver_test_14.script
 @GCC_TRUE@@NATIVE_LINKER_TRUE@	$(CXXLINK) -Bgcctestdir/ -Wl,--version-script,$(srcdir)/ver_test_14.script -Wl,-E -Wl,-R,. ver_test_main.o ver_test_1.so ver_test_2.so ver_test_4.so
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_pr23409.syms: ver_test_pr23409_1.so
+@GCC_TRUE@@NATIVE_LINKER_TRUE@	$(TEST_READELF) --dyn-syms -W $< >$@
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_pr23409_1.so: gcctestdir/ld ver_test_1.o $(srcdir)/ver_test_pr23409_1.script ver_test_pr23409_2.so
+@GCC_TRUE@@NATIVE_LINKER_TRUE@	gcctestdir/ld -shared -o $@ ver_test_1.o ver_test_pr23409_2.so --version-script $(srcdir)/ver_test_pr23409_1.script
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_pr23409_2.so: gcctestdir/ld ver_test_1.o $(srcdir)/ver_test_pr23409_2.script
+@GCC_TRUE@@NATIVE_LINKER_TRUE@	gcctestdir/ld -shared -o $@ ver_test_1.o --version-script $(srcdir)/ver_test_pr23409_2.script
 @GCC_TRUE@@NATIVE_LINKER_TRUE@weak_as_needed.stdout: weak_as_needed_a.so
 @GCC_TRUE@@NATIVE_LINKER_TRUE@	$(TEST_READELF) -dW --dyn-syms $< >$@
 @GCC_TRUE@@NATIVE_LINKER_TRUE@weak_as_needed_a.so: gcctestdir/ld weak_as_needed_a.o weak_as_needed_b.so weak_as_needed_c.so
diff --git a/gold/testsuite/ver_test_pr23409.sh b/gold/testsuite/ver_test_pr23409.sh
new file mode 100755
index 0000000..ed1ef65
--- /dev/null
+++ b/gold/testsuite/ver_test_pr23409.sh
@@ -0,0 +1,64 @@
+#!/bin/sh
+
+# ver_test_pr23409.sh -- a test case for version scripts
+
+# Copyright (C) 2018 Free Software Foundation, Inc.
+# Written by Cary Coutant <ccoutant@gmail.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 test verifies that linker-generated symbols (e.g., _end)
+# get correct version information even in the presence of
+# a shared library that provides those symbols with different
+# versions.
+
+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_missing()
+{
+    if grep -q "$2" "$1"
+    then
+	echo "Found unexpected symbol in $1:"
+	echo "   $2"
+	echo ""
+	echo "Actual output below:"
+	cat "$1"
+	exit 1
+    fi
+}
+
+check ver_test_pr23409.syms "_end@@VER1$"
+check ver_test_pr23409.syms "_edata@@VER1$"
+check ver_test_pr23409.syms "__bss_start@@VER1$"
+
+check_missing ver_test_pr23409.syms "_end@VER"
+check_missing ver_test_pr23409.syms "_edata@VER"
+check_missing ver_test_pr23409.syms "__bss_start@VER"
+
+exit 0
diff --git a/gold/testsuite/ver_test_pr23409_1.script b/gold/testsuite/ver_test_pr23409_1.script
new file mode 100644
index 0000000..6969454
--- /dev/null
+++ b/gold/testsuite/ver_test_pr23409_1.script
@@ -0,0 +1,3 @@
+VER1 {
+  global: *;
+};
diff --git a/gold/testsuite/ver_test_pr23409_2.script b/gold/testsuite/ver_test_pr23409_2.script
new file mode 100644
index 0000000..fa45184
--- /dev/null
+++ b/gold/testsuite/ver_test_pr23409_2.script
@@ -0,0 +1,3 @@
+VER2 {
+  global: *;
+};


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