]> git.pld-linux.org Git - packages/binutils.git/blob - bug-23409.patch
- rel 3; add workaround from FC for _end: invalid version 21 (max 0), error adding...
[packages/binutils.git] / bug-23409.patch
1 From 1b115e8e0e051d65d0747f0a8a84eb6453866729 Mon Sep 17 00:00:00 2001
2 From: Cary Coutant <ccoutant@gmail.com>
3 Date: Sat, 14 Jul 2018 12:29:03 -0700
4 Subject: [PATCH 1/1] Fix problem causing duplicated linker-generated symbols
5  with versions.
6
7 When generating _end, _edata, etc. symbols, and a version script provides
8 a version name, and we are linking against another shared library that
9 provides those symbols with a different version, gold ends up trying to
10 resolve the other shared library's symbols to the new definitions, resulting
11 in two copies of each symbol, one as default, and one as non-default.
12 This patch tests for that condition, and ignores the symbols provided
13 by the other shared library.
14
15 gold/
16         PR gold/23409
17         * symtab.cc (Symbol_table::define_special_symbol): Add check for
18         version name on existing symbol.
19         * testsuite/Makefile.am (ver_test_pr23409): New test case.
20         * testsuite/Makefile.in: Regenerate.
21         * testsuite/ver_test_pr23409.sh: New test script.
22         * testsuite/ver_test_pr23409_1.script: New version script.
23         * testsuite/ver_test_pr23409_2.script: New version script.
24 ---
25  gold/ChangeLog                           | 11 ++++++
26  gold/symtab.cc                           |  7 +++-
27  gold/testsuite/Makefile.am               |  9 +++++
28  gold/testsuite/Makefile.in               | 19 +++++++++-
29  gold/testsuite/ver_test_pr23409.sh       | 64 ++++++++++++++++++++++++++++++++
30  gold/testsuite/ver_test_pr23409_1.script |  3 ++
31  gold/testsuite/ver_test_pr23409_2.script |  3 ++
32  7 files changed, 112 insertions(+), 4 deletions(-)
33  create mode 100755 gold/testsuite/ver_test_pr23409.sh
34  create mode 100644 gold/testsuite/ver_test_pr23409_1.script
35  create mode 100644 gold/testsuite/ver_test_pr23409_2.script
36
37 diff --git a/gold/symtab.cc b/gold/symtab.cc
38 index c43d127..aa76441 100644
39 --- a/gold/symtab.cc
40 +++ b/gold/symtab.cc
41 @@ -1898,10 +1898,13 @@ Symbol_table::define_special_symbol(const char** pname, const char** pversion,
42           add_to_table = true;
43           add_loc = ins.first;
44  
45 -         if (is_default_version && !insdefault.second)
46 +         if (is_default_version
47 +             && !insdefault.second
48 +             && insdefault.first->second->version() == NULL)
49             {
50               // We are adding NAME/VERSION, and it is the default
51 -             // version.  We already have an entry for NAME/NULL.
52 +             // version.  We already have an entry for NAME/NULL
53 +             // that does not already have a version.
54               oldsym = insdefault.first->second;
55               *resolve_oldsym = true;
56             }
57 diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am
58 index 5f7d981..e15788e 100644
59 --- a/gold/testsuite/Makefile.am
60 +++ b/gold/testsuite/Makefile.am
61 @@ -1880,6 +1880,15 @@ ver_test_14.syms: ver_test_14
62  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
63         $(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
64  
65 +check_SCRIPTS += ver_test_pr23409.sh
66 +check_DATA += ver_test_pr23409.syms
67 +ver_test_pr23409.syms: ver_test_pr23409_1.so
68 +       $(TEST_READELF) --dyn-syms -W $< >$@
69 +ver_test_pr23409_1.so: gcctestdir/ld ver_test_1.o $(srcdir)/ver_test_pr23409_1.script ver_test_pr23409_2.so
70 +       gcctestdir/ld -shared -o $@ ver_test_1.o ver_test_pr23409_2.so --version-script $(srcdir)/ver_test_pr23409_1.script
71 +ver_test_pr23409_2.so: gcctestdir/ld ver_test_1.o $(srcdir)/ver_test_pr23409_2.script
72 +       gcctestdir/ld -shared -o $@ ver_test_1.o --version-script $(srcdir)/ver_test_pr23409_2.script
73 +
74  check_SCRIPTS += weak_as_needed.sh
75  check_DATA += weak_as_needed.stdout
76  weak_as_needed.stdout: weak_as_needed_a.so
77 diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in
78 index b4729bc..7305d32 100644
79 --- a/gold/testsuite/Makefile.in
80 +++ b/gold/testsuite/Makefile.in
81 @@ -479,8 +479,9 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
82  @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_4.sh ver_test_5.sh \
83  @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_7.sh ver_test_8.sh \
84  @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_10.sh ver_test_13.sh \
85 -@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_14.sh weak_as_needed.sh \
86 -@GCC_TRUE@@NATIVE_LINKER_TRUE@ relro_test.sh \
87 +@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_14.sh \
88 +@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_pr23409.sh \
89 +@GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_as_needed.sh relro_test.sh \
90  @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_matching_test.sh \
91  @GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_3.sh \
92  @GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_4.sh \
93 @@ -536,6 +537,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
94  @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_10.syms \
95  @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_13.syms \
96  @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_14.syms \
97 +@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_pr23409.syms \
98  @GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_as_needed.stdout \
99  @GCC_TRUE@@NATIVE_LINKER_TRUE@ protected_3.err \
100  @GCC_TRUE@@NATIVE_LINKER_TRUE@ relro_test.stdout \
101 @@ -5807,6 +5809,13 @@ ver_test_14.sh.log: ver_test_14.sh
102         --log-file $$b.log --trs-file $$b.trs \
103         $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
104         "$$tst" $(AM_TESTS_FD_REDIRECT)
105 +ver_test_pr23409.sh.log: ver_test_pr23409.sh
106 +       @p='ver_test_pr23409.sh'; \
107 +       b='ver_test_pr23409.sh'; \
108 +       $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
109 +       --log-file $$b.log --trs-file $$b.trs \
110 +       $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
111 +       "$$tst" $(AM_TESTS_FD_REDIRECT)
112  weak_as_needed.sh.log: weak_as_needed.sh
113         @p='weak_as_needed.sh'; \
114         b='weak_as_needed.sh'; \
115 @@ -8731,6 +8740,12 @@ uninstall-am:
116  @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_OBJDUMP) -T $< | $(TEST_CXXFILT) >$@
117  @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
118  @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
119 +@GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_pr23409.syms: ver_test_pr23409_1.so
120 +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) --dyn-syms -W $< >$@
121 +@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
122 +@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
123 +@GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_pr23409_2.so: gcctestdir/ld ver_test_1.o $(srcdir)/ver_test_pr23409_2.script
124 +@GCC_TRUE@@NATIVE_LINKER_TRUE@ gcctestdir/ld -shared -o $@ ver_test_1.o --version-script $(srcdir)/ver_test_pr23409_2.script
125  @GCC_TRUE@@NATIVE_LINKER_TRUE@weak_as_needed.stdout: weak_as_needed_a.so
126  @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -dW --dyn-syms $< >$@
127  @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
128 diff --git a/gold/testsuite/ver_test_pr23409.sh b/gold/testsuite/ver_test_pr23409.sh
129 new file mode 100755
130 index 0000000..ed1ef65
131 --- /dev/null
132 +++ b/gold/testsuite/ver_test_pr23409.sh
133 @@ -0,0 +1,64 @@
134 +#!/bin/sh
135 +
136 +# ver_test_pr23409.sh -- a test case for version scripts
137 +
138 +# Copyright (C) 2018 Free Software Foundation, Inc.
139 +# Written by Cary Coutant <ccoutant@gmail.com>.
140 +
141 +# This file is part of gold.
142 +
143 +# This program is free software; you can redistribute it and/or modify
144 +# it under the terms of the GNU General Public License as published by
145 +# the Free Software Foundation; either version 3 of the License, or
146 +# (at your option) any later version.
147 +
148 +# This program is distributed in the hope that it will be useful,
149 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
150 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
151 +# GNU General Public License for more details.
152 +
153 +# You should have received a copy of the GNU General Public License
154 +# along with this program; if not, write to the Free Software
155 +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
156 +# MA 02110-1301, USA.
157 +
158 +# This test verifies that linker-generated symbols (e.g., _end)
159 +# get correct version information even in the presence of
160 +# a shared library that provides those symbols with different
161 +# versions.
162 +
163 +check()
164 +{
165 +    if ! grep -q "$2" "$1"
166 +    then
167 +       echo "Did not find expected symbol in $1:"
168 +       echo "   $2"
169 +       echo ""
170 +       echo "Actual output below:"
171 +       cat "$1"
172 +       exit 1
173 +    fi
174 +}
175 +
176 +check_missing()
177 +{
178 +    if grep -q "$2" "$1"
179 +    then
180 +       echo "Found unexpected symbol in $1:"
181 +       echo "   $2"
182 +       echo ""
183 +       echo "Actual output below:"
184 +       cat "$1"
185 +       exit 1
186 +    fi
187 +}
188 +
189 +check ver_test_pr23409.syms "_end@@VER1$"
190 +check ver_test_pr23409.syms "_edata@@VER1$"
191 +check ver_test_pr23409.syms "__bss_start@@VER1$"
192 +
193 +check_missing ver_test_pr23409.syms "_end@VER"
194 +check_missing ver_test_pr23409.syms "_edata@VER"
195 +check_missing ver_test_pr23409.syms "__bss_start@VER"
196 +
197 +exit 0
198 diff --git a/gold/testsuite/ver_test_pr23409_1.script b/gold/testsuite/ver_test_pr23409_1.script
199 new file mode 100644
200 index 0000000..6969454
201 --- /dev/null
202 +++ b/gold/testsuite/ver_test_pr23409_1.script
203 @@ -0,0 +1,3 @@
204 +VER1 {
205 +  global: *;
206 +};
207 diff --git a/gold/testsuite/ver_test_pr23409_2.script b/gold/testsuite/ver_test_pr23409_2.script
208 new file mode 100644
209 index 0000000..fa45184
210 --- /dev/null
211 +++ b/gold/testsuite/ver_test_pr23409_2.script
212 @@ -0,0 +1,3 @@
213 +VER2 {
214 +  global: *;
215 +};
216 -- 
217 2.9.3
218
This page took 0.066119 seconds and 3 git commands to generate.