aboutsummaryrefslogtreecommitdiff
path: root/gold/testsuite
diff options
context:
space:
mode:
authorDoug Kwan <dougkwan@google.com>2009-10-16 19:11:32 +0000
committerDoug Kwan <dougkwan@google.com>2009-10-16 19:11:32 +0000
commitc5617f2fb6d7c6a1898d920ac662209a195b3c9e (patch)
tree3cc0e6f7022a7431503777045283809c0aa3f762 /gold/testsuite
parent0a8d1bde177b4f1ef4df5ba6a7b79a9df3d1497f (diff)
downloadfsf-binutils-gdb-c5617f2fb6d7c6a1898d920ac662209a195b3c9e.zip
fsf-binutils-gdb-c5617f2fb6d7c6a1898d920ac662209a195b3c9e.tar.gz
fsf-binutils-gdb-c5617f2fb6d7c6a1898d920ac662209a195b3c9e.tar.bz2
2009-10-16 Doug Kwan <dougkwan@google.com>
* dynobj.cc (Versions::Versions): Initialize version_script_. Only insert base version symbol definition for a shared object if version script defines any version versions. (Versions::define_base_version): New method definition. (Versions::add_def): Check that base version is not needed. (Versions::add_need): Define base version lazily. * dynobj.h (Versions::define_base_version): New method declaration. (Versions::needs_base_version_): New data member declaration. * testsuite/Makefile.am (check_SCRIPTS): Add no_version_test.sh (check_DATA): Add no_version_test.stdout. (libno_version_test.so, no_version_test.o no_version_test.stdout): New make rules. * testsuite/Makefile.in: Regenerate. * testsuite/no_version_test.c: New file. * testsuite/no_version_test.sh: Ditto.
Diffstat (limited to 'gold/testsuite')
-rw-r--r--gold/testsuite/Makefile.am14
-rw-r--r--gold/testsuite/Makefile.in21
-rw-r--r--gold/testsuite/no_version_test.c32
-rwxr-xr-xgold/testsuite/no_version_test.sh45
4 files changed, 109 insertions, 3 deletions
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am
index 6fa1e18..b343ca3 100644
--- a/gold/testsuite/Makefile.am
+++ b/gold/testsuite/Makefile.am
@@ -1249,6 +1249,20 @@ alt/searched_file_test_lib.a: searched_file_test_lib.o
test -d alt || mkdir -p alt
$(TEST_AR) rc $@ $^
+# Test that no .gnu.version sections are created when
+# symbol versioning is not used.
+check_SCRIPTS += no_version_test.sh
+check_DATA += no_version_test.stdout
+MOSTLYCLEANFILES += libno_version_test.so no_version_test.stdout
+# We invoke the linker directly since gcc may include additional objects that
+# uses symbol versioning.
+libno_version_test.so: no_version_test.o gcctestdir/ld
+ gcctestdir/ld -shared -o $@ no_version_test.o
+no_version_test.o: no_version_test.c
+ $(COMPILE) -o $@ -c -fPIC $<
+no_version_test.stdout: libno_version_test.so
+ $(TEST_OBJDUMP) -h $< > $@
+
endif GCC
endif NATIVE_LINKER
diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in
index 193888a..ed08580 100644
--- a/gold/testsuite/Makefile.in
+++ b/gold/testsuite/Makefile.in
@@ -354,14 +354,19 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
# referenced by a shared library.
# Test -retain-symbols-file.
+
+# Test that no .gnu.version sections are created when
+# symbol versioning is not used.
@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_27 = exclude_libs_test.sh \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ discard_locals_test.sh \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ hidden_test.sh \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ retain_symbols_file_test.sh
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ retain_symbols_file_test.sh \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ no_version_test.sh
@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_28 = exclude_libs_test.syms \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ discard_locals_test.syms \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ hidden_test.err \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ retain_symbols_file_test.stdout
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ retain_symbols_file_test.stdout \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ no_version_test.stdout
@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_29 = exclude_libs_test.syms \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ libexclude_libs_test_1.a \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ libexclude_libs_test_2.a \
@@ -373,7 +378,9 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ retain_symbols_file_test.stdout \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ searched_file_test \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ searched_file_test_lib.o \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ alt/searched_file_test_lib.a
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ alt/searched_file_test_lib.a \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ libno_version_test.so \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ no_version_test.stdout
@GCC_TRUE@@MCMODEL_MEDIUM_TRUE@@NATIVE_LINKER_TRUE@am__append_30 = large
@GCC_FALSE@large_DEPENDENCIES = libgoldtest.a ../libgold.a \
@GCC_FALSE@ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
@@ -3104,6 +3111,14 @@ uninstall-am:
@GCC_TRUE@@NATIVE_LINKER_TRUE@alt/searched_file_test_lib.a: searched_file_test_lib.o
@GCC_TRUE@@NATIVE_LINKER_TRUE@ test -d alt || mkdir -p alt
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_AR) rc $@ $^
+# We invoke the linker directly since gcc may include additional objects that
+# uses symbol versioning.
+@GCC_TRUE@@NATIVE_LINKER_TRUE@libno_version_test.so: no_version_test.o gcctestdir/ld
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ gcctestdir/ld -shared -o $@ no_version_test.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@no_version_test.o: no_version_test.c
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(COMPILE) -o $@ -c -fPIC $<
+@GCC_TRUE@@NATIVE_LINKER_TRUE@no_version_test.stdout: libno_version_test.so
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_OBJDUMP) -h $< > $@
@DEFAULT_TARGET_I386_TRUE@split_i386_1.o: split_i386_1.s
@DEFAULT_TARGET_I386_TRUE@ $(TEST_AS) -o $@ $<
@DEFAULT_TARGET_I386_TRUE@split_i386_2.o: split_i386_2.s
diff --git a/gold/testsuite/no_version_test.c b/gold/testsuite/no_version_test.c
new file mode 100644
index 0000000..e42d04f
--- /dev/null
+++ b/gold/testsuite/no_version_test.c
@@ -0,0 +1,32 @@
+// ver_no_default.c -- a test case for gold
+
+// Copyright 2009 Free Software Foundation, Inc.
+// Written by Doug Kwan <dougkwan@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.
+
+// We should not create any .gnu.version sections if symbol versioning
+// is not used.
+
+extern int the_answer(void);
+
+int
+the_answer(void)
+{
+ return 42;
+}
diff --git a/gold/testsuite/no_version_test.sh b/gold/testsuite/no_version_test.sh
new file mode 100755
index 0000000..f4ca9b1
--- /dev/null
+++ b/gold/testsuite/no_version_test.sh
@@ -0,0 +1,45 @@
+#!/bin/sh
+
+# no_version_test.sh -- test that .gnu.version* sections are not created
+# in a shared object when symbol versioning is not used.
+
+# Copyright 2009 Free Software Foundation, Inc.
+# Written by Doug Kwan <dougkwan@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 no_version_test.c, a C source file
+# linked with option -shared -nostdlib. We run objdump on
+# the resulting executable and check that .gnu.version* sections
+# are not created.
+
+check()
+{
+ file=$1
+
+ found=`egrep "\.gnu\.version.*" $file`
+ if test -n "$found"; then
+ echo "These section should not be in $file:"
+ echo "$found"
+ exit 1
+ fi
+}
+
+check "no_version_test.stdout"
+
+exit 0