old-cross-binutils/gold/testsuite/script_test_12i.t

64 lines
1.8 KiB
Perl
Raw Normal View History

Fix gold to group sections correctly via linker script. In PR 15370, it is noted that gold does not distinguish between "*(.foo .bar)" and "*(.foo) *(.bar)" in linker scripts. In both cases, gold groups all .foo sections together, followed by all .bar sections, whereas in the first case, it should collect all .foo and .bar sections in the order seen. If you add sort specs, the Gnu linker has some bizarre corner cases that I do not try to replicate. In particular, "*(SORT_BY_NAME(.foo) SORT_BY_NAME(.bar))" does the same thing as "*(.foo) *(.bar)". But if you apply a sort spec to just one of several patterns, say, "*(SORT_BY_NAME(.foo) .bar)", the Gnu linker will collect any .bar section it sees before the first .foo, then all .foo sections, then all remaining .bar sections. With this patch, if any of the input patterns have a sort spec, gold will group them all as it did before; e.g., all .foo sections followed by all .bar sections. 2015-06-03 Cary Coutant <ccoutant@gmail.com> gold/ PR gold/15370 * script-sections.cc (Output_section_element_input::set_section_addresses): When there are several patterns with no sort spec, put all sections in the same bin. * testsuite/Makefile.am (script_test_12): New testcase. (script_test_12i): New testcase. * testsuite/Makefile.in: Regenerate. * testsuite/script_test_12.t: New test linker script. * testsuite/script_test_12i.t: New test linker script. * testsuite/script_test_12a.c: New test source file. * testsuite/script_test_12b.c: New test source file.
2015-06-04 02:11:42 +00:00
/* script_test_12i.t -- linker script test 12 for gold, with interleaved sections
Copyright (C) 2008-2015 Free Software Foundation, Inc.
Written by Cary Coutant <ccoutant@gmail.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. */
interleaved = 1;
SECTIONS
{
. = 0x400000 + SIZEOF_HEADERS;
.interp : { *(.interp) }
.note : { *(.note .note.*) }
.rel.dyn : { *(.rel.dyn) }
.rela.dyn : { *(.rela.dyn) }
.rel.plt : { *(.rel.plt) }
.rela.plt : { *(.rela.plt) }
.init : { *(.init) }
.plt : { *(.plt) }
.text : { *(.text) }
.fini : { *(.fini) }
.rodata : { *(.rodata .rodata.*) }
.eh_frame_hdr : { *(.eh_frame_hdr) }
.eh_frame : { *(.eh_frame) }
. = DATA_SEGMENT_ALIGN(0x1000, 0x1000);
.init_array : {
__init_array_start = .;
*(.init_array);
__init_array_end = .;
}
.fini_array : { *(.fini_array) }
.jcr : { *(.jcr) }
.dynamic : { *(.dynamic) }
.got : { *(.got) }
.got.plt : { *(.got.plt) }
.data : { *(.data) }
.test : {
test_array_start = .;
*(.x1) *(.x2) *(.x3)
test_array_end = .;
}
.bss : { *(.bss) }
}