* layout.cc (Layout::layout): Do not do default sorting for text sections when section ordering is specified. (make_output_section): Ditto. * testsuite/plugin_final_layout.cc: Name the sections for the functions to catch reordering issues. Index: layout.cc =================================================================== RCS file: /cvs/src/src/gold/layout.cc,v retrieving revision 1.242 diff -u -u -p -r1.242 layout.cc --- layout.cc 21 Dec 2012 06:24:31 -0000 1.242 +++ layout.cc 16 Jan 2013 22:13:38 -0000 @@ -1150,6 +1150,7 @@ Layout::layout(Sized_relobj_filescript_options_->saw_sections_clause() + && !this->is_section_ordering_specified() && !parameters->options().relocatable() && Layout::special_ordering_of_input_section(name) >= 0) os->set_must_sort_attached_input_sections(); @@ -1646,6 +1647,7 @@ Layout::make_output_section(const char* // need to know that this might happen before we attach any input // sections. if (!this->script_options_->saw_sections_clause() + && !this->is_section_ordering_specified() && !parameters->options().relocatable() && strcmp(name, ".text") == 0) os->set_may_sort_attached_input_sections(); cvs diff: Diffing po cvs diff: Diffing testsuite Index: testsuite/plugin_final_layout.cc =================================================================== RCS file: /cvs/src/src/gold/testsuite/plugin_final_layout.cc,v retrieving revision 1.1 diff -u -u -p -r1.1 plugin_final_layout.cc --- testsuite/plugin_final_layout.cc 29 Sep 2011 23:45:57 -0000 1.1 +++ testsuite/plugin_final_layout.cc 16 Jan 2013 22:13:38 -0000 @@ -21,16 +21,22 @@ // MA 02110-1301, USA. // The goal of this program is to verify if section ordering -// via plugins happens correctly. +// via plugins happens correctly. Also, test is plugin based ordering +// overrides default text section ordering where ".text.hot" sections +// are grouped. The plugin does not want foo and baz next to each other. +// Plugin section order is foo() followed by bar() and then baz(). +__attribute__ ((section(".text._Z3barv"))) void bar () { } +__attribute__ ((section(".text.hot._Z3bazv"))) void baz () { } +__attribute__ ((section(".text.hot._Z3foov"))) void foo () { }