diff options
author | Sriraman Tallam <tmsriram@google.com> | 2012-12-19 02:55:15 +0000 |
---|---|---|
committer | Sriraman Tallam <tmsriram@google.com> | 2012-12-19 02:55:15 +0000 |
commit | 28f2a4ac6f40b5bf1fccc1fa320b41f82f3c5cc9 (patch) | |
tree | 07a61340c8370a3db3f6fdafa7c020d26eaaf70e /gold/testsuite | |
parent | e0e51b23915fa452d757ee8e36d84324b6b53e7b (diff) | |
download | gdb-28f2a4ac6f40b5bf1fccc1fa320b41f82f3c5cc9.zip gdb-28f2a4ac6f40b5bf1fccc1fa320b41f82f3c5cc9.tar.gz gdb-28f2a4ac6f40b5bf1fccc1fa320b41f82f3c5cc9.tar.bz2 |
Group text sections with prefixes .text.unlikely,.text.hot and .text.startup
by default.
2012-12-18 Sriraman Tallam <tmsriram@google.com>
* layout.cc (Layout::is_section_name_prefix_grouped): New function.
* layout.h (Layout::is_section_name_prefix_grouped): New function.
* output.cc (Output_section::add_input_section): Check if section
name contains special prefix. Keep input sections to sort such
sections.
(Output_section::Input_section_sort_section_order_index_compare
::operator()): Group sections according to prefixes.
* (Output_section::sort_attached_input_sections): Add condition
to Input_section_entry constructor call.
* testsuite/Makefile.am (text_section_grouping): New test.
* testsuite/Makefile.in: Regenerate.
* testsuite/text_section_grouping.cc: New file.
* testsuite/text_section_grouping.sh: New file.
Diffstat (limited to 'gold/testsuite')
-rw-r--r-- | gold/testsuite/Makefile.am | 10 | ||||
-rw-r--r-- | gold/testsuite/Makefile.in | 11 | ||||
-rw-r--r-- | gold/testsuite/text_section_grouping.cc | 72 | ||||
-rwxr-xr-x | gold/testsuite/text_section_grouping.sh | 65 |
4 files changed, 158 insertions, 0 deletions
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am index c5c8a99..745e13d 100644 --- a/gold/testsuite/Makefile.am +++ b/gold/testsuite/Makefile.am @@ -250,6 +250,16 @@ final_layout: final_layout.o final_layout_sequence.txt gcctestdir/ld final_layout.stdout: final_layout $(TEST_NM) -n --synthetic final_layout > final_layout.stdout +check_SCRIPTS += text_section_grouping.sh +check_DATA += text_section_grouping.stdout +MOSTLYCLEANFILES += text_section_grouping +text_section_grouping.o: text_section_grouping.cc + $(CXXCOMPILE) -O0 -c -ffunction-sections -g -o $@ $< +text_section_grouping: text_section_grouping.o gcctestdir/ld + $(CXXLINK) -Bgcctestdir/ text_section_grouping.o +text_section_grouping.stdout: text_section_grouping + $(TEST_NM) -n --synthetic text_section_grouping > text_section_grouping.stdout + check_PROGRAMS += icf_virtual_function_folding_test MOSTLYCLEANFILES += icf_virtual_function_folding_test icf_virtual_function_folding_test.o: icf_virtual_function_folding_test.cc diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in index 6d9c630..b1058b4 100644 --- a/gold/testsuite/Makefile.in +++ b/gold/testsuite/Makefile.in @@ -81,6 +81,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_test.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_so_test.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ final_layout.sh \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ text_section_grouping.sh \ @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 \ @@ -111,6 +112,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_so_test_1.stdout \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_so_test_2.stdout \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ final_layout.stdout \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ text_section_grouping.stdout \ @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 \ @@ -122,6 +124,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_test icf_keep_unique_test \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_test icf_safe_so_test \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ final_layout \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ text_section_grouping \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ final_layout_sequence.txt \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_virtual_function_folding_test \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_preemptible_functions_test \ @@ -3701,6 +3704,8 @@ icf_safe_so_test.sh.log: icf_safe_so_test.sh @p='icf_safe_so_test.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) final_layout.sh.log: final_layout.sh @p='final_layout.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) +text_section_grouping.sh.log: text_section_grouping.sh + @p='text_section_grouping.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) icf_preemptible_functions_test.sh.log: icf_preemptible_functions_test.sh @p='icf_preemptible_functions_test.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) icf_string_merge_test.sh.log: icf_string_merge_test.sh @@ -4348,6 +4353,12 @@ uninstall-am: @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -Wl,--section-ordering-file,final_layout_sequence.txt final_layout.o @GCC_TRUE@@NATIVE_LINKER_TRUE@final_layout.stdout: final_layout @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_NM) -n --synthetic final_layout > final_layout.stdout +@GCC_TRUE@@NATIVE_LINKER_TRUE@text_section_grouping.o: text_section_grouping.cc +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -O0 -c -ffunction-sections -g -o $@ $< +@GCC_TRUE@@NATIVE_LINKER_TRUE@text_section_grouping: text_section_grouping.o gcctestdir/ld +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ text_section_grouping.o +@GCC_TRUE@@NATIVE_LINKER_TRUE@text_section_grouping.stdout: text_section_grouping +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_NM) -n --synthetic text_section_grouping > text_section_grouping.stdout @GCC_TRUE@@NATIVE_LINKER_TRUE@icf_virtual_function_folding_test.o: icf_virtual_function_folding_test.cc @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -O0 -c -ffunction-sections -fPIE -g -o $@ $< @GCC_TRUE@@NATIVE_LINKER_TRUE@icf_virtual_function_folding_test: icf_virtual_function_folding_test.o gcctestdir/ld diff --git a/gold/testsuite/text_section_grouping.cc b/gold/testsuite/text_section_grouping.cc new file mode 100644 index 0000000..5a3a809 --- /dev/null +++ b/gold/testsuite/text_section_grouping.cc @@ -0,0 +1,72 @@ +// text_section_grouping.cc -- a test case for gold + +// Copyright 2012 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 .text sections are grouped +// according to prefix. .text.unlikely, .text.startup and .text.hot should +// be grouped and placed together. + +extern "C" +__attribute__ ((section(".text.hot.foo"))) +int hot_foo() +{ + return 1; +} + +extern "C" +__attribute__ ((section(".text.startup.foo"))) +int startup_foo() +{ + return 1; +} + +extern "C" +__attribute__ ((section(".text.unlikely.foo"))) +int unlikely_foo() +{ + return 1; +} + +extern "C" +__attribute__ ((section(".text.hot.bar"))) +int hot_bar() +{ + return 1; +} + +extern "C" +__attribute__ ((section(".text.startup.bar"))) +int startup_bar() +{ + return 1; +} + +extern "C" +__attribute__ ((section(".text.unlikely.bar"))) +int unlikely_bar() +{ + return 1; +} + +int main() +{ + return 1; +} diff --git a/gold/testsuite/text_section_grouping.sh b/gold/testsuite/text_section_grouping.sh new file mode 100755 index 0000000..a79836c --- /dev/null +++ b/gold/testsuite/text_section_grouping.sh @@ -0,0 +1,65 @@ +#!/bin/sh + +# text_section_grouping.sh -- test + +# Copyright 2012 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 .text sections are grouped +# according to prefix. .text.unlikely, .text.startup and .text.hot should +# be grouped and placed together. + +set -e + +check() +{ + awk " +BEGIN { saw1 = 0; saw2 = 0; err = 0; } +/.*$2\$/ { saw1 = 1; } +/.*$3\$/ { + saw2 = 1; + if (!saw1) + { + printf \"layout of $2 and $3 is not right\\n\"; + err = 1; + exit 1; + } + } +END { + if (!saw1 && !err) + { + printf \"did not see $2\\n\"; + exit 1; + } + if (!saw2 && !err) + { + printf \"did not see $3\\n\"; + exit 1; + } + }" $1 +} + +# addr (unlikely_*) < addr (startup_*) < addr (hot_*) +check text_section_grouping.stdout "unlikely_foo" "startup_foo" +check text_section_grouping.stdout "startup_foo" "hot_foo" +check text_section_grouping.stdout "unlikely_bar" "startup_bar" +check text_section_grouping.stdout "startup_bar" "hot_bar" +check text_section_grouping.stdout "unlikely_foo" "startup_bar" +check text_section_grouping.stdout "startup_foo" "hot_bar" |