diff options
author | Sriraman Tallam <tmsriram@google.com> | 2009-08-12 19:03:16 +0000 |
---|---|---|
committer | Sriraman Tallam <tmsriram@google.com> | 2009-08-12 19:03:16 +0000 |
commit | 48c187ced8fcf0c09c26ab1782e63752bf206b4e (patch) | |
tree | 139f6a887edb3544c108164fee359016f5a5a48f /gold/testsuite | |
parent | 645afe0c5b028b013231f5890f66376e4dfc811d (diff) | |
download | gdb-48c187ced8fcf0c09c26ab1782e63752bf206b4e.zip gdb-48c187ced8fcf0c09c26ab1782e63752bf206b4e.tar.gz gdb-48c187ced8fcf0c09c26ab1782e63752bf206b4e.tar.bz2 |
Sriraman Tallam <tmsriram@google.com>
* icf.cc (Icf::find_identical_sections): Unfold symbols that have
been maked as --keep-unique.
(Icf::unfold_section): New function.
* icf.h (Icf::unfold_section): New function.
* options.h (General_options::keep_unique): New option.
* testsuite/Makefile.am: Add commands to build icf_keep_unique_test.
* testsuite/Makefile.in: Regenerate.
* testsuite/icf_keep_unique_test.sh: New file.
* testsuite/icf_keep_unique_test.cc: New file.
Diffstat (limited to 'gold/testsuite')
-rw-r--r-- | gold/testsuite/Makefile.am | 8 | ||||
-rw-r--r-- | gold/testsuite/Makefile.in | 8 | ||||
-rw-r--r-- | gold/testsuite/icf_keep_unique_test.cc | 39 | ||||
-rwxr-xr-x | gold/testsuite/icf_keep_unique_test.sh | 39 |
4 files changed, 94 insertions, 0 deletions
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am index 6e3169d..e8d03f5 100644 --- a/gold/testsuite/Makefile.am +++ b/gold/testsuite/Makefile.am @@ -133,6 +133,14 @@ icf_test: icf_test.o gcctestdir/ld icf_test.stdout: icf_test $(TEST_NM) -C icf_test > icf_test.stdout +check_SCRIPTS += icf_keep_unique_test.sh +check_DATA += icf_keep_unique_test.stdout +icf_keep_unique_test.o: icf_keep_unique_test.cc + $(CXXCOMPILE) -O0 -c -ffunction-sections -g -o $@ $< +icf_keep_unique_test: icf_keep_unique_test.o gcctestdir/ld + $(CXXLINK) -Bgcctestdir/ -Wl,--icf -Wl,--keep-unique,_Z11unique_funcv icf_keep_unique_test.o +icf_keep_unique_test.stdout: icf_keep_unique_test + $(TEST_NM) -C icf_keep_unique_test > icf_keep_unique_test.stdout check_PROGRAMS += basic_test check_PROGRAMS += basic_static_test diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in index d3a547e..d3598d3 100644 --- a/gold/testsuite/Makefile.in +++ b/gold/testsuite/Makefile.in @@ -58,6 +58,7 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \ # and --dynamic-list-cpp-typeinfo @GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_1 = gc_comdat_test.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_tls_test.sh icf_test.sh \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_keep_unique_test.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_shared.sh weak_plt.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ debug_msg.sh undef_symbol.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_1.sh ver_test_2.sh \ @@ -77,6 +78,7 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_2 = gc_comdat_test.stdout \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_tls_test.stdout \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_test.stdout \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_keep_unique_test.stdout \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_shared.dbg \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_plt_shared.so debug_msg.err \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ debug_msg_so.err \ @@ -2337,6 +2339,12 @@ uninstall-am: uninstall-info-am @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -Wl,--icf icf_test.o @GCC_TRUE@@NATIVE_LINKER_TRUE@icf_test.stdout: icf_test @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_NM) -C icf_test > icf_test.stdout +@GCC_TRUE@@NATIVE_LINKER_TRUE@icf_keep_unique_test.o: icf_keep_unique_test.cc +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -O0 -c -ffunction-sections -g -o $@ $< +@GCC_TRUE@@NATIVE_LINKER_TRUE@icf_keep_unique_test: icf_keep_unique_test.o gcctestdir/ld +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -Wl,--icf -Wl,--keep-unique,_Z11unique_funcv icf_keep_unique_test.o +@GCC_TRUE@@NATIVE_LINKER_TRUE@icf_keep_unique_test.stdout: icf_keep_unique_test +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_NM) -C icf_keep_unique_test > icf_keep_unique_test.stdout @GCC_TRUE@@NATIVE_LINKER_TRUE@basic_test.o: basic_test.cc @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -O0 -c -o $@ $< @GCC_TRUE@@NATIVE_LINKER_TRUE@basic_test: basic_test.o gcctestdir/ld diff --git a/gold/testsuite/icf_keep_unique_test.cc b/gold/testsuite/icf_keep_unique_test.cc new file mode 100644 index 0000000..37f6437 --- /dev/null +++ b/gold/testsuite/icf_keep_unique_test.cc @@ -0,0 +1,39 @@ +// icf_keep_unique_test.cc -- a test case for gold + +// Copyright 2009 Free Software Foundation, Inc. +// Written by Sriraman Tallam <tmsriram@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 goal of this program is to verify if --keep-unique works +// as intended when used with --icf. + +int kept_func() +{ + return 0; +} + +int unique_func() +{ + return 0; +} + +int main() +{ + return 1; +} diff --git a/gold/testsuite/icf_keep_unique_test.sh b/gold/testsuite/icf_keep_unique_test.sh new file mode 100755 index 0000000..c267373 --- /dev/null +++ b/gold/testsuite/icf_keep_unique_test.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +# icf_keep_unique_test.sh -- test --icf --keep-unique + +# Copyright 2009 Free Software Foundation, Inc. +# Written by Sriraman Tallam <tmsriram@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 goal of this program is to verify if --keep-unique works +# as intended when used with --icf. + +check() +{ + func_addr_1=`grep $2 $1 | awk '{print $1}'` + func_addr_2=`grep $3 $1 | awk '{print $1}'` + if [ $func_addr_1 = $func_addr_2 ] + then + echo "Identical Code Folding with keep-unique failed to unfold" $2 + exit 1 + fi +} + +check icf_keep_unique_test.stdout "kept_func" "unique_func" |