Add ORIGIN and LENGTH linker script operators.
[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
3ec57632 3# Copyright 2001, 2004
a2b64bed
NC
4# Free Software Foundation, Inc.
5#
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.
252b5132
RH
19
20set testname "script"
21
22if ![ld_assemble $as $srcdir/$subdir/script.s tmpdir/script.o] {
23 unresolved $testname
24 return
25}
26
27proc check_script { } {
28 global nm
29 global testname
30 global nm_output
31
992c450d 32 if ![ld_nm $nm "" tmpdir/script] {
252b5132 33 unresolved $testname
3ec57632
NC
34 return
35 }
36
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 }
46
47 set passes 1
48 set text_end 0x104
49 set data_end 0x1004
50
51 if [istarget *c4x*-*-*] then {
52 set text_end 0x101
53 set data_end 0x1001
54 }
55
56 if [istarget *c54x*-*-*] then {
57 set text_end 0x102
58 set data_end 0x1002
59 }
60
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 }
66
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 }
73
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 }
79
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 }
86
87 if { $passes } {
88 pass $testname
252b5132 89 } else {
3ec57632 90 fail $testname
252b5132
RH
91 }
92}
93
777690b6
ILT
94# PE targets need to set the image base to 0 to avoid complications from nm.
95set flags ""
96if {[istarget "*-*-pe*"] \
97 || [istarget "*-*-cygwin*"] \
98 || [istarget "*-*-mingw32*"] \
99 || [istarget "*-*-winnt*"] \
3ec57632 100 || [istarget "*-*-nt"] \
777690b6
ILT
101 || [istarget "*-*-interix*"] } then {
102 set flags "--image-base 0"
103}
104
105if ![ld_simple_link $ld tmpdir/script "$flags -T $srcdir/$subdir/script.t tmpdir/script.o"] {
252b5132
RH
106 fail $testname
107} else {
108 check_script
109}
110
111set testname "MRI script"
112
777690b6 113if ![ld_simple_link $ld tmpdir/script "$flags -c $srcdir/$subdir/scriptm.t"] {
252b5132
RH
114 fail $testname
115} else {
116 check_script
117}
3ec57632
NC
118
119set testname "MEMORY"
120
121if ![ld_simple_link $ld tmpdir/script "$flags -T $srcdir/$subdir/memory.t tmpdir/script.o"] {
122 fail $testname
123} else {
124 check_script
125}
126
127
This page took 0.237852 seconds and 4 git commands to generate.