* ldgram.y: Add ALIGN_WITH_INPUT output section attribute.
[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
1eec346e 3# Copyright 1999-2013 Free Software Foundation, Inc.
a2b64bed 4#
f96b4a7b
NC
5# This file is part of the GNU Binutils.
6#
7# This program is free software; you can redistribute it and/or modify
a2b64bed 8# it under the terms of the GNU General Public License as published by
f96b4a7b 9# the Free Software Foundation; either version 3 of the License, or
a2b64bed 10# (at your option) any later version.
f96b4a7b 11#
a2b64bed
NC
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
f96b4a7b 16#
a2b64bed
NC
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
f96b4a7b
NC
19# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20# MA 02110-1301, USA.
252b5132
RH
21
22set testname "script"
23
24if ![ld_assemble $as $srcdir/$subdir/script.s tmpdir/script.o] {
25 unresolved $testname
26 return
27}
28
29proc check_script { } {
30 global nm
31 global testname
32 global nm_output
33
992c450d 34 if ![ld_nm $nm "" tmpdir/script] {
252b5132 35 unresolved $testname
3ec57632
NC
36 return
37 }
38
39 if {![info exists nm_output(text_start)] \
40 || ![info exists nm_output(text_end)] \
41 || ![info exists nm_output(data_start)] \
42 || ![info exists nm_output(data_end)]} {
43 send_log "bad output from nm\n"
44 verbose "bad output from nm"
45 fail $testname
46 return
47 }
48
49 set passes 1
50 set text_end 0x104
51 set data_end 0x1004
52
53 if [istarget *c4x*-*-*] then {
54 set text_end 0x101
55 set data_end 0x1001
56 }
57
58 if [istarget *c54x*-*-*] then {
59 set text_end 0x102
60 set data_end 0x1002
61 }
62
63 if {$nm_output(text_start) != 0x100} {
64 send_log "text_start == $nm_output(text_start)\n"
65 verbose "text_start == $nm_output(text_start)"
66 set passes 0
67 }
68
69 if {$nm_output(text_end) < $text_end \
70 || $nm_output(text_end) > 0x110} {
71 send_log "text_end == $nm_output(text_end)\n"
72 verbose "text_end == $nm_output(text_end)"
73 set passes 0
74 }
75
76 if {$nm_output(data_start) != 0x1000} {
77 send_log "data_start == $nm_output(data_start)\n"
78 verbose "data_start == $nm_output(data_start)"
79 set passes 0
80 }
81
82 if {$nm_output(data_end) < $data_end \
83 || $nm_output(data_end) > 0x1010} {
84 send_log "data_end == $nm_output(data_end)\n"
85 verbose "data_end == $nm_output(data_end)"
86 set passes 0
87 }
88
89 if { $passes } {
90 pass $testname
252b5132 91 } else {
3ec57632 92 fail $testname
252b5132
RH
93 }
94}
95
777690b6
ILT
96# PE targets need to set the image base to 0 to avoid complications from nm.
97set flags ""
98if {[istarget "*-*-pe*"] \
99 || [istarget "*-*-cygwin*"] \
99ad8390 100 || [istarget "*-*-mingw*"] \
777690b6 101 || [istarget "*-*-winnt*"] \
3ec57632 102 || [istarget "*-*-nt"] \
777690b6
ILT
103 || [istarget "*-*-interix*"] } then {
104 set flags "--image-base 0"
105}
106
107if ![ld_simple_link $ld tmpdir/script "$flags -T $srcdir/$subdir/script.t tmpdir/script.o"] {
252b5132
RH
108 fail $testname
109} else {
110 check_script
111}
112
113set testname "MRI script"
114
777690b6 115if ![ld_simple_link $ld tmpdir/script "$flags -c $srcdir/$subdir/scriptm.t"] {
252b5132
RH
116 fail $testname
117} else {
118 check_script
119}
3ec57632
NC
120
121set testname "MEMORY"
122
123if ![ld_simple_link $ld tmpdir/script "$flags -T $srcdir/$subdir/memory.t tmpdir/script.o"] {
124 fail $testname
125} else {
126 check_script
127}
4a93e180 128
4287f8de 129set test_script_list [lsort [glob $srcdir/$subdir/region-alias-*.t]]
4a93e180
NC
130
131foreach test_script $test_script_list {
c3e5cf5f 132 set testname [file tail $test_script]
4a93e180 133 if ![ld_simple_link $ld tmpdir/script "$flags -T $test_script tmpdir/script.o"] {
c3e5cf5f 134 xfail "REGION_ALIAS: $testname"
4a93e180 135 } else {
c3e5cf5f 136 xpass "REGION_ALIAS: $testname"
4a93e180
NC
137 }
138}
1eec346e
NC
139
140set testname "ALIGN_WITH_INPUT"
141
142if ![ld_simple_link $ld tmpdir/script "$flags -T $srcdir/$subdir/align-with-input.t tmpdir/script.o"] {
143 xfail $testname
144} else {
145 xpass $testname
146}
This page took 0.609901 seconds and 4 git commands to generate.