aboutsummaryrefslogtreecommitdiff
path: root/gold/testsuite/icf_string_merge_test.cc
diff options
context:
space:
mode:
authorSriraman Tallam <tmsriram@google.com>2010-04-20 21:13:30 +0000
committerSriraman Tallam <tmsriram@google.com>2010-04-20 21:13:30 +0000
commitce97fa81e0c46d216b80b143ad8c02fff6906fef (patch)
tree539a9d93c76d2113b92da17405b144eba8fa92c5 /gold/testsuite/icf_string_merge_test.cc
parentec31cde5942e935e74f6ff919ffc480dfa2f1bac (diff)
downloadgdb-ce97fa81e0c46d216b80b143ad8c02fff6906fef.zip
gdb-ce97fa81e0c46d216b80b143ad8c02fff6906fef.tar.gz
gdb-ce97fa81e0c46d216b80b143ad8c02fff6906fef.tar.bz2
2010-04-18 Sriraman Tallam <tmsriram@google.com>
* icf.cc (get_section_contents): Check for preemptible functions. Ignore addend when appropriate. * symtab.cc (should_add_dynsym_entry): Add new parameter. Check for section folded. (add_from_relobj): Check for section folded. (set_dynsym_indexes): Fix call to should_add_dynsym_entry. * symtab.h (should_add_dynsym_entry): Add new parameter. * target-reloc.h (scan_relocs): Check for section folded. * x86_64.cc (Target_x86_64::Scan::possible_function_pointer_reloc): Check reloc types for function pointers in shared objects. * testsuite/Makefile.am (icf_virtual_function_folding_test): New test case. (icf_preemptible_functions_test): New test case. (icf_string_merge_test): New test case. * testsuite.Makefile.in: Regenerate. * testsuite/icf_safe_so_test.sh: Change to not fold foo_glob and bar_glob. Refactor code. * testsuite/icf_preemptible_functions_test.cc: New file. * testsuite/icf_preemptible_functions_test.sh: New file. * testsuite/icf_string_merge_test.cc: New file. * testsuite/icf_string_merge_test.sh: New file. * testsuite/icf_virtual_function_folding_test.cc: New file. * testsuite/icf_virtual_function_folding_test.sh: New file.
Diffstat (limited to 'gold/testsuite/icf_string_merge_test.cc')
-rw-r--r--gold/testsuite/icf_string_merge_test.cc50
1 files changed, 50 insertions, 0 deletions
diff --git a/gold/testsuite/icf_string_merge_test.cc b/gold/testsuite/icf_string_merge_test.cc
new file mode 100644
index 0000000..b1e1191
--- /dev/null
+++ b/gold/testsuite/icf_string_merge_test.cc
@@ -0,0 +1,50 @@
+// icf_string_merge_test.cc -- a test case for gold
+
+// Copyright 2010 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 is strings are handled correctly
+// by ICF. ICF inlines strings that can be merged. In some cases, the
+// addend of the relocation pointing to a string merge section must be
+// ignored. This program has no pair of identical functions that can be
+// folded. However, if the addend is not ignored then get2 and get3 will
+// become identical.
+
+const char* const str1 = "aaaaaaaaaastr1";
+const char* const str2 = "bbbbaaaaaastr1";
+const char* const str3 = "cccccaaaaastr1";
+
+const char* get1()
+{
+ return str1;
+}
+const char* get2()
+{
+ return str2;
+}
+
+const char* get3()
+{
+ return str3;
+}
+int main()
+{
+ return 0;
+}