Typo fix in most recent entry.
[binutils.git] / ld / testsuite / ld-elf / sec-to-seg.exp
bloba576fcefcd22fdeb317dc04f9483fbedeab97b8b
1 # Test the assigment of sections to segments.
3 # Copyright 2008 Free Software Foundation, Inc.
4 # Contributed by Red Hat.
6 # This file is part of the GNU Binutils.
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 # MA 02110-1301, USA.
23 set testname "assignment of ELF sections to segments"
25 if {! [is_elf_format] } {
26 unsupported $testname
27 return
30 if { ! [ld_assemble $as $srcdir/$subdir/sec-to-seg1.s tmpdir/sec-to-seg1.o]
31 || ! [ld_assemble $as $srcdir/$subdir/sec-to-seg2.s tmpdir/sec-to-seg2.o]} then {
32 unresolved $testname
33 return
36 proc sec_to_seg_test { testname scriptname same_seg } {
37 global srcdir
38 global subdir
39 global ld
40 global exec_output
41 global READELF
43 if {! [ld_simple_link $ld tmpdir/sec-to-seg "-T $srcdir/$subdir/$scriptname tmpdir/sec-to-seg1.o tmpdir/sec-to-seg2.o"] } then {
44 fail $testname
45 return 0
48 send_log "$READELF --program-headers --section-headers tmpdir/sec-to-seg\n"
49 set exec_output [run_host_cmd "$READELF" "--program-headers --section-headers tmpdir/sec-to-seg"]
51 if { $same_seg == 1 } {
52 if {! [regexp ".*.sec1 .sec2" $exec_output] } {
53 fail $testname
54 return 0
56 } else {
57 if { [regexp ".*.sec1 .sec2" $exec_output] } {
58 fail $testname
59 return 0
63 pass $testname
64 return 1
67 # Assuming a pagesize of 0x1000 then:
69 # Test Sec1 End Sec 2 Start Expected Result
70 # ---- -------- ----------- ---------------
71 # A 00001042 00001043 Both sections on same page: assign to same segment.
72 # B 00001042 00002044 Sections on adjacent pages: assign to same segment.
73 # C 00001042 00003044 Sections on disjoint pages: assign to separate segments.
75 # These targets have a pagesize of 1, so they will always end up
76 # placing the two sections in separate segments in the B test.
77 if { [istarget avr-*-*]
78 || [istarget cr16-*-*]
79 || [istarget crx-*-*]
80 || [istarget dlx-*-*]
81 || [istarget h8300-*-*]
82 || [istarget ip2k-*-*]
83 || [istarget m32r-*-*]
84 || [istarget m88k-*-*]
85 || [istarget msp430-*-*]
86 } {
87 set B_test_same_seg 0
88 } else {
89 set B_test_same_seg 1
92 sec_to_seg_test "assignment of ELF sections to segments (same page)" "sec-to-seg-script-same-page.t" 1
93 sec_to_seg_test "assignment of ELF sections to segments (adjacent pages)" "sec-to-seg-script-adjoining-pages.t" $B_test_same_seg
94 sec_to_seg_test "assignment of ELF sections to segments (disjoint pages)" "sec-to-seg-script-disjoint-pages.t" 0
97 # FIXME: Add more tests to check other rules of section to segment assignment.