diff options
author | Cary Coutant <ccoutant@google.com> | 2013-04-29 17:15:09 +0000 |
---|---|---|
committer | Cary Coutant <ccoutant@google.com> | 2013-04-29 17:15:09 +0000 |
commit | e31908b642bf3602c06fe64ab574a865307e45b0 (patch) | |
tree | 10a5d3ebaad183647e9da9ef874b2fc7fed3aa9a /gold/testsuite | |
parent | 5dad867ccace0a74c90b729372c9c01392756875 (diff) | |
download | gdb-e31908b642bf3602c06fe64ab574a865307e45b0.zip gdb-e31908b642bf3602c06fe64ab574a865307e45b0.tar.gz gdb-e31908b642bf3602c06fe64ab574a865307e45b0.tar.bz2 |
2013-04-29 Alexander Ivchenko <alexander.ivchenko@intel.com>
gold/
* output.cc (Output_section::add_merge_input_section): Allow
to merge sections if the alignment is more than character size.
* merge.h (Output_merge_string::Output_merge_string): Remove
assert.
* merge.cc (Output_merge_string<Char_type>::do_add_input_section): Count
only not-null strings. Check the alignment of strings.
* stringpool.h
(Stringpool_template<Stringpool_char>::Stringpool_template): Add
alignment as the argument.
(Stringpool_template<Stringpool_char>::addralign_): New class member.
* stringpool.cc (Stringpool_template<Stringpool_char>::new_key_offset):
Align non-zero length strings according to the addralign_.
(Stringpool_template<Stringpool_char>::set_string_offsets):
Updating offsets according to the given alignment.
* testsuite/Makefile.am (text_section_grouping): Test if string
literals are getting merged.
* testsuite/Makefile.in: Regenerate.
* testsuite/merge_string_literals_1.c: New file.
* testsuite/merge_string_literals_2.c: Ditto.
* testsuite/merge_string_literals.sh: Ditto.
Diffstat (limited to 'gold/testsuite')
-rw-r--r-- | gold/testsuite/Makefile.am | 12 | ||||
-rw-r--r-- | gold/testsuite/Makefile.in | 13 | ||||
-rwxr-xr-x | gold/testsuite/merge_string_literals.sh | 41 | ||||
-rw-r--r-- | gold/testsuite/merge_string_literals_1.c | 31 | ||||
-rw-r--r-- | gold/testsuite/merge_string_literals_2.c | 31 |
5 files changed, 128 insertions, 0 deletions
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am index 4d02925..a1ac474 100644 --- a/gold/testsuite/Makefile.am +++ b/gold/testsuite/Makefile.am @@ -329,6 +329,18 @@ icf_sht_rel_addend_test: icf_sht_rel_addend_test_1.o icf_sht_rel_addend_test_2.o icf_sht_rel_addend_test.stdout: icf_sht_rel_addend_test $(TEST_NM) icf_sht_rel_addend_test > icf_sht_rel_addend_test.stdout +check_SCRIPTS += merge_string_literals.sh +check_DATA += merge_string_literals.stdout +MOSTLYCLEANFILES += merge_string_literals +merge_string_literals_1.o: merge_string_literals_1.c + $(CXXCOMPILE) -O2 -c -fPIC -g -o $@ $< +merge_string_literals_2.o: merge_string_literals_2.c + $(CXXCOMPILE) -O2 -c -fPIC -g -o $@ $< +merge_string_literals: merge_string_literals_1.o merge_string_literals_2.o gcctestdir/ld + $(CXXLINK) -Bgcctestdir/ merge_string_literals_1.o merge_string_literals_2.o -O2 -shared -nostdlib +merge_string_literals.stdout: merge_string_literals + $(TEST_OBJDUMP) -s -j.rodata merge_string_literals > merge_string_literals.stdout + check_PROGRAMS += basic_test check_PROGRAMS += basic_pic_test basic_test.o: basic_test.cc diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in index fa9e80f..7d159e7 100644 --- a/gold/testsuite/Makefile.in +++ b/gold/testsuite/Makefile.in @@ -85,6 +85,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_preemptible_functions_test.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_string_merge_test.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_sht_rel_addend_test.sh \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ merge_string_literals.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 \ @@ -119,6 +120,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_preemptible_functions_test.stdout \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_string_merge_test.stdout \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_sht_rel_addend_test.stdout \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ merge_string_literals.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@am__append_4 = incremental_test \ @@ -140,6 +142,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_preemptible_functions_test \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_string_merge_test \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_sht_rel_addend_test \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ merge_string_literals \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_shared.dbg \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ alt/weak_undef_lib.so @GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_5 = icf_virtual_function_folding_test \ @@ -3755,6 +3758,8 @@ icf_string_merge_test.sh.log: icf_string_merge_test.sh @p='icf_string_merge_test.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) icf_sht_rel_addend_test.sh.log: icf_sht_rel_addend_test.sh @p='icf_sht_rel_addend_test.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) +merge_string_literals.sh.log: merge_string_literals.sh + @p='merge_string_literals.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) two_file_shared.sh.log: two_file_shared.sh @p='two_file_shared.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) weak_plt.sh.log: weak_plt.sh @@ -4440,6 +4445,14 @@ uninstall-am: @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -Wl,--icf=all icf_sht_rel_addend_test_1.o icf_sht_rel_addend_test_2.o @GCC_TRUE@@NATIVE_LINKER_TRUE@icf_sht_rel_addend_test.stdout: icf_sht_rel_addend_test @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_NM) icf_sht_rel_addend_test > icf_sht_rel_addend_test.stdout +@GCC_TRUE@@NATIVE_LINKER_TRUE@merge_string_literals_1.o: merge_string_literals_1.c +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -O2 -c -fPIC -g -o $@ $< +@GCC_TRUE@@NATIVE_LINKER_TRUE@merge_string_literals_2.o: merge_string_literals_2.c +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -O2 -c -fPIC -g -o $@ $< +@GCC_TRUE@@NATIVE_LINKER_TRUE@merge_string_literals: merge_string_literals_1.o merge_string_literals_2.o gcctestdir/ld +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ merge_string_literals_1.o merge_string_literals_2.o -O2 -shared -nostdlib +@GCC_TRUE@@NATIVE_LINKER_TRUE@merge_string_literals.stdout: merge_string_literals +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_OBJDUMP) -s -j.rodata merge_string_literals > merge_string_literals.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/merge_string_literals.sh b/gold/testsuite/merge_string_literals.sh new file mode 100755 index 0000000..486a895 --- /dev/null +++ b/gold/testsuite/merge_string_literals.sh @@ -0,0 +1,41 @@ +#!/bin/sh + +# merge_string_literals.sh -- test + +# Copyright 2013 Free Software Foundation, Inc. +# Written by Alexander Ivchenko <alexander.ivchenko@intel.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 check whether string literals from different +# object files are merged together + +set -e + +check() +{ + number_of_occurrence=`grep $2 ./$1 -o| wc -l` + if [ $number_of_occurrence != $3 ] + then + echo "String literals were not merged" + exit 1 + fi +} + +# If string literals were merged, then "abcd" appears two times +check merge_string_literals.stdout "abcd" 2 diff --git a/gold/testsuite/merge_string_literals_1.c b/gold/testsuite/merge_string_literals_1.c new file mode 100644 index 0000000..fc0487c --- /dev/null +++ b/gold/testsuite/merge_string_literals_1.c @@ -0,0 +1,31 @@ +// merge_string_literals_1.c -- a test case for gold + +// Copyright 2013 Free Software Foundation, Inc. +// Written by Alexander Ivchenko <alexander.ivchenko@intel.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 check whether string literals from different +// object files are merged together + +const char* bar1() { + return "abcdefghijklmnopqrstuvwxyz0123456789"; +} +const char* bar1_short() { + return "abcdef"; +} diff --git a/gold/testsuite/merge_string_literals_2.c b/gold/testsuite/merge_string_literals_2.c new file mode 100644 index 0000000..d1185cd --- /dev/null +++ b/gold/testsuite/merge_string_literals_2.c @@ -0,0 +1,31 @@ +// merge_string_literals_2.c -- a test case for gold + +// Copyright 2013 Free Software Foundation, Inc. +// Written by Alexander Ivchenko <alexander.ivchenko@intel.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 check whether string literals from different +// object files are merged together + +const char* bar2() { + return "abcdefghijklmnopqrstuvwxyz0123456789"; +} +const char* bar2_short() { + return "abcdef"; +} |