Add 2 tests for PR ld/11812.
[binutils.git] / ld / testsuite / ld-scripts / script.exp
blob66c62f50edb63f171c7ec19d148f2a57b8e8251c
1 # Test basic linker script functionality
2 # By Ian Lance Taylor, Cygnus Support
3 # Copyright 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007, 2009
4 # Free Software Foundation, Inc.
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 "script"
25 if ![ld_assemble $as $srcdir/$subdir/script.s tmpdir/script.o] {
26 unresolved $testname
27 return
30 proc check_script { } {
31 global nm
32 global testname
33 global nm_output
35 if ![ld_nm $nm "" tmpdir/script] {
36 unresolved $testname
37 return
40 if {![info exists nm_output(text_start)] \
41 || ![info exists nm_output(text_end)] \
42 || ![info exists nm_output(data_start)] \
43 || ![info exists nm_output(data_end)]} {
44 send_log "bad output from nm\n"
45 verbose "bad output from nm"
46 fail $testname
47 return
50 set passes 1
51 set text_end 0x104
52 set data_end 0x1004
54 if [istarget *c4x*-*-*] then {
55 set text_end 0x101
56 set data_end 0x1001
59 if [istarget *c54x*-*-*] then {
60 set text_end 0x102
61 set data_end 0x1002
64 if {$nm_output(text_start) != 0x100} {
65 send_log "text_start == $nm_output(text_start)\n"
66 verbose "text_start == $nm_output(text_start)"
67 set passes 0
70 if {$nm_output(text_end) < $text_end \
71 || $nm_output(text_end) > 0x110} {
72 send_log "text_end == $nm_output(text_end)\n"
73 verbose "text_end == $nm_output(text_end)"
74 set passes 0
77 if {$nm_output(data_start) != 0x1000} {
78 send_log "data_start == $nm_output(data_start)\n"
79 verbose "data_start == $nm_output(data_start)"
80 set passes 0
83 if {$nm_output(data_end) < $data_end \
84 || $nm_output(data_end) > 0x1010} {
85 send_log "data_end == $nm_output(data_end)\n"
86 verbose "data_end == $nm_output(data_end)"
87 set passes 0
90 if { $passes } {
91 pass $testname
92 } else {
93 fail $testname
97 # PE targets need to set the image base to 0 to avoid complications from nm.
98 set flags ""
99 if {[istarget "*-*-pe*"] \
100 || [istarget "*-*-cygwin*"] \
101 || [istarget "*-*-mingw*"] \
102 || [istarget "*-*-winnt*"] \
103 || [istarget "*-*-nt"] \
104 || [istarget "*-*-interix*"] } then {
105 set flags "--image-base 0"
108 if ![ld_simple_link $ld tmpdir/script "$flags -T $srcdir/$subdir/script.t tmpdir/script.o"] {
109 fail $testname
110 } else {
111 check_script
114 set testname "MRI script"
116 if ![ld_simple_link $ld tmpdir/script "$flags -c $srcdir/$subdir/scriptm.t"] {
117 fail $testname
118 } else {
119 check_script
122 set testname "MEMORY"
124 if ![ld_simple_link $ld tmpdir/script "$flags -T $srcdir/$subdir/memory.t tmpdir/script.o"] {
125 fail $testname
126 } else {
127 check_script
130 set test_script_list [glob $srcdir/$subdir/region-alias-*.t]
132 foreach test_script $test_script_list {
133 if ![ld_simple_link $ld tmpdir/script "$flags -T $test_script tmpdir/script.o"] {
134 xfail "REGION_ALIAS: $test_script"
135 } else {
136 xpass "REGION_ALIAS: $test_script"