* config/mh-mingw32: Delete.
[binutils.git] / ld / testsuite / ld-scripts / script.exp
blob7e6ba2b61f9d3e3ec8c7e18d728a9ff49f36bfea
1 # Test basic linker script functionality
2 # By Ian Lance Taylor, Cygnus Support
3 #   Copyright 1999, 2000, 2001, 2002, 2004
4 #   Free Software Foundation, Inc.
6 # This file is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 set testname "script"
22 if ![ld_assemble $as $srcdir/$subdir/script.s tmpdir/script.o] { 
23     unresolved $testname
24     return
27 proc check_script { } {
28     global nm
29     global testname
30     global nm_output
32     if ![ld_nm $nm "" tmpdir/script] {
33         unresolved $testname
34         return
35     } 
37     if {![info exists nm_output(text_start)] \
38             || ![info exists nm_output(text_end)] \
39             || ![info exists nm_output(data_start)] \
40             || ![info exists nm_output(data_end)]} {
41         send_log "bad output from nm\n"
42         verbose "bad output from nm"
43         fail $testname
44         return
45     } 
47     set passes 1
48     set text_end 0x104
49     set data_end 0x1004
51     if [istarget *c4x*-*-*] then {
52         set text_end 0x101
53         set data_end 0x1001
54     }
56     if [istarget *c54x*-*-*] then {
57         set text_end 0x102
58         set data_end 0x1002
59     }
61     if {$nm_output(text_start) != 0x100} {
62         send_log "text_start == $nm_output(text_start)\n"
63         verbose "text_start == $nm_output(text_start)"
64         set passes 0
65     } 
67     if {$nm_output(text_end) < $text_end \
68             || $nm_output(text_end) > 0x110} {
69         send_log "text_end == $nm_output(text_end)\n"
70         verbose "text_end == $nm_output(text_end)"
71         set passes 0
72     } 
74     if {$nm_output(data_start) != 0x1000} {
75         send_log "data_start == $nm_output(data_start)\n"
76         verbose "data_start == $nm_output(data_start)"
77         set passes 0
78     } 
80     if {$nm_output(data_end) < $data_end \
81             || $nm_output(data_end) > 0x1010} {
82         send_log "data_end == $nm_output(data_end)\n"
83         verbose "data_end == $nm_output(data_end)"
84         set passes 0
85     } 
87     if { $passes } {
88         pass $testname
89     } else {
90         fail $testname
91     }
94 # PE targets need to set the image base to 0 to avoid complications from nm.
95 set flags ""
96 if {[istarget "*-*-pe*"] \
97     || [istarget "*-*-cygwin*"] \
98     || [istarget "*-*-mingw32*"] \
99     || [istarget "*-*-winnt*"] \
100     || [istarget "*-*-nt"] \
101     || [istarget "*-*-interix*"] } then {
102   set flags "--image-base 0"
105 if ![ld_simple_link $ld tmpdir/script "$flags -T $srcdir/$subdir/script.t tmpdir/script.o"] {
106     fail $testname
107 } else {
108     check_script
111 set testname "MRI script"
113 if ![ld_simple_link $ld tmpdir/script "$flags -c $srcdir/$subdir/scriptm.t"] {
114     fail $testname
115 } else {
116     check_script
119 set testname "MEMORY"
121 if ![ld_simple_link $ld tmpdir/script "$flags -T $srcdir/$subdir/memory.t tmpdir/script.o"] {
122     fail $testname
123 } else {
124     check_script