update copyright dates
[deliverable/binutils-gdb.git] / ld / testsuite / ld-scripts / script.exp
CommitLineData
252b5132
RH
1# Test basic linker script functionality
2# By Ian Lance Taylor, Cygnus Support
aa820537 3# Copyright 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007, 2009
a2b64bed
NC
4# Free Software Foundation, Inc.
5#
f96b4a7b
NC
6# This file is part of the GNU Binutils.
7#
8# This program is free software; you can redistribute it and/or modify
a2b64bed 9# it under the terms of the GNU General Public License as published by
f96b4a7b 10# the Free Software Foundation; either version 3 of the License, or
a2b64bed 11# (at your option) any later version.
f96b4a7b 12#
a2b64bed
NC
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.
f96b4a7b 17#
a2b64bed
NC
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
f96b4a7b
NC
20# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21# MA 02110-1301, USA.
252b5132
RH
22
23set testname "script"
24
25if ![ld_assemble $as $srcdir/$subdir/script.s tmpdir/script.o] {
26 unresolved $testname
27 return
28}
29
30proc check_script { } {
31 global nm
32 global testname
33 global nm_output
34
992c450d 35 if ![ld_nm $nm "" tmpdir/script] {
252b5132 36 unresolved $testname
3ec57632
NC
37 return
38 }
39
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
48 }
49
50 set passes 1
51 set text_end 0x104
52 set data_end 0x1004
53
54 if [istarget *c4x*-*-*] then {
55 set text_end 0x101
56 set data_end 0x1001
57 }
58
59 if [istarget *c54x*-*-*] then {
60 set text_end 0x102
61 set data_end 0x1002
62 }
63
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
68 }
69
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
75 }
76
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
81 }
82
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
88 }
89
90 if { $passes } {
91 pass $testname
252b5132 92 } else {
3ec57632 93 fail $testname
252b5132
RH
94 }
95}
96
777690b6
ILT
97# PE targets need to set the image base to 0 to avoid complications from nm.
98set flags ""
99if {[istarget "*-*-pe*"] \
100 || [istarget "*-*-cygwin*"] \
99ad8390 101 || [istarget "*-*-mingw*"] \
777690b6 102 || [istarget "*-*-winnt*"] \
3ec57632 103 || [istarget "*-*-nt"] \
777690b6
ILT
104 || [istarget "*-*-interix*"] } then {
105 set flags "--image-base 0"
106}
107
108if ![ld_simple_link $ld tmpdir/script "$flags -T $srcdir/$subdir/script.t tmpdir/script.o"] {
252b5132
RH
109 fail $testname
110} else {
111 check_script
112}
113
114set testname "MRI script"
115
777690b6 116if ![ld_simple_link $ld tmpdir/script "$flags -c $srcdir/$subdir/scriptm.t"] {
252b5132
RH
117 fail $testname
118} else {
119 check_script
120}
3ec57632
NC
121
122set testname "MEMORY"
123
124if ![ld_simple_link $ld tmpdir/script "$flags -T $srcdir/$subdir/memory.t tmpdir/script.o"] {
125 fail $testname
126} else {
127 check_script
128}
4a93e180
NC
129
130set test_script_list [glob $srcdir/$subdir/region-alias-*.t]
131
132foreach 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"
137 }
138}
This page took 0.588556 seconds and 4 git commands to generate.