* 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.
This commit is contained in:
Ian Lance Taylor
2008-03-27 06:11:57 +00:00
parent 42972f502e
commit 5871526fc2
8 changed files with 149 additions and 5 deletions

View File

@ -1,5 +1,17 @@
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.
PR gold/5986
Fix problems building gold with gcc 4.3.0.
* gold.h (TEMPLATE_ATTRIBUTE_PRINTF_4): Define.

View File

@ -49,8 +49,8 @@ DIST_COMMON = README $(am__configure_deps) $(srcdir)/../config.guess \
$(srcdir)/../install-sh $(srcdir)/../missing \
$(srcdir)/../mkinstalldirs $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(srcdir)/config.in \
$(top_srcdir)/configure $(top_srcdir)/po/Make-in pread.c \
yyscript.c yyscript.h
$(top_srcdir)/configure $(top_srcdir)/po/Make-in ChangeLog \
NEWS pread.c yyscript.c yyscript.h
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \

View File

@ -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.

View File

@ -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

View File

@ -178,8 +178,12 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test ver_test_2 \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_1 script_test_2 \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ justsyms binary_test
@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@am__append_11 = ver_test_2.sh
@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@am__append_12 = ver_test_2.syms
@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@am__append_11 = \
@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@ ver_test_2.sh \
@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@ ver_test_5.sh
@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@am__append_12 = \
@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@ ver_test_2.syms \
@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@ ver_test_5.syms
@GCC_FALSE@script_test_1_DEPENDENCIES = libgoldtest.a ../libgold.a \
@GCC_FALSE@ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
@GCC_FALSE@ $(am__DEPENDENCIES_1)
@ -1767,6 +1771,13 @@ uninstall-am: uninstall-info-am
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -fpic -o $@ $<
@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@ver_test_2.syms: ver_test_2
@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@ readelf -s $< >$@ 2>/dev/null
@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@ver_test_5.so: ver_test_5.o $(srcdir)/ver_test_5.script ver_test_4.so gcctestdir/ld
@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@ $(CXXLINK) -Bgcctestdir/ -shared -Wl,--version-script,$(srcdir)/ver_test_5.script ver_test_5.o ver_test_4.so
@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@ver_test_5.o: ver_test_5.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@ $(CXXCOMPILE) -c -fpic -o $@ $<
@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@ver_test_5.syms: ver_test_5.so
@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@ readelf -s $< >$@ 2>/dev/null
@GCC_TRUE@@NATIVE_LINKER_TRUE@justsyms_2.o: justsyms_2.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -o $@ $<
@GCC_TRUE@@NATIVE_LINKER_TRUE@justsyms_2r.o: justsyms_2.o gcctestdir/ld

View File

@ -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();
}

View File

@ -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;
};

44
gold/testsuite/ver_test_5.sh Executable file
View File

@ -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