aboutsummaryrefslogtreecommitdiff
path: root/gold/testsuite
diff options
context:
space:
mode:
authorCraig Silverstein <csilvers@google.com>2009-09-18 20:03:22 +0000
committerCraig Silverstein <csilvers@google.com>2009-09-18 20:03:22 +0000
commit8c60465154ed694fac2531f65e7ca1ae51093174 (patch)
tree5b1e1c166e0d5f50c40988974cf4a87e9dfcb216 /gold/testsuite
parentf43030c448dc1938d6fc7a6072f1a76853b1b70d (diff)
downloadgdb-8c60465154ed694fac2531f65e7ca1ae51093174.zip
gdb-8c60465154ed694fac2531f65e7ca1ae51093174.tar.gz
gdb-8c60465154ed694fac2531f65e7ca1ae51093174.tar.bz2
* object.cc (Sized_relobj::do_count): Test should_retain_symbol map.
* options.cc: Include <cerrno> and <fstream>. (General_options::finalize): Parse -retain-symbols-file tag. * options.h: New flag. (General_options): New method should_retain_symbol, new variable symbols_to_retain. * symtab.cc (Symbol_table::sized_finalize_symbol): Test should_retain_symbol map. * testsuite/Makefile.am (retain_symbols_file_test): New test. * testsuite/Makefile.in: Regenerate. * testsuite/retain_symbols_file_test.sh: New file.
Diffstat (limited to 'gold/testsuite')
-rw-r--r--gold/testsuite/Makefile.am17
-rw-r--r--gold/testsuite/Makefile.in23
-rwxr-xr-xgold/testsuite/retain_symbols_file_test.sh55
3 files changed, 92 insertions, 3 deletions
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am
index af16f90..25740b8 100644
--- a/gold/testsuite/Makefile.am
+++ b/gold/testsuite/Makefile.am
@@ -1153,6 +1153,23 @@ hidden_test: hidden_test_main.o libhidden.so gcctestdir/ld
hidden_test.err: hidden_test
@touch hidden_test.err
+# Test -retain-symbols-file.
+check_SCRIPTS += retain_symbols_file_test.sh
+check_DATA += retain_symbols_file_test.stdout
+MOSTLYCLEANFILES += retain_symbols_file_test retain_symbols_file_test.in \
+ retain_symbols_file_test.stdout
+retain_symbols_file_test.so: basic_pic_test.o gcctestdir/ld
+ echo 'main' > retain_symbols_file_test.in
+ echo 't1' >> retain_symbols_file_test.in
+ echo '_ZN4t16bC1Ev' >> retain_symbols_file_test.in
+ echo '_ZNK4t20a3getEv' >> retain_symbols_file_test.in
+ echo '_Z3t18v' >> retain_symbols_file_test.in
+ echo '__tcf_0' >> retain_symbols_file_test.in
+ $(CXXLINK) -Bgcctestdir/ -shared -Wl,-retain-symbols-file,retain_symbols_file_test.in basic_pic_test.o
+retain_symbols_file_test.stdout: retain_symbols_file_test.so
+ $(TEST_NM) -C retain_symbols_file_test.so > $@
+
+
# Test that if the output file already exists and is empty,
# it will get execute permission.
check_PROGRAMS += permission_test
diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in
index 13cb340..36334ef 100644
--- a/gold/testsuite/Makefile.in
+++ b/gold/testsuite/Makefile.in
@@ -341,18 +341,25 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
# Test that hidden and internal symbols in the main program cannot be
# referenced by a shared library.
+
+# Test -retain-symbols-file.
@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@ hidden_test.sh \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ retain_symbols_file_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@ hidden_test.err \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ retain_symbols_file_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 \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ alt/libexclude_libs_test_3.a \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ discard_locals_test.syms \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ hidden_test hidden_test.err
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ hidden_test hidden_test.err \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ retain_symbols_file_test \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ retain_symbols_file_test.in \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ retain_symbols_file_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) \
@@ -2956,6 +2963,16 @@ uninstall-am:
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(LINK) -Bgcctestdir/ -Wl,-R,. hidden_test_main.o libhidden.so 2>hidden_test.err
@GCC_TRUE@@NATIVE_LINKER_TRUE@hidden_test.err: hidden_test
@GCC_TRUE@@NATIVE_LINKER_TRUE@ @touch hidden_test.err
+@GCC_TRUE@@NATIVE_LINKER_TRUE@retain_symbols_file_test.so: basic_pic_test.o gcctestdir/ld
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ echo 'main' > retain_symbols_file_test.in
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ echo 't1' >> retain_symbols_file_test.in
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ echo '_ZN4t16bC1Ev' >> retain_symbols_file_test.in
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ echo '_ZNK4t20a3getEv' >> retain_symbols_file_test.in
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ echo '_Z3t18v' >> retain_symbols_file_test.in
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ echo '__tcf_0' >> retain_symbols_file_test.in
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -shared -Wl,-retain-symbols-file,retain_symbols_file_test.in basic_pic_test.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@retain_symbols_file_test.stdout: retain_symbols_file_test.so
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_NM) -C retain_symbols_file_test.so > $@
@GCC_TRUE@@NATIVE_LINKER_TRUE@permission_test: basic_test.o gcctestdir/ld
@GCC_TRUE@@NATIVE_LINKER_TRUE@ umask 022; \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ rm -f $@; \
diff --git a/gold/testsuite/retain_symbols_file_test.sh b/gold/testsuite/retain_symbols_file_test.sh
new file mode 100755
index 0000000..ba0afd6
--- /dev/null
+++ b/gold/testsuite/retain_symbols_file_test.sh
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+# retain_symbols_file_test.sh -- a test case for -retain-symbols-file
+
+# Copyright 2009 Free Software Foundation, Inc.
+# Written by Craig Silverstein <csilvers@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.
+
+# The Makefile tries linking simple_test.o with -retain-symbols-file.
+# It then runs nm over the results. We check that the output is right.
+
+check_present()
+{
+ if ! grep -q "$1" retain_symbols_file_test.out
+ then
+ echo "Did not find expected symbol $1 in retain_symbols_file_test.out"
+ exit 1
+ fi
+}
+
+check_absent()
+{
+ if grep -q "$1" retain_symbols_file_test.out
+ then
+ echo "Found unexpected symbol $1 in retain_symbols_file_test.out"
+ exit 1
+ fi
+}
+
+check_present 't1'
+check_present 't16b::t16b()'
+check_present 't20a::get()'
+check_present 't18()'
+check_present '__tcf_0'
+check_absent 't10'
+check_absent 't1()'
+check_absent 't16b::t()'
+
+exit 0